Skip to content

Commit

Permalink
feat: Use new linear algebra functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
joschmitt authored and thofma committed Feb 12, 2024
1 parent 7ce63ff commit d121b0d
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 66 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
cohomCalg_jll = "5558cf25-a90e-53b0-b813-cadaa3ae7ade"

[compat]
AbstractAlgebra = "0.37.5"
AbstractAlgebra = "0.37.6"
AlgebraicSolving = "0.4.6"
Distributed = "1.6"
DocStringExtensions = "0.8, 0.9"
Expand All @@ -35,7 +35,7 @@ Hecke = "0.27.0"
JSON = "^0.20, ^0.21"
JSON3 = "1.13.2"
LazyArtifacts = "1.6"
Nemo = "0.41.3"
Nemo = "0.41.5"
Pkg = "1.6"
Polymake = "0.11.12"
Preferences = "1"
Expand Down
2 changes: 1 addition & 1 deletion experimental/FTheoryTools/src/FamilyOfSpaces/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Ideal generated by
ring = coordinate_ring(f)
variables = gens(ring)
w = weights(f)
ideal_gens = right_kernel(ZZMatrix(w))[2]
ideal_gens = Solve.kernel(ZZMatrix(w); side = :right)
ideal_gens = [sum([ideal_gens[l,k] * variables[l] for l in 1:nrows(ideal_gens)]) for k in 1:ncols(ideal_gens)]
return ideal(ideal_gens)
end
2 changes: 1 addition & 1 deletion experimental/FTheoryTools/src/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function _ambient_space(base::NormalToricVariety, fiber_amb_space::NormalToricVa
D2_coeffs = divisor_class(D2).coeff
m1 = reduce(vcat, [D1_coeffs, D2_coeffs])
m2 = transpose(f_rays[1:2,:])
u_matrix = solve_left(b_grades, (-1)*m2*m1)
u_matrix = Solve.solve(b_grades, (-1)*m2*m1; side = :left)

# Form toric ambient space
a_rays = zero_matrix(ZZ, nrows(b_rays) + nrows(f_rays), ncols(b_rays) + ncols(f_rays))
Expand Down
4 changes: 3 additions & 1 deletion experimental/GITFans/src/GITFans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module GITFans
# the necessary Julia packages
using Oscar

import Oscar: AbstractAlgebra.Solve

export git_fan

#############################################################################
Expand Down Expand Up @@ -207,7 +209,7 @@ function action_on_target(Q::Matrix{Int}, G::PermGroup)
matgens = typeof(mat)[]
for ppi in permgens
matimg = mat[Vector{Int}(ppi), 1:n] # permute the rows with `ppi`
push!(matgens, solve(mat, matimg))
push!(matgens, Solve.solve(mat, matimg; side = :right))
end

# Create the matrix group.
Expand Down
6 changes: 4 additions & 2 deletions experimental/LieAlgebras/src/LieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ function center(L::LieAlgebra)
end
end

c_dim, c_basis = left_kernel(mat)
c_basis = Solve.kernel(mat; side = :left)
c_dim = nrows(c_basis)
return ideal(L, [L(c_basis[i, :]) for i in 1:c_dim]; is_basis=true)
end

Expand All @@ -322,7 +323,8 @@ function centralizer(L::LieAlgebra, xs::AbstractVector{<:LieAlgebraElem})
end
end

c_dim, c_basis = left_kernel(mat)
c_basis = Solve.kernel(mat; side = :left)
c_dim = nrows(c_basis)
return sub(L, [L(c_basis[i, :]) for i in 1:c_dim]; is_basis=true)
end

Expand Down
4 changes: 3 additions & 1 deletion experimental/LieAlgebras/src/LieAlgebraHom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ end
Return the kernel of `h` as an ideal of the domain.
"""
function kernel(h::LieAlgebraHom)
ker_dim, ker_b = left_kernel(matrix(h))
ker_b = Solve.kernel(matrix(h); side = :left)
ker_dim = nrows(ker_b)

return ideal(domain(h), [domain(h)(ker_b[i, :]) for i in 1:ker_dim])
end

Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/LieAlgebraIdeal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
left = copy(gens)
while !isempty(left)
g = pop!(left)
can_solve(basis_matrix, _matrix(g); side=:left) && continue
Solve.can_solve(basis_matrix, _matrix(g); side=:left) && continue
for b in basis(L)
push!(left, b * g)
end
Expand Down
2 changes: 2 additions & 0 deletions experimental/LieAlgebras/src/LieAlgebras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ using AbstractAlgebra: CacheDictType, ProductIterator, get_cached!, ordinal_numb

using AbstractAlgebra.PrettyPrinting


# functions with new methods
import ..Oscar:
AbstractAlgebra.Solve,
_iso_oscar_gap,
action,
basis_matrix,
Expand Down
7 changes: 4 additions & 3 deletions experimental/LieAlgebras/src/LieSubalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
left = copy(gens)
while !isempty(left)
g = pop!(left)
can_solve(basis_matrix, _matrix(g); side=:left) && continue
Solve.can_solve(basis_matrix, _matrix(g); side=:left) && continue
for i in 1:nrows(basis_matrix)
push!(left, g * L(basis_matrix[i, :]))
end
Expand Down Expand Up @@ -160,7 +160,7 @@ end
Return `true` if `x` is in the Lie subalgebra `S`, `false` otherwise.
"""
function Base.in(x::LieAlgebraElem, S::LieSubalgebra)
return can_solve(basis_matrix(S), _matrix(x); side=:left)
return Solve.can_solve(basis_matrix(S), _matrix(x); side=:left)
end

###############################################################################
Expand Down Expand Up @@ -213,7 +213,8 @@ function normalizer(L::LieAlgebra, S::LieSubalgebra)
S
)
end
sol_dim, sol = left_kernel(mat)
sol = Solve.kernel(mat; side = :left)
sol_dim = nrows(sol)
sol = sol[:, 1:dim(L)]
c_dim, c_basis = rref(sol)
return sub(L, [L(c_basis[i, :]) for i in 1:c_dim]; is_basis=true)
Expand Down
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/src/Util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function coefficient_vector(M::MatElem{T}, basis::Vector{<:MatElem{T}}) where {T
for i in 1:nr, j in 1:nc
rhs[(i - 1) * nc + j, 1] = M[i, j]
end
fl, sol = can_solve_with_solution(lgs, rhs)
fl, sol = Solve.can_solve_with_solution(lgs, rhs; side = :right)
@assert fl
return transpose(sol)
end
2 changes: 1 addition & 1 deletion experimental/LieAlgebras/test/LieAlgebraModule-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
b = V()
while iszero(a) ||
iszero(b) ||
can_solve(
Oscar.Solve.can_solve(
Oscar.LieAlgebras._matrix(a),
Oscar.LieAlgebras._matrix(b);
side=:left,
Expand Down
3 changes: 2 additions & 1 deletion experimental/ModStd/ModStdQt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module ModStdQt
using Oscar
import Oscar.Nemo
import Oscar.Hecke
import Oscar.Solve

function __init__()
Hecke.add_verbose_scope(:ModStdQt)
Expand Down Expand Up @@ -892,7 +893,7 @@ function Oscar.lift(f::PolyRingElem, g::PolyRingElem, a::AbsSimpleNumFieldElem,
for i=1:n
mm[i, 1] = coeff(d*b, i-1)
end
s = solve(m, mm)
s = Solve.solve(m, mm; side = :right)
B = q(parent(f)(vec(collect(s))))
@assert all(x->iszero(evaluate(numerator(x), V)), coefficients(lift(gg(B))))
o = lift(inv(derivative(gg)(B)))
Expand Down
15 changes: 8 additions & 7 deletions experimental/QuadFormAndIsom/src/embeddings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function _overlattice(gamma::TorQuadModuleMap,
_B = QQ(1, denominator(Fakeglue))*change_base_ring(QQ, numerator(_FakeB))
C = lattice(ambient_space(A), _B[end-rank(A)-rank(B)+1:end, :])
fC = block_diagonal_matrix(QQMatrix[fA, fB])
_B = solve_left(reduce(vcat, basis_matrix.([A,B])), basis_matrix(C))
_B = Solve.solve(reduce(vcat, basis_matrix.([A,B])), basis_matrix(C); side = :left)
fC = _B*fC*inv(_B)
else
_glue = Vector{QQFieldElem}[lift(HAinD(a)) + lift(HBinD(gamma(a))) for a in gens(domain(gamma))]
Expand All @@ -187,7 +187,7 @@ function _overlattice(gamma::TorQuadModuleMap,
_B = QQ(1, denominator(Fakeglue))*change_base_ring(QQ, numerator(_FakeB))
C = lattice(ambient_space(cover(D)), _B[end-rank(A)-rank(B)+1:end, :])
fC = block_diagonal_matrix(QQMatrix[fA, fB])
_B = solve_left(block_diagonal_matrix(basis_matrix.(ZZLat[A, B])), basis_matrix(C))
_B = Solve.solve(block_diagonal_matrix(basis_matrix.(ZZLat[A, B])), basis_matrix(C); side = :left)
fC = _B*fC*inv(_B)
end
@hassert :ZZLatWithIsom 1 fC*gram_matrix(C)*transpose(fC) == gram_matrix(C)
Expand Down Expand Up @@ -377,7 +377,7 @@ function _fitting_isometries(OqfN::AutomorphismGroup{TorQuadModule},
# To summarize, in the general case, we obtain representatives of fitting
# isometries by identifying CN-conjugate isometries in the coset fNKN.
if first
reporb = QQMatrix[solve_left(basis_matrix(N), basis_matrix(N)*matrix(_fN))]
reporb = QQMatrix[Solve.solve(basis_matrix(N), basis_matrix(N)*matrix(_fN); side = :left)]
else
KNhat, _ = discrep\(kernel(_actN)[1])
fNKN = _fN*KNhat
Expand All @@ -391,7 +391,7 @@ function _fitting_isometries(OqfN::AutomorphismGroup{TorQuadModule},
end
end
end
reporb = QQMatrix[solve_left(basis_matrix(N), basis_matrix(N)*matrix(a[1])) for a in orb_and_rep]
reporb = QQMatrix[Solve.solve(basis_matrix(N), basis_matrix(N)*matrix(a[1]); side = :left) for a in orb_and_rep]
return reporb
end

Expand Down Expand Up @@ -925,7 +925,8 @@ function _subgroups_orbit_representatives_and_stabilizers_elementary(Vinq::TorQu

F = base_ring(Qp)
# K is H0 but seen a subvector space of Vp (which is V)
k, K = kernel(VptoQp.matrix; side = :left)
K = Solve.kernel(VptoQp.matrix; side = :left)
k = nrows(K)
gene_H0p = elem_type(Vp)[Vp(vec(collect(K[i,:]))) for i in 1:k]
orb_and_stab = orbit_representatives_and_stabilizers(MGp, g-k)

Expand Down Expand Up @@ -1405,8 +1406,8 @@ function primitive_embeddings(G::ZZGenus, M::ZZLat; classification::Symbol = :su
# L, M3 and N live in a very big ambient space: we redescribed them in the
# rational span of L so that L has full rank and we keep only the
# necessary information.
bM = solve_left(basis_matrix(L), basis_matrix(M3))
bN = solve_left(basis_matrix(L), basis_matrix(N))
bM = Solve.solve(basis_matrix(L), basis_matrix(M3); side = :left)
bN = Solve.solve(basis_matrix(L), basis_matrix(N); side = :left)
L = integer_lattice(; gram = gram_matrix(L))
M3 = lattice_in_same_ambient_space(L, bM)
N = lattice_in_same_ambient_space(L, bN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ function _transfer_discriminant_isometry(res::AbstractSpaceRes,
B2abs = map_entries(p, B2abs)

# Our local modular solution we have to lift
K = solve_left(Bpabs, B2abs)
K = Solve.solve(Bpabs, B2abs; side = :left)
K = map_entries(a -> EabstoE(Eabs(p\a)), K)

# If what we have done is correct then K*newBp == newB2 modulo O_p, so all
Expand Down
8 changes: 4 additions & 4 deletions experimental/QuadFormAndIsom/src/lattices_with_isometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1821,7 +1821,7 @@ function _real_kernel_signatures(L::ZZLat, M::MatElem)
C = base_ring(M)
G = gram_matrix(L)
GC = change_base_ring(C, G)
_, K = left_kernel(M)
K = Solve.kernel(M; side = :left)
diag = K*GC*transpose(K)

diag = Hecke._gram_schmidt(diag, C)[1]
Expand Down Expand Up @@ -1951,7 +1951,7 @@ function kernel_lattice(Lf::ZZLatWithIsom, p::QQPolyRingElem)
f = isometry(Lf)
M = p(f)
d = denominator(M)
k, K = left_kernel(change_base_ring(ZZ, d*M))
K = Solve.kernel(change_base_ring(ZZ, d*M); side = :left)
return lattice(ambient_space(Lf), K*basis_matrix(L))
end

Expand Down Expand Up @@ -2141,7 +2141,7 @@ function coinvariant_lattice(L::ZZLat, G::MatrixGroup; ambient_representation::B
if !ambient_representation
g_ambient = block_diagonal_matrix(QQMatrix[matrix(g), identity_matrix(QQ, nrows(B2))])
g_ambient = iB3*g_ambient*B3
m = solve_left(basis_matrix(C), basis_matrix(C)*g_ambient)
m = Solve.solve(basis_matrix(C), basis_matrix(C)*g_ambient; side = :left)
push!(gene, m)
else
push!(gene, matrix(g))
Expand Down Expand Up @@ -2216,7 +2216,7 @@ function invariant_coinvariant_pair(L::ZZLat, G::MatrixGroup; ambient_representa
if !ambient_representation
g_ambient = block_diagonal_matrix(QQMatrix[matrix(g), identity_matrix(QQ, nrows(B2))])
g_ambient = iB3*g_ambient*B3
m = solve_left(basis_matrix(C), basis_matrix(C)*g_ambient)
m = Solve.solve(basis_matrix(C), basis_matrix(C)*g_ambient; side = :left)
push!(gene, m)
else
push!(gene, matrix(g))
Expand Down
4 changes: 3 additions & 1 deletion experimental/Rings/QQAbAndPChars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ using ..Oscar

import Oscar: IJuliaMime

import Oscar: Solve

###############################################################################
#
# Partial character functions
Expand Down Expand Up @@ -42,7 +44,7 @@ end
function (Chi::PartialCharacter)(b::ZZMatrix)
@assert nrows(b) == 1
@assert Nemo.ncols(b) == Nemo.ncols(Chi.A)
s = can_solve_with_solution(Chi.A, b, side = :left)
s = Solve.can_solve_with_solution(Chi.A, b, side = :left)
@assert s[1]
return evaluate(FacElem(Dict([(Chi.b[i], s[2][1, i]) for i = 1:length(Chi.b)])))
end
Expand Down
3 changes: 2 additions & 1 deletion experimental/Schemes/WeilDivisor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ function _subsystem(L::LinearSystem, P::IdealSheaf, n)
A[i, k] = c
end
end
r, K = left_kernel(A)
K = Solve.kernel(A; side = :left)
r = nrows(K)
new_gens = [sum([K[i,j]*gen(L, j) for j in 1:ncols(K)]) for i in 1:r]
W = weil_divisor(L)
PW = WeilDivisor(P, check=false)
Expand Down
5 changes: 3 additions & 2 deletions experimental/Schemes/elliptic_surface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,8 @@ function _prop217(E::EllipticCurve, P::EllipticCurvePoint, k)
cc = [[coeff(j, abi) for abi in ab] for j in eqns]
M = matrix(B, length(eqns), length(ab), reduce(vcat,cc, init=elem_type(base)[]))
# @assert M == matrix(base, cc) # does not work if length(eqns)==0
kerdim, K = kernel(M)
K = Solve.kernel(M; side = :right)
kerdim = ncols(K)
result = Tuple{elem_type(Bt),elem_type(Bt)}[]
t = gen(Bt)
for j in 1:kerdim
Expand Down Expand Up @@ -1358,7 +1359,7 @@ function extended_ade(ADE::Symbol, n::Int)
G[n,1] = -1
end
@assert rank(G) == n
return -G, left_kernel(G)[2]
return -G, Solve.kernel(G; side = :left)
end

function basis_representation(X::EllipticSurface, D::WeilDivisor)
Expand Down
4 changes: 2 additions & 2 deletions experimental/SymmetricIntersections/src/representations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1280,12 +1280,12 @@ function complement_submodule(rep::LinRep{S, T, U}, M::W) where {S, T, U, W <: M
B2j = B2[j]
B2jM = (B2j*M)[1:1,:]
B1u = reduce(vcat, [BB[1:1,:] for BB in B1])
_Kj = solve_left(B1u, B2jM)
_Kj = Solve.solve(B1u, B2jM; side = :left)
for i in 1:d, k in 1:length(B1)
_K[(k-1)*d + i, i + (j-1)*d] = _Kj[1, k]
end
end
a, K2 = left_kernel(_K)
K2 = Solve.kernel(_K; side = :left)
Borth = K2*reduce(vcat, B1)
@assert is_submodule(rep, Borth)
bas = vcat(bas, Borth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ function _intersection_with_grassmannian(V::Vector{T}, n::Int, t::Int;
end
Grtn = subscheme(X, ideal_Gr)
B = reduce(vcat, V)
_, K = right_kernel(B)
K = Solve.kernel(B; side = :right)

if ncols(K) == 0
return ideal_Gr
Expand Down
Loading

0 comments on commit d121b0d

Please sign in to comment.