Skip to content

Commit

Permalink
Consistently use ZZ instead of mix of ZZ and FlintZZ
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Apr 17, 2024
1 parent 3131da4 commit 54628fd
Show file tree
Hide file tree
Showing 64 changed files with 254 additions and 254 deletions.
4 changes: 2 additions & 2 deletions benchmarks/charpoly_integers.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function benchmark_charpoly_int()
print("benchmark_charpoly_int ... ")
M = matrix_space(FlintZZ, 80, 80)()
M = matrix_space(ZZ, 80, 80)()

for i in 1:80
for j in 1:80
M[i, j] = rand(-20:20)
end
end

tt = @elapsed charpoly(polynomial_ring(FlintZZ, "x")[1], M)
tt = @elapsed charpoly(polynomial_ring(ZZ, "x")[1], M)
println("$tt")
end
2 changes: 1 addition & 1 deletion benchmarks/det_commutative_ring.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function benchmark_znz_det()
print("benchmark_znz_det ... ")
n = 2003 * 1009
Zn, = residue_ring(FlintZZ, n)
Zn, = residue_ring(ZZ, n)
R, x = polynomial_ring(Zn, "x")

M = matrix_space(R, 80, 80)()
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/det_polynomials.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function benchmark_det_poly_ring()
print("benchmark_det_poly_ring ... ")
ZZx, x = polynomial_ring(FlintZZ, "x")
ZZx, x = polynomial_ring(ZZ, "x")
M = matrix_space(ZZx, 40, 40)()

for i in 1:40
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/fateman.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function benchmark_fateman()
print("benchmark_fateman ... ")
R, x = polynomial_ring(FlintZZ, "x")
R, x = polynomial_ring(ZZ, "x")
S, y = polynomial_ring(R, "y")
T, z = polynomial_ring(S, "z")
U, t = polynomial_ring(T, "t")
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/minpoly_integers.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function benchmark_minpoly_integers()
print("benchmark_minpoly_integers ... ")
M = matrix_space(FlintZZ, 80, 80)()
M = matrix_space(ZZ, 80, 80)()

for i in 1:40
for j in 1:40
Expand All @@ -14,7 +14,7 @@ function benchmark_minpoly_integers()
similarity!(M, rand(1:80), ZZRingElem(rand(-3:3)))
end

tt = @elapsed minpoly(polynomial_ring(FlintZZ, "x")[1], M)
tt = @elapsed minpoly(polynomial_ring(ZZ, "x")[1], M)
println("$tt")
end

2 changes: 1 addition & 1 deletion benchmarks/solve_polynomials.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function benchmark_solve_poly()
print("benchmark_solve_poly ... ")
R, x = polynomial_ring(FlintZZ, "x")
R, x = polynomial_ring(ZZ, "x")
S, y = polynomial_ring(R, "y")
M = matrix_space(S, 20, 20)()

Expand Down
2 changes: 1 addition & 1 deletion docs/src/developer/parents.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ As all elements and parents in Nemo are objects, those objects have types
which we refer to as the element type and parent type respectively.

For example, Flint integers have type `ZZRingElem` and the parent object they all
belong to, `FlintZZ` has type `ZZRing`.
belong to, `ZZ` has type `ZZRing`.

More complex parents and elements are parameterised. For example, generic
univariate polynomials over a base ring `R` are parameterised by `R`. The
Expand Down
6 changes: 3 additions & 3 deletions docs/src/integer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ end
# Integers

The default integer type in Nemo is provided by Flint. The associated ring of
integers is represented by the constant parent object called `FlintZZ`.
integers is represented by the constant parent object called `ZZ`.

For convenience we define

```
ZZ = FlintZZ
ZZ = ZZ
```

so that integers can be constructed using `ZZ` instead of `FlintZZ`. Note that
so that integers can be constructed using `ZZ` instead of `ZZ`. Note that
this is the name of a specific parent object, not the name of its type.

The types of the integer ring parent objects and elements of the associated
Expand Down
2 changes: 1 addition & 1 deletion docs/src/qadic.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ m = prime(R)
n = valuation(b)
Qx, x = QQ["x"]
p = lift(Qx, a)
Zy, y = FlintZZ["y"]
Zy, y = ZZ["y"]
q = lift(Zy, divexact(a, b))
```

Expand Down
2 changes: 1 addition & 1 deletion src/HeckeMiscFiniteField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Base.eltype(::fqPolyRepField) = fqPolyRepFieldElem
# FqPolyRepField

function Base.iterate(F::FqPolyRepField)
return zero(F), zeros(FlintZZ, degree(F))
return zero(F), zeros(ZZ, degree(F))
end

function Base.iterate(F::FqPolyRepField, st::Vector{ZZRingElem})
Expand Down
2 changes: 1 addition & 1 deletion src/HeckeMiscInteger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ for sym in (:trunc, :round, :ceil, :floor)
# support `trunc(ZZRingElem, m)` etc. where m is a matrix of reals
function Base.$sym(::Type{ZZMatrix}, a::Matrix{<:Real})
s = Base.size(a)
m = zero_matrix(FlintZZ, s[1], s[2])
m = zero_matrix(ZZ, s[1], s[2])
for i = 1:s[1], j = 1:s[2]
m[i, j] = Base.$sym(ZZRingElem, a[i, j])
end
Expand Down
16 changes: 8 additions & 8 deletions src/HeckeMiscMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# This function is really slow...
function denominator(M::QQMatrix)
d = one(FlintZZ)
d = one(ZZ)
for i in 1:nrows(M)
for j in 1:ncols(M)
d = lcm!(d, d, denominator(M[i, j]))
Expand All @@ -18,7 +18,7 @@ end
transpose!(A::Union{ZZMatrix,QQMatrix}) = is_square(A) ? transpose!(A, A) : transpose(A)

function matrix(A::Matrix{ZZRingElem})
m = matrix(FlintZZ, A)
m = matrix(ZZ, A)
return m
end

Expand Down Expand Up @@ -137,7 +137,7 @@ end
It returns a lift of the matrix to the integers.
"""
function lift(a::Generic.Mat{EuclideanRingResidueRingElem{ZZRingElem}})
z = zero_matrix(FlintZZ, nrows(a), ncols(a))
z = zero_matrix(ZZ, nrows(a), ncols(a))
for i in 1:nrows(a)
for j in 1:ncols(a)
z[i, j] = lift(a[i, j])
Expand All @@ -147,7 +147,7 @@ function lift(a::Generic.Mat{EuclideanRingResidueRingElem{ZZRingElem}})
end

function lift(a::ZZModMatrix)
z = zero_matrix(FlintZZ, nrows(a), ncols(a))
z = zero_matrix(ZZ, nrows(a), ncols(a))
GC.@preserve a z begin
for i in 1:nrows(a)
for j in 1:ncols(a)
Expand All @@ -166,7 +166,7 @@ function lift(x::FpMatrix)
end

function lift(a::Generic.Mat{ZZModRingElem})
z = zero_matrix(FlintZZ, nrows(a), ncols(a))
z = zero_matrix(ZZ, nrows(a), ncols(a))
for i in 1:nrows(a)
for j in 1:ncols(a)
z[i, j] = lift(a[i, j])
Expand Down Expand Up @@ -227,7 +227,7 @@ mod_sym!(M::ZZMatrix, B::Integer) = mod_sym!(M, ZZRingElem(B))
Reduces every entry modulo $p$ into the symmetric residue system.
"""
function mod_sym(M::ZZMatrix, B::ZZRingElem)
N = zero_matrix(FlintZZ, nrows(M), ncols(M))
N = zero_matrix(ZZ, nrows(M), ncols(M))
ccall((:fmpz_mat_scalar_smod, libflint), Nothing, (Ref{ZZMatrix}, Ref{ZZMatrix}, Ref{ZZRingElem}), N, M, B)
return N
end
Expand Down Expand Up @@ -293,11 +293,11 @@ left and/ or right transformation matrices are computed as well.
"""
function snf_with_transform(A::ZZMatrix, l::Bool=true, r::Bool=true)
if r
R = identity_matrix(FlintZZ, ncols(A))
R = identity_matrix(ZZ, ncols(A))
end

if l
L = identity_matrix(FlintZZ, nrows(A))
L = identity_matrix(ZZ, nrows(A))
end
# TODO: if only one trafo is required, start with the HNF that does not
# compute the trafo
Expand Down
4 changes: 2 additions & 2 deletions src/HeckeMiscPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ end

function roots(R::T, f::QQPolyRingElem) where {T<:Union{fqPolyRepField,fpField}}
Rt, t = polynomial_ring(R, "t", cached=false)
fp = polynomial_ring(FlintZZ, cached=false)[1](f * denominator(f))
fp = polynomial_ring(ZZ, cached=false)[1](f * denominator(f))
fpp = Rt(fp)
return roots(fpp)
end
Expand Down Expand Up @@ -228,7 +228,7 @@ function is_power(a::Union{fpField, FpFieldElem, fqPolyRepFieldElem,FqPolyRepFie
end
s = order(parent(a))
if gcd(s - 1, m) == 1
return true, a^invmod(FlintZZ(m), s - 1)
return true, a^invmod(ZZ(m), s - 1)
end
St, t = polynomial_ring(parent(a), "t", cached=false)
f = t^m - a
Expand Down
10 changes: 5 additions & 5 deletions src/HeckeMoreStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ function roots(f::ZZModPolyRingElem, fac::Fac{ZZRingElem})
return _res
end

ZZMatrix(M::Matrix{Int}) = matrix(FlintZZ, M)
ZZMatrix(M::Matrix{Int}) = matrix(ZZ, M)

order(::ZZRingElem) = FlintZZ
order(::ZZRingElem) = ZZ

function sub!(z::Vector{QQFieldElem}, x::Vector{QQFieldElem}, y::Vector{ZZRingElem})
for i in 1:length(z)
Expand Down Expand Up @@ -186,7 +186,7 @@ function Base.round(::Type{ZZRingElem}, x::ArbFieldElem)
end

function Base.round(::Type{ZZMatrix}, C::ArbMatrix)
v = zero_matrix(FlintZZ, nrows(C), ncols(C))
v = zero_matrix(ZZ, nrows(C), ncols(C))

for i = 1:nrows(C)
for j = 1:ncols(C)
Expand Down Expand Up @@ -512,7 +512,7 @@ $b\in Z[t]$, $\deg(a) = \deg(b)$ and $d>0$ minimal in $Z$.
This function returns $b$.
"""
function numerator(a::AbsSimpleNumFieldElem)
_one = one(FlintZZ)
_one = one(ZZ)
z = deepcopy(a)
ccall((:nf_elem_set_den, libantic), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}),
Expand Down Expand Up @@ -1364,7 +1364,7 @@ function lift(M::fqPolyRepMatrix, R::zzModRing)
N = zero_matrix(R, nrows(M), ncols(M))
for i = 1:nrows(M)
for j = 1:ncols(M)
N[i, j] = FlintZZ(coeff(M[i, j], 0))
N[i, j] = ZZ(coeff(M[i, j], 0))
end
end
return N
Expand Down
2 changes: 1 addition & 1 deletion src/Nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ const _ecm_nCs = Vector{Int}[_ecm_nC]
#
###############################################################################

const ZZ = FlintZZ
const FlintZZ = ZZ
const FlintQQ = QQ
#const FiniteField = FlintFiniteField

Expand Down
4 changes: 2 additions & 2 deletions src/antic/nf_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ supplied, a default dollar sign will be used to represent the variable.
"""
function cyclotomic_field(n::Int, s::VarName = "z_$n", t = "_\$"; cached = true)
n > 0 || throw(ArgumentError("conductor must be positive, not $n"))
Zx, x = polynomial_ring(FlintZZ, gensym(); cached = false)
Zx, x = polynomial_ring(ZZ, gensym(); cached = false)
Qx, = polynomial_ring(QQ, t; cached = cached)
f = cyclotomic(n, x)
C, g = number_field(Qx(f), Symbol(s); cached = cached, check = false)
Expand Down Expand Up @@ -1237,7 +1237,7 @@ constructed, should be printed. If it is not supplied, a default dollar sign
will be used to represent the variable.
"""
function cyclotomic_real_subfield(n::Int, s::VarName = "(z_$n + 1/z_$n)", t = "\$"; cached = true)
Zx, x = polynomial_ring(FlintZZ, gensym(); cached = false)
Zx, x = polynomial_ring(ZZ, gensym(); cached = false)
Qx, = polynomial_ring(QQ, t; cached = cached)
f = cos_minpoly(n, x)
R, a = number_field(Qx(f), Symbol(s); cached = cached, check = false)
Expand Down
2 changes: 1 addition & 1 deletion src/arb/ComplexPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ contained in the (constant) polynomial $x$, along with that integer $z$
in case it is, otherwise sets $t$ to `false`.
"""
function unique_integer(x::ComplexPoly)
z = ZZPolyRing(FlintZZ, var(parent(x)))()
z = ZZPolyRing(ZZ, var(parent(x)))()
unique = ccall((:acb_poly_get_unique_fmpz_poly, libarb), Int,
(Ref{ZZPolyRingElem}, Ref{ComplexPoly}), z, x)
return (unique != 0, z)
Expand Down
2 changes: 1 addition & 1 deletion src/arb/RealPoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ contained in each of the coefficients of $x$, otherwise sets $t$ to `false`.
In the former case, $z$ is set to the integer polynomial.
"""
function unique_integer(x::RealPoly)
z = ZZPolyRing(FlintZZ, var(parent(x)))()
z = ZZPolyRing(ZZ, var(parent(x)))()
unique = ccall((:arb_poly_get_unique_fmpz_poly, libarb), Int,
(Ref{ZZPolyRingElem}, Ref{RealPoly}), z, x)
return (unique != 0, z)
Expand Down
2 changes: 1 addition & 1 deletion src/arb/acb_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ contained in the (constant) polynomial $x$, along with that integer $z$
in case it is, otherwise sets $t$ to `false`.
"""
function unique_integer(x::AcbPolyRingElem)
z = ZZPolyRing(FlintZZ, var(parent(x)))()
z = ZZPolyRing(ZZ, var(parent(x)))()
unique = ccall((:acb_poly_get_unique_fmpz_poly, libarb), Int,
(Ref{ZZPolyRingElem}, Ref{AcbPolyRingElem}), z, x)
return (unique != 0, z)
Expand Down
2 changes: 1 addition & 1 deletion src/arb/arb_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ contained in each of the coefficients of $x$, otherwise sets $t$ to `false`.
In the former case, $z$ is set to the integer polynomial.
"""
function unique_integer(x::ArbPolyRingElem)
z = ZZPolyRing(FlintZZ, var(parent(x)))()
z = ZZPolyRing(ZZ, var(parent(x)))()
unique = ccall((:arb_poly_get_unique_fmpz_poly, libarb), Int,
(Ref{ZZPolyRingElem}, Ref{ArbPolyRingElem}), z, x)
return (unique != 0, z)
Expand Down
2 changes: 1 addition & 1 deletion src/calcium/qqbar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ characteristic(::QQBarField) = 0

# todo: want a C function for this
function Base.hash(a::QQBarFieldElem, h::UInt)
R, x = polynomial_ring(FlintZZ, "x")
R, x = polynomial_ring(ZZ, "x")
return xor(hash(minpoly(R, a)), h)
end

Expand Down
2 changes: 1 addition & 1 deletion src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ julia> ZZ(2)^100
struct ZZRing <: Ring
end

const FlintZZ = ZZRing()
const ZZ = ZZRing()

integer_ring() = ZZRing()

Expand Down
2 changes: 1 addition & 1 deletion src/flint/fmpq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ parent_type(::Type{QQFieldElem}) = QQField

elem_type(::Type{QQField}) = QQFieldElem

base_ring(a::QQField) = FlintZZ
base_ring(a::QQField) = ZZ

is_domain_type(::Type{QQFieldElem}) = true

Expand Down
2 changes: 1 addition & 1 deletion src/flint/fmpq_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ end
################################################################################

function nullspace(A::QQMatrix)
AZZ = zero_matrix(FlintZZ, nrows(A), ncols(A))
AZZ = zero_matrix(ZZ, nrows(A), ncols(A))
ccall((:fmpq_mat_get_fmpz_mat_rowwise, libflint), Nothing,
(Ref{ZZMatrix}, Ptr{Nothing}, Ref{QQMatrix}), AZZ, C_NULL, A)
N = similar(AZZ, ncols(A), ncols(A))
Expand Down
2 changes: 1 addition & 1 deletion src/flint/fmpq_mpoly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ function (R::QQMPolyRing)(a::Vector{Any}, b::Vector{Vector{T}}) where T
n = nvars(R)
length(a) != length(b) && error("Coefficient and exponent vector must have the same length")
newa = map(QQ, a)
newb = map(x -> map(FlintZZ, x), b)
newb = map(x -> map(ZZ, x), b)
newaa = convert(Vector{QQFieldElem}, newa)
newbb = convert(Vector{Vector{ZZRingElem}}, newb)

Expand Down
Loading

0 comments on commit 54628fd

Please sign in to comment.