Skip to content

Commit

Permalink
Fix some conformance issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Oct 18, 2024
1 parent 875f94f commit c2d3375
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
10 changes: 7 additions & 3 deletions src/flint/fmpz_mod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,14 @@ end
################################################################################

function invmod(x::T, y::T) where {T <: Zmodn_fmpz_poly}
length(y) == 0 && error("Second argument must not be 0")
check_parent(x, y)
is_zero(y) && error("Second argument must not be 0")
check_parent(x,y)
if length(y) == 1
return parent(x)(inv(evaluate(x, coeff(y, 0))))
t = evaluate(x, coeff(y, 0))
if !is_zero(t)
t = inv!(t)
end
return parent(x)(t)
end
z = parent(x)()
r = ccall((:fmpz_mod_poly_invmod, libflint), Cint,
Expand Down
10 changes: 9 additions & 1 deletion src/flint/gfp_fmpz_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,15 @@ end

function gcdinv(x::FpPolyRingElem, y::FpPolyRingElem)
check_parent(x,y)
length(y) >= 2 || error("Length of second argument must be >= 2")
if is_zero(x)
is_zero(y) && return y, x
ly = leading_coefficient(y)
if !is_one(ly)
y = divexact(y,ly)
end
return y, x
end
length(y) <= 1 && return gcdx(x, y)[1:2]
g = parent(x)()
s = parent(x)()
ccall((:fmpz_mod_poly_gcdinv, libflint), Nothing,
Expand Down
10 changes: 9 additions & 1 deletion src/flint/gfp_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,15 @@ end

function gcdinv(x::fpPolyRingElem, y::fpPolyRingElem)
check_parent(x,y)
length(y) <= 1 && error("Length of second argument must be >= 2")
if is_zero(x)
is_zero(y) && return y, x
ly = leading_coefficient(y)
if !is_one(ly)
y = divexact(y,ly)
end
return y, x
end
length(y) <= 1 && return gcdx(x, y)[1:2]
g = parent(x)()
s = parent(x)()
ccall((:nmod_poly_gcdinv, libflint), Nothing,
Expand Down
8 changes: 6 additions & 2 deletions src/flint/nmod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,14 @@ end
################################################################################

function invmod(x::T, y::T) where T <: Zmodn_poly
length(y) == 0 && error("Second argument must not be 0")
is_zero(y) && error("Second argument must not be 0")
check_parent(x,y)
if length(y) == 1
return parent(x)(inv(evaluate(x, coeff(y, 0))))
t = evaluate(x, coeff(y, 0))
if !is_zero(t)
t = inv!(t)
end
return parent(x)(t)
end
z = parent(x)()
r = ccall((:nmod_poly_invmod, libflint), Int32,
Expand Down
4 changes: 1 addition & 3 deletions test/flint/gfp-test.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@testset "gfp.conformance_tests" begin
# TODO: make this work with test_Field_interface_recursive
for p in [13, next_prime(2^8), next_prime(2^16), next_prime(2^32)]
test_Field_interface(Native.GF(p))
#test_Field_interface_recursive(Native.GF(p))
test_Field_interface_recursive(Native.GF(p))
end
end

Expand Down
4 changes: 1 addition & 3 deletions test/flint/gfp_fmpz-test.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@testset "gfp_fmpz.conformance_tests" begin
# TODO: make this work with test_Field_interface_recursive
for p in [13, next_prime(2^8), next_prime(2^16), next_prime(2^32)]
test_Field_interface(Native.GF(ZZ(p)))
#test_Field_interface_recursive(Native.GF(ZZ(p)))
test_Field_interface_recursive(Native.GF(ZZ(p)))
end
end

Expand Down

0 comments on commit c2d3375

Please sign in to comment.