Skip to content

Commit

Permalink
Use new matrix functions
Browse files Browse the repository at this point in the history
  • Loading branch information
joschmitt authored and thofma committed Feb 11, 2024
1 parent 7ce63ff commit 598d2c6
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 20 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
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
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
4 changes: 2 additions & 2 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
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
3 changes: 2 additions & 1 deletion experimental/QuadFormAndIsom/src/embeddings.jl
Original file line number Diff line number Diff line change
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
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/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
8 changes: 4 additions & 4 deletions src/AlgebraicGeometry/Surfaces/K3Auto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function short_vectors_affine(gram::MatrixElem, v::MatrixElem, alpha::QQFieldEle
tmp = FakeFmpqMat(w)
wn = numerator(tmp)
wd = denominator(tmp)
b, x = can_solve_with_solution(transpose(wn), matrix(ZZ, 1, 1, [alpha*wd]))
b, x = can_solve_with_solution(transpose(wn), matrix(ZZ, 1, 1, [alpha*wd]); side = :right)
if !b
return QQMatrix[]
end
Expand Down Expand Up @@ -1096,7 +1096,7 @@ function _alg58_close_vector(data::BorcherdsCtx, w::ZZMatrix)
B = basis_matrix(SSdual)
KB = K*B
for (alpha, d) in keys(cvp_inputs)
can_solve_i, x = can_solve_with_solution(transpose(wn), matrix(ZZ, 1, 1, [alpha*wd]))
can_solve_i, x = Solve.can_solve_with_solution(transpose(wn), matrix(ZZ, 1, 1, [alpha*wd]); side = :right)
if !can_solve_i
continue
end
Expand Down Expand Up @@ -1598,8 +1598,8 @@ function span_in_S(L, S, weyl)
else
M = linear_equation_matrix(spanC)
end
k, K = kernel(M)
gensN = transpose(K)[1:k,:]
K = Solve.kernel(M; side = :right)
gensN = transpose(K)
return gensN
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Map
v = [images[i,k] for k in 1:ncols(images)]
j = findfirst(x -> x == true, [(v in maximal_cones(cod)[j]) for j in 1:nmaxcones(cod)])
m = reduce(vcat, [Int(ray_indices(maximal_cones(cod))[j, k]) * cod_rays[k:k, :] for k in 1:nrays(cod)])
mapping_matrix = hcat(mapping_matrix, solve(transpose(m), transpose(images[i:i, :])))
mapping_matrix = hcat(mapping_matrix, solve(transpose(m), transpose(images[i:i, :]); side = :right))
end
return hom(torusinvariant_weil_divisor_group(d), torusinvariant_weil_divisor_group(cod), transpose(mapping_matrix))
end
Expand Down Expand Up @@ -240,7 +240,7 @@ Covering
hb_V_mat = matrix(ZZ, hb_V)
hb_V_img = hb_V_mat * At
hb_U_mat = matrix(ZZ, hb_U)
sol = solve_left(hb_U_mat, hb_V_img)
sol = solve(hb_U_mat, hb_V_img; side = :left)
@assert sol*hb_U_mat == hb_V_img
@assert all(x->x>=0, sol)

Expand Down
21 changes: 21 additions & 0 deletions src/Oscar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,27 @@ function build()
system("Build.jl")
end

# temporarily

import AbstractAlgebra: Solve

const solve = AbstractAlgebra.Solve.solve
const can_solve = AbstractAlgebra.Solve.can_solve
const can_solve_with_solution = AbstractAlgebra.Solve.can_solve_with_solution

kernel(args...; kw...) = Hecke.kernel(args...; kw...)

export solve, can_solve, can_solve_with_solution, kernel

function kernel(M::MatElem; side::Symbol = :right)
return AbstractAlgebra.Solve.kernel(M, side = side)
end

function kernel(R::Ring, M::MatElem; side::Symbol = :right)
return AbstractAlgebra.Solve.kernel(R, M, side = side)
end


include("assertions.jl")

include("exports.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/AbelianClosure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ function _embedding(F::AbsSimpleNumField, K::QQAbField{AbsSimpleNumField},
x = Hecke.force_coerce_cyclo(Kn, x)
# ... and then w.r.t. `F`
a = Hecke.coefficients(x)
fl, sol = can_solve_with_solution(c, matrix(QQ, length(a), 1, a))
fl, sol = can_solve_with_solution(c, matrix(QQ, length(a), 1, a); side = :right)
if fl
b = transpose(sol)
b = [b[i] for i in 1:length(b)]
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/groebner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ function _find_weights(F::Vector{P}) where {P <: MPolyRingElem}
exp_diffs = permutedims(reduce(hcat, [e[i] - e[1] for e in
(collect).((exponents).(F))
for i in 2:length(e)]))
K = kernel(matrix(QQ, nrows, ncols, exp_diffs))[2]
K = kernel(matrix(QQ, nrows, ncols, exp_diffs); side = :right)
isempty(K) && return zeros(Int, ncols)
# Here we try to find a vector with strictly positive entries in K
# this method to find such a vector is taken from
Expand Down
4 changes: 4 additions & 0 deletions src/imports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ let exclude_hecke = [
:tail,
:terms,
:YoungTableau,
:kernel,
:solve,
:can_solve,
:can_solve_with_solution,
]
for i in names(Hecke)
(i in exclude_hecke || !isdefined(Hecke, i)) && continue
Expand Down

0 comments on commit 598d2c6

Please sign in to comment.