Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently use ZZ/QQ instead of mix of ZZ/QQ and FlintZZ/FlintQQ #1718

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/bernoulli_polynomials.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function benchmark_bernoulli()
print("benchmark_bernoulli ... ")

R, x = FlintQQ["x"]
R, x = QQ["x"]
S, t = power_series_ring(R, 1000, "t")

u = t + O(t^1000)
Expand Down
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_field.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function benchmark_nf_det()
print("benchmark_nf_det ... ")
QQx, x = polynomial_ring(FlintQQ, "x")
QQx, x = polynomial_ring(QQ, "x")
K, a = AbsSimpleNumField(x^3 + 3*x + 1, "a")
M = matrix_space(K, 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
2 changes: 1 addition & 1 deletion benchmarks/minpoly_finite_field.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function benchmark_minpoly_finite_field()
print("benchmark_minpoly_finite_field ... ")

F, s = FlintFiniteField(103, 2, "s")
F, s = finite_field(103, 2, "s")

M = matrix_space(F, 80, 80)()

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
4 changes: 2 additions & 2 deletions docs/src/qadic.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ c = R(2)
k = precision(a)
m = prime(R)
n = valuation(b)
Qx, x = FlintQQ["x"]
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)

Check warning on line 9 in src/HeckeMiscMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscMatrix.jl#L9

Added line #L9 was not covered by tests
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 @@
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)

Check warning on line 21 in src/HeckeMiscMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscMatrix.jl#L21

Added line #L21 was not covered by tests
return m
end

Expand Down Expand Up @@ -137,7 +137,7 @@
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))

Check warning on line 140 in src/HeckeMiscMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscMatrix.jl#L140

Added line #L140 was not covered by tests
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 @@
end

function lift(a::ZZModMatrix)
z = zero_matrix(FlintZZ, nrows(a), ncols(a))
z = zero_matrix(ZZ, nrows(a), ncols(a))

Check warning on line 150 in src/HeckeMiscMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscMatrix.jl#L150

Added line #L150 was not covered by tests
GC.@preserve a z begin
for i in 1:nrows(a)
for j in 1:ncols(a)
Expand All @@ -166,7 +166,7 @@
end

function lift(a::Generic.Mat{ZZModRingElem})
z = zero_matrix(FlintZZ, nrows(a), ncols(a))
z = zero_matrix(ZZ, nrows(a), ncols(a))

Check warning on line 169 in src/HeckeMiscMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscMatrix.jl#L169

Added line #L169 was not covered by tests
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 @@
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))

Check warning on line 230 in src/HeckeMiscMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscMatrix.jl#L230

Added line #L230 was not covered by tests
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 @@
"""
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 @@

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))

Check warning on line 198 in src/HeckeMiscPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscPoly.jl#L198

Added line #L198 was not covered by tests
fpp = Rt(fp)
return roots(fpp)
end
Expand Down Expand Up @@ -228,7 +228,7 @@
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)

Check warning on line 231 in src/HeckeMiscPoly.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMiscPoly.jl#L231

Added line #L231 was not covered by tests
end
St, t = polynomial_ring(parent(a), "t", cached=false)
f = t^m - a
Expand Down
18 changes: 9 additions & 9 deletions src/HeckeMoreStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
end

function QQMatrix(x::ZZMatrix)
z = zero_matrix(FlintQQ, nrows(x), ncols(x))
z = zero_matrix(QQ, nrows(x), ncols(x))

Check warning on line 6 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L6

Added line #L6 was not covered by tests
ccall((:fmpq_mat_set_fmpz_mat, libflint), Nothing, (Ref{QQMatrix}, Ref{ZZMatrix}), z, x)
return z
end
Expand Down Expand Up @@ -134,9 +134,9 @@
return _res
end

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

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

Check warning on line 139 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L139

Added line #L139 was not covered by tests

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 @@
end

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

Check warning on line 189 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L189

Added line #L189 was not covered by tests

for i = 1:nrows(C)
for j = 1:ncols(C)
Expand All @@ -206,7 +206,7 @@

norm(x::ZZRingElem) = abs(x)

number_field(::ZZRing) = FlintQQ
number_field(::ZZRing) = QQ

Check warning on line 209 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L209

Added line #L209 was not covered by tests

function Base.hash(f::zzModMPolyRingElem, h::UInt)
return UInt(1) # TODO: enhance or throw error
Expand Down Expand Up @@ -371,7 +371,7 @@
return d
end

base_field(_::AbsSimpleNumField) = FlintQQ
base_field(_::AbsSimpleNumField) = QQ

Check warning on line 374 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L374

Added line #L374 was not covered by tests

################################################################################
#
Expand Down Expand Up @@ -512,7 +512,7 @@
This function returns $b$.
"""
function numerator(a::AbsSimpleNumFieldElem)
_one = one(FlintZZ)
_one = one(ZZ)

Check warning on line 515 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L515

Added line #L515 was not covered by tests
z = deepcopy(a)
ccall((:nf_elem_set_den, libantic), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{ZZRingElem}, Ref{AbsSimpleNumField}),
Expand Down Expand Up @@ -1364,7 +1364,7 @@
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))

Check warning on line 1367 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L1367

Added line #L1367 was not covered by tests
end
end
return N
Expand Down Expand Up @@ -1479,7 +1479,7 @@
Base.replace!(::typeof(-), m::ZZMatrix) = -m

function (A::AbsSimpleNumField)(a::ZZPolyRingElem)
return A(FlintQQ["x"][1](a))
return A(QQ["x"][1](a))

Check warning on line 1482 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L1482

Added line #L1482 was not covered by tests
end


Expand Down
7 changes: 3 additions & 4 deletions src/Nemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,12 @@ const _ecm_nCs = Vector{Int}[_ecm_nC]

###############################################################################
#
# Set domain for ZZ, QQ, PadicField, finite_field to Flint
# Set domain for ZZ, QQ to Flint
#
###############################################################################

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

###############################################################################
#
Expand Down
8 changes: 4 additions & 4 deletions src/antic/nf_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1202,8 +1202,8 @@ 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)
Qx, = polynomial_ring(FlintQQ, t; cached = cached)
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)
set_attribute!(C, :show => show_cyclo, :cyclo => n)
Expand Down Expand Up @@ -1237,8 +1237,8 @@ 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)
Qx, = polynomial_ring(FlintQQ, t; cached = cached)
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)
set_attribute!(R, :show => show_maxreal, :maxreal => n)
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
Loading
Loading