Skip to content

Commit

Permalink
Replace all uses of FlintQQ and FlintZZ (oscar-system#4261)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Nov 6, 2024
1 parent e91af41 commit 309dcf7
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 66 deletions.
6 changes: 3 additions & 3 deletions docs/src/DeveloperDocumentation/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ like `cyclotomic_polynomial`
```
module Globals
using Hecke
const Qx, _ = polynomial_ring(FlintQQ, :x, cached = false)
const Zx, _ = polynomial_ring(FlintZZ, :x, cached = false)
const Zxy, _ = polynomial_ring(FlintZZ, [:x, :y], cached = false)
const Qx, _ = polynomial_ring(QQ, :x, cached = false)
const Zx, _ = polynomial_ring(ZZ, :x, cached = false)
const Zxy, _ = polynomial_ring(ZZ, [:x, :y], cached = false)
end
```
You can use these in your own code as well, or imitate this pattern if convenient.
Expand Down
6 changes: 3 additions & 3 deletions experimental/QuadFormAndIsom/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end
@test evaluate(minimal_polynomial(Vf), -1) == 0
@test evaluate(characteristic_polynomial(Vf), 0) == 1

G = matrix(FlintQQ, 6, 6 ,[3, 1, -1, 1, 0, 0, 1, 3, 1, 1, 1, 1, -1, 1, 3, 0, 0, 1, 1, 1, 0, 4, 2, 2, 0, 1, 0, 2, 4, 2, 0, 1, 1, 2, 2, 4])
G = matrix(QQ, 6, 6 ,[3, 1, -1, 1, 0, 0, 1, 3, 1, 1, 1, 1, -1, 1, 3, 0, 0, 1, 1, 1, 0, 4, 2, 2, 0, 1, 0, 2, 4, 2, 0, 1, 1, 2, 2, 4])
V = quadratic_space(QQ, G)
f = matrix(QQ, 6, 6, [1 0 0 0 0 0; 0 0 -1 0 0 0; -1 1 -1 0 0 0; 0 0 0 1 0 -1; 0 0 0 0 0 -1; 0 0 0 0 1 -1])
Vf = @inferred quadratic_space_with_isometry(V, f)
Expand Down Expand Up @@ -386,8 +386,8 @@ end
@test length(reps) == 1

## Odd case
B = matrix(FlintQQ, 5, 5 ,[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
G = matrix(FlintQQ, 5, 5 ,[3, 1, 0, 0, 0, 1, 3, 1, 1, -1, 0, 1, 3, 0, 0, 0, 1, 0, 3, 0, 0, -1, 0, 0, 3]);
B = matrix(QQ, 5, 5 ,[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
G = matrix(QQ, 5, 5 ,[3, 1, 0, 0, 0, 1, 3, 1, 1, -1, 0, 1, 3, 0, 0, 0, 1, 0, 3, 0, 0, -1, 0, 0, 3]);
L = integer_lattice(B, gram = G);
k = lattice_in_same_ambient_space(L, B[2:2, :])
N = orthogonal_submodule(L, k)
Expand Down
2 changes: 1 addition & 1 deletion src/NumberTheory/GaloisGrp/GaloisGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ end

function Nemo.roots_upper_bound(f::ZZMPolyRingElem, t::Int = 0)
@assert nvars(parent(f)) == 2
Qs, s = rational_function_field(FlintQQ, "t", cached = false)
Qs, s = rational_function_field(QQ, "t", cached = false)
Qsx, x = polynomial_ring(Qs, cached = false)
F = evaluate(f, [x, Qsx(s)])
dis = numerator(discriminant(F))
Expand Down
4 changes: 2 additions & 2 deletions src/NumberTheory/GaloisGrp/Qt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ for analysis of the denominator and the infinite valuations
function _galois_init(F::Generic.FunctionField{QQFieldElem}; tStart::Int = -1)
f = defining_polynomial(F)
@assert is_monic(f)
Zxy, (x, y) = polynomial_ring(FlintZZ, 2, cached = false)
Zxy, (x, y) = polynomial_ring(ZZ, 2, cached = false)
ff = Zxy()
d = lcm(map(denominator, coefficients(f)))
df = f*d
Expand All @@ -101,7 +101,7 @@ function _galois_init(F::Generic.FunctionField{QQFieldElem}; tStart::Int = -1)
for i=0:degree(f)
c = coeff(df, i)
if !iszero(c)
ff += map_coefficients(FlintZZ, numerator(c))(y)*x^i
ff += map_coefficients(ZZ, numerator(c))(y)*x^i
end
end
_subfields(F, ff, tStart = tStart)
Expand Down
16 changes: 8 additions & 8 deletions src/NumberTheory/NmbThy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function norm_equation_fac_elem(R::AbsNumFieldOrder, k::ZZRingElem; abs::Bool =
S = Tuple{Vector{Tuple{Hecke.ideal_type(R), Int}}, Vector{ZZMatrix}}[]
for (p, k) = lp.fac
P = prime_decomposition(R, p)
s = solve_non_negative(matrix(FlintZZ, 1, length(P), [degree(x[1]) for x = P]), matrix(FlintZZ, 1, 1, [k]))
s = solve_non_negative(matrix(ZZ, 1, length(P), [degree(x[1]) for x = P]), matrix(ZZ, 1, 1, [k]))
push!(S, (P, ZZMatrix[view(s, i:i, 1:ncols(s)) for i=1:nrows(s)]))
end
sol = FacElem{AbsSimpleNumFieldElem, AbsSimpleNumField}[]
Expand Down Expand Up @@ -144,10 +144,10 @@ function norm_equation_fac_elem(R::Hecke.RelNumFieldOrder{AbsSimpleNumFieldElem,
q, mms = snf(q)
mq = mq*inv(mms)

C = vcat([matrix(FlintZZ, 1, ngens(q), [valuation(mS(preimage(mq, q[i])), p) for i=1:ngens(q)]) for p = keys(lp)])
C = vcat([matrix(ZZ, 1, ngens(q), [valuation(mS(preimage(mq, q[i])), p) for i=1:ngens(q)]) for p = keys(lp)])

A = vcat([matrix(FlintZZ, 1, ngens(q), [valuation(norm(mkK, mS(preimage(mq, g))), p) for g in gens(q)]) for p = keys(la)])
b = matrix(FlintZZ, length(la), 1, [valuation(a, p) for p = keys(la)])
A = vcat([matrix(ZZ, 1, ngens(q), [valuation(norm(mkK, mS(preimage(mq, g))), p) for g in gens(q)]) for p = keys(la)])
b = matrix(ZZ, length(la), 1, [valuation(a, p) for p = keys(la)])

so = solve_mixed(A, b, C)
u, mu = Hecke.unit_group_fac_elem(parent(a))
Expand Down Expand Up @@ -189,16 +189,16 @@ function is_irreducible(a::AbsNumFieldOrderElem{AbsSimpleNumField,AbsSimpleNumFi
# if this is possible, then a is not irreducible as a
# is then ms(Ax) * ms(Ay) and neither is trivial.

I = identity_matrix(FlintZZ, length(S))
I = identity_matrix(ZZ, length(S))
A = hcat(I, I)
#so A*(x|y) = x+y = sol is the 1. condition
C = cat(V, V, dims=(1,2))
# C(x|y) >=0 iff Cx >=0 and Cy >=0
#Cx <> 0 iff (1,..1)*Cx >= 1
one = matrix(FlintZZ, 1, length(S), [1 for p = S])
zer = matrix(FlintZZ, 1, length(S), [0 for p = S])
one = matrix(ZZ, 1, length(S), [1 for p = S])
zer = matrix(ZZ, 1, length(S), [0 for p = S])
C = vcat(C, hcat(one, zer), hcat(zer, one))
d = matrix(FlintZZ, 2*length(S)+2, 1, [0 for i = 1:2*length(S) + 2])
d = matrix(ZZ, 2*length(S)+2, 1, [0 for i = 1:2*length(S) + 2])
d[end-1, 1] = 1
d[end, 1] = 1
pt = solve_mixed(A, sol, C, d)
Expand Down
20 changes: 10 additions & 10 deletions src/PolyhedralGeometry/solving_integrally.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ Note that the output can be permuted, hence we sort it.
```jldoctest
julia> A = ZZMatrix([1 1]);
julia> b = zero_matrix(FlintZZ, 1,1); b[1,1]=7;
julia> b = zero_matrix(ZZ, 1,1); b[1,1]=7;
julia> C = ZZMatrix([1 0; 0 1]);
julia> d = zero_matrix(FlintZZ,2,1); d[1,1]=2; d[2,1]=3;
julia> d = zero_matrix(ZZ,2,1); d[1,1]=2; d[2,1]=3;
julia> sortslices(Matrix{BigInt}(solve_mixed(A, b, C, d)), dims=1)
3×2 Matrix{BigInt}:
Expand Down Expand Up @@ -101,7 +101,7 @@ Note that the output can be permuted, hence we sort it.
```jldoctest
julia> A = ZZMatrix([1 1]);
julia> b = zero_matrix(FlintZZ, 1,1); b[1,1]=3;
julia> b = zero_matrix(ZZ, 1,1); b[1,1]=3;
julia> C = ZZMatrix([1 0; 0 1]);
Expand Down Expand Up @@ -131,9 +131,9 @@ julia> for x in it
"""
solve_mixed(
as::Type{T}, A::ZZMatrix, b::ZZMatrix, C::ZZMatrix; permit_unbounded=false
) where {T} = solve_mixed(T, A, b, C, zero_matrix(FlintZZ, nrows(C), 1); permit_unbounded)
) where {T} = solve_mixed(T, A, b, C, zero_matrix(ZZ, nrows(C), 1); permit_unbounded)
solve_mixed(A::ZZMatrix, b::ZZMatrix, C::ZZMatrix; permit_unbounded=false) =
solve_mixed(ZZMatrix, A, b, C, zero_matrix(FlintZZ, nrows(C), 1); permit_unbounded)
solve_mixed(ZZMatrix, A, b, C, zero_matrix(ZZ, nrows(C), 1); permit_unbounded)

@doc raw"""
solve_ineq(as::Type{T}, A::ZZMatrix, b::ZZMatrix) where {T}
Expand All @@ -151,7 +151,7 @@ Note that the output can be permuted, hence we sort it.
```jldoctest
julia> A = ZZMatrix([1 0; 0 1; -1 0; 0 -1]);
julia> b = zero_matrix(FlintZZ, 4,1); b[1,1]=1; b[2,1]=1; b[3,1]=0; b[4,1]=0;
julia> b = zero_matrix(ZZ, 4,1); b[1,1]=1; b[2,1]=1; b[3,1]=0; b[4,1]=0;
julia> sortslices(Matrix{BigInt}(solve_ineq(A, b)), dims=1)
4×2 Matrix{BigInt}:
Expand All @@ -173,8 +173,8 @@ SubObjectIterator{PointVector{ZZRingElem}}
solve_ineq(as::Type{T}, A::ZZMatrix, b::ZZMatrix; permit_unbounded=false) where {T} =
solve_mixed(
T,
zero_matrix(FlintZZ, 0, ncols(A)),
zero_matrix(FlintZZ, 0, 1),
zero_matrix(ZZ, 0, ncols(A)),
zero_matrix(ZZ, 0, 1),
-A,
-b;
permit_unbounded,
Expand All @@ -198,7 +198,7 @@ Note that the output can be permuted, hence we sort it.
```jldoctest
julia> A = ZZMatrix([1 1]);
julia> b = zero_matrix(FlintZZ, 1,1); b[1,1]=3;
julia> b = zero_matrix(ZZ, 1,1); b[1,1]=3;
julia> sortslices(Matrix{BigInt}(solve_non_negative(A, b)), dims=1)
4×2 Matrix{BigInt}:
Expand All @@ -219,6 +219,6 @@ SubObjectIterator{PointVector{ZZRingElem}}
"""
solve_non_negative(
as::Type{T}, A::ZZMatrix, b::ZZMatrix; permit_unbounded=false
) where {T} = solve_mixed(T, A, b, identity_matrix(FlintZZ, ncols(A)); permit_unbounded)
) where {T} = solve_mixed(T, A, b, identity_matrix(ZZ, ncols(A)); permit_unbounded)
solve_non_negative(A::ZZMatrix, b::ZZMatrix; permit_unbounded=false) =
solve_non_negative(ZZMatrix, A, b; permit_unbounded)
4 changes: 2 additions & 2 deletions src/Rings/NumberField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ parent(a::NfNSGenElem) = a.parent

Hecke.data(a::NfNSGenElem) = a.f

base_field(K::NfNSGen{QQFieldElem, QQMPolyRingElem}) = FlintQQ
base_field(K::NfNSGen{QQFieldElem, QQMPolyRingElem}) = QQ

base_field(K::NfNSGen) = base_ring(polynomial_ring(K))

Expand Down Expand Up @@ -616,7 +616,7 @@ end
function basis_matrix(v::Vector{NfNSGenElem{QQFieldElem, QQMPolyRingElem}},
::Type{Hecke.FakeFmpqMat})
d = degree(parent(v[1]))
z = zero_matrix(FlintQQ, length(v), d)
z = zero_matrix(QQ, length(v), d)
for i in 1:length(v)
elem_to_mat_row!(z, i, v[i])
end
Expand Down
14 changes: 7 additions & 7 deletions src/Rings/binomial_ideals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ function (Chi::PartialCharacter)(b::ZZMatrix)
end

function (Chi::PartialCharacter)(b::Vector{ZZRingElem})
return Chi(matrix(FlintZZ, 1, length(b), b))
return Chi(matrix(ZZ, 1, length(b), b))
end

function have_same_domain(P::PartialCharacter, Q::PartialCharacter)
Expand Down Expand Up @@ -482,7 +482,7 @@ function ideal_from_character(P::PartialCharacter, R::MPolyRing)

@assert ncols(P.A) == nvars(R)
#test if the domain of the partial character is the zero lattice
if isone(nrows(P.A)) && have_same_span(P.A, zero_matrix(FlintZZ, 1, ncols(P.A)))
if isone(nrows(P.A)) && have_same_span(P.A, zero_matrix(ZZ, 1, ncols(P.A)))
return ideal(R, zero(R))
end

Expand Down Expand Up @@ -582,7 +582,7 @@ function partial_character_from_ideal(I::MPolyIdeal, R::MPolyRing)

Delta = cell[2] #cell variables
if isempty(Delta)
return partial_character(zero_matrix(FlintZZ, 1, nvars(R)), [one(QQAb)], Set{Int64}())
return partial_character(zero_matrix(ZZ, 1, nvars(R)), [one(QQAb)], Set{Int64}())
end

#now consider the case where Delta is not empty
Expand All @@ -598,12 +598,12 @@ function partial_character_from_ideal(I::MPolyIdeal, R::MPolyRing)
end
QQAbcl, = abelian_closure(QQ)
if iszero(J)
return partial_character(zero_matrix(FlintZZ, 1, nvars(R)), [one(QQAbcl)], Set{Int64}())
return partial_character(zero_matrix(ZZ, 1, nvars(R)), [one(QQAbcl)], Set{Int64}())
end
#now case if J \neq 0
#let ts be a list of minimal binomial generators for J
gb = groebner_basis(J, complete_reduction = true)
vs = zero_matrix(FlintZZ, 0, nvars(R))
vs = zero_matrix(ZZ, 0, nvars(R))
images = QQAbFieldElem{AbsSimpleNumFieldElem}[]
for t in gb
#TODO: Once tail will be available, use it.
Expand All @@ -612,7 +612,7 @@ function partial_character_from_ideal(I::MPolyIdeal, R::MPolyRing)
u = exponent_vector(lm, 1)
v = exponent_vector(tl, 1)
#now test if we need the vector uv
uv = matrix(FlintZZ, 1, nvars(R), Int[u[j]-v[j] for j =1:length(u)]) #this is the vector of u-v
uv = matrix(ZZ, 1, nvars(R), Int[u[j]-v[j] for j =1:length(u)]) #this is the vector of u-v
#TODO: It can be done better by saving the hnf...
if !can_solve(vs, uv, side = :left)[1]
push!(images, -QQAbcl(AbstractAlgebra.leading_coefficient(tl)))
Expand Down Expand Up @@ -1162,7 +1162,7 @@ function birth_death_ideal(m::Int, n::Int)
R = Matrix{QQMPolyRingElem}(undef, m, n+1)
D = Matrix{QQMPolyRingElem}(undef, m+1, m)
L = Matrix{QQMPolyRingElem}(undef, m+1, n+1)
Qxy, gQxy = polynomial_ring(FlintQQ, length(U)+length(R)+length(D)+length(L); cached = false)
Qxy, gQxy = polynomial_ring(QQ, length(U)+length(R)+length(D)+length(L); cached = false)
pols = Vector{elem_type(Qxy)}(undef, 4*n*m)
ind = 1
for i = 1:m+1
Expand Down
4 changes: 2 additions & 2 deletions src/Rings/hilbert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,9 @@ end
# # Transpose while converting:
# ncols = length(W);
# nrows = length(W[1]);
# A = zero_matrix(FlintZZ, nrows,ncols);
# A = zero_matrix(ZZ, nrows,ncols);
# for i in 1:nrows for j in 1:ncols A[i,j] = W[j][i]; end; end;
# b = zero_matrix(FlintZZ, nrows,1);
# b = zero_matrix(ZZ, nrows,1);
# try
# solve_non_negative(A, b); # any non-zero soln gives rise to infinitely many, which triggers an exception
# catch e
Expand Down
2 changes: 1 addition & 1 deletion src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ function monomial_basis(W::MPolyDecRing, d::FinGenAbGroupElem)
k, im = kernel(h)
#need the positive elements in there...
#Ax = b, Cx >= 0
C = identity_matrix(FlintZZ, ngens(W))
C = identity_matrix(ZZ, ngens(W))
A = reduce(vcat, [x.coeff for x = W.d])
k = solve_mixed(transpose(A), transpose(d.coeff), C)
for ee = 1:nrows(k)
Expand Down
Loading

0 comments on commit 309dcf7

Please sign in to comment.