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

Misc changes #1878

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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: 2 additions & 0 deletions src/HeckeMoreStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@
ccall((:nf_elem_sub, libflint), Nothing,
(Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumFieldElem}, Ref{AbsSimpleNumField}),
a, b, c, a.parent)
return a

Check warning on line 354 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L354

Added line #L354 was not covered by tests
end

function lift(R::ZZAbsPowerSeriesRing, f::ZZModAbsPowerSeriesRingElem)
Expand Down Expand Up @@ -1053,6 +1054,7 @@
for i = 0:degree(f)
setcoeff!(f, i, mod_sym(coeff(f, i), p))
end
return f

Check warning on line 1057 in src/HeckeMoreStuff.jl

View check run for this annotation

Codecov / codecov/patch

src/HeckeMoreStuff.jl#L1057

Added line #L1057 was not covered by tests
end

function mod_sym(a::AbsSimpleNumFieldElem, b::ZZRingElem, b2::ZZRingElem)
Expand Down
9 changes: 2 additions & 7 deletions src/flint/FlintTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -754,13 +754,8 @@ mutable struct fpPolyRingElem <: PolyRingElem{fpFieldElem}
return z
end

function fpPolyRingElem(n::UInt, a::Int)
z = new()
ccall((:nmod_poly_init, libflint), Nothing, (Ref{fpPolyRingElem}, UInt), z, n)
ccall((:nmod_poly_set_coeff_ui, libflint), Nothing,
(Ref{fpPolyRingElem}, Int, UInt), z, 0, mod(a, n))
finalizer(_gfp_poly_clear_fn, z)
return z
function fpPolyRingElem(n::UInt, a::Integer)
return fpPolyRingElem(n, mod(a, n) % UInt)
end

function fpPolyRingElem(n::UInt, arr::Vector{ZZRingElem})
Expand Down
10 changes: 10 additions & 0 deletions src/flint/fmpq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,16 @@
return cmp(a, b) < 0
end

function Base.isapprox(x::QQFieldElem, y::QQFieldElem;

Check warning on line 372 in src/flint/fmpq.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpq.jl#L372

Added line #L372 was not covered by tests
atol::Real=0, rtol::Real=0,
nans::Bool=false, norm::Function=abs)
if norm === abs && atol < 1 && rtol == 0
return x == y

Check warning on line 376 in src/flint/fmpq.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpq.jl#L375-L376

Added lines #L375 - L376 were not covered by tests
else
return norm(x - y) <= max(atol, rtol*max(norm(x), norm(y)))

Check warning on line 378 in src/flint/fmpq.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpq.jl#L378

Added line #L378 was not covered by tests
end
end

###############################################################################
#
# Ad hoc comparison
Expand Down
19 changes: 10 additions & 9 deletions src/flint/fmpz.jl
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,16 @@

isless(x::Integer, y::ZZRingElem) = ZZRingElem(x) < y

function Base.isapprox(x::ZZRingElem, y::ZZRingElem;

Check warning on line 863 in src/flint/fmpz.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpz.jl#L863

Added line #L863 was not covered by tests
atol::Real=0, rtol::Real=0,
nans::Bool=false, norm::Function=abs)
if norm === abs && atol < 1 && rtol == 0
return x == y

Check warning on line 867 in src/flint/fmpz.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpz.jl#L866-L867

Added lines #L866 - L867 were not covered by tests
else
return norm(x - y) <= max(atol, rtol*max(norm(x), norm(y)))

Check warning on line 869 in src/flint/fmpz.jl

View check run for this annotation

Codecov / codecov/patch

src/flint/fmpz.jl#L869

Added line #L869 was not covered by tests
end
end

###############################################################################
#
# Ad hoc comparison
Expand Down Expand Up @@ -1425,15 +1435,6 @@
return d, x, y
end

@doc raw"""
gcdinv(a::ZZRingElem, b::ZZRingElem)

Return a tuple $g, s$ where $g$ is the greatest common divisor of $a$ and
$b$ and where $s$ is the inverse of $a$ modulo $b$ if $g = 1$. This function
can be used to detect impossible inverses, i.e. where $a$ and $b$ are not
coprime, and to yield the common factor of $a$ and $b$ if they are not
coprime. We require $b \geq a \geq 0$.
"""
function gcdinv(a::ZZRingElem, b::ZZRingElem)
a < 0 && throw(DomainError(a, "First argument must be non-negative"))
b < a && throw(DomainError((a, b), "First argument must be smaller than second argument"))
Expand Down
11 changes: 0 additions & 11 deletions src/flint/fq_default_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -509,17 +509,6 @@ function gcd(x::FqPolyRingElem, y::FqPolyRingElem)
return z
end

function gcdinv(x::FqPolyRingElem, y::FqPolyRingElem)
check_parent(x,y)
z = parent(x)()
s = parent(x)()
t = parent(x)()
ccall((:fq_default_poly_xgcd, libflint), Nothing,
(Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem}, Ref{FqPolyRingElem},
Ref{FqField}), z, s, t, x, y, base_ring(parent(x)))
return z, s
end

function gcdx(x::FqPolyRingElem, y::FqPolyRingElem)
check_parent(x,y)
z = parent(x)()
Expand Down
12 changes: 0 additions & 12 deletions src/flint/fq_nmod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,6 @@ function gcd(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem)
return z
end

function gcdinv(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem)
check_parent(x,y)
z = parent(x)()
s = parent(x)()
t = parent(x)()
ccall((:fq_nmod_poly_xgcd, libflint), Nothing,
(Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem},
Ref{fqPolyRepPolyRingElem}, Ref{fqPolyRepPolyRingElem},
Ref{fqPolyRepField}), z, s, t, x, y, base_ring(parent(x)))
return z, s
end

function gcdx(x::fqPolyRepPolyRingElem, y::fqPolyRepPolyRingElem)
check_parent(x,y)
z = parent(x)()
Expand Down
11 changes: 0 additions & 11 deletions src/flint/fq_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -515,17 +515,6 @@ function gcd(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem)
return z
end

function gcdinv(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem)
check_parent(x,y)
z = parent(x)()
s = parent(x)()
t = parent(x)()
ccall((:fq_poly_xgcd, libflint), Nothing,
(Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem}, Ref{FqPolyRepPolyRingElem},
Ref{FqPolyRepField}), z, s, t, x, y, base_ring(parent(x)))
return z, s
end

function gcdx(x::FqPolyRepPolyRingElem, y::FqPolyRepPolyRingElem)
check_parent(x,y)
z = parent(x)()
Expand Down
5 changes: 0 additions & 5 deletions src/gaussiannumbers/ZZi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,6 @@ function invmod(a::ZZiRingElem, b::ZZiRingElem)
return x
end

function gcdinv(a::ZZiRingElem, b::ZZiRingElem)
g, x, y = gcdx(a, b)
return (g, x)
end

function remove(a::ZZiRingElem, b::ZZiRingElem)
if (iszero(b) || is_unit(b))
throw(ArgumentError("Second argument must be a non-zero non-unit"))
Expand Down
Loading