Skip to content

Commit

Permalink
Merge branch 'Nemocas:master' into JAA/is_nilpotent
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnAAbbott authored Jan 8, 2025
2 parents baa6317 + fc77b13 commit 522970d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/HeckeMoreStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ end
function invmod(f::ZZModPolyRingElem, M::ZZModPolyRingElem)
if !is_unit(f)
r = parent(f)()
i = @ccall libflint.fmpz_mod_poly_invmod(r::Ref{ZZModPolyRingElem}, f::Ref{ZZModPolyRingElem}, M::Ref{ZZModPolyRingElem}, f.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Int
ff = ZZ()
i = @ccall libflint.fmpz_mod_poly_invmod_f(ff::Ref{ZZRingElem}, r::Ref{ZZModPolyRingElem}, f::Ref{ZZModPolyRingElem}, M::Ref{ZZModPolyRingElem}, f.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Int
if iszero(i)
error("not yet implemented")
else
Expand Down
11 changes: 7 additions & 4 deletions src/flint/gfp_fmpz_elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,13 @@ end

function mul!(z::FpFieldElem, x::FpFieldElem, y::ZZRingElem)
R = parent(x)
@ccall libflint.fmpz_mod(z.data::Ref{ZZRingElem}, y::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing

@ccall libflint.fmpz_mod_mul(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, z.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing
return z
if z !== x
@ccall libflint.fmpz_mod(z.data::Ref{ZZRingElem}, y::Ref{ZZRingElem}, R.n::Ref{ZZRingElem})::Nothing
@ccall libflint.fmpz_mod_mul(z.data::Ref{ZZRingElem}, x.data::Ref{ZZRingElem}, z.data::Ref{ZZRingElem}, R.ninv::Ref{fmpz_mod_ctx_struct})::Nothing
return z
else
return mul!(z, x, R(y))
end
end

function add!(z::FpFieldElem, x::FpFieldElem, y::FpFieldElem)
Expand Down
6 changes: 6 additions & 0 deletions test/flint/fmpz_mod_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@ end
@test powermod(f, -10, g) == 78305338116088931412*x+91239060941924718463

@test powermod(f, -ZZRingElem(10), g) == 78305338116088931412*x+91239060941924718463

R, = residue_ring(ZZ, ZZ(2809))
Rx, x = R[:x]
f = 32*x^9 + 28*x^8 + 2497*x^7 + 2443*x^6 + 708*x^5 + 996*x^4 + 2557*x^3 + 2104*x^2 + 2517*x + 2752
g = x^10 + 2798*x^8 + 2806*x^7 + 37*x^6 + 14*x^5 + 2761*x^4 + 2787*x^3 + 20*x^2 + 12*x + 1
@test_throws ErrorException invmod(f, g)
end

@testset "ZZModPolyRingElem.euclidean_division" begin
Expand Down
7 changes: 7 additions & 0 deletions test/flint/gfp_fmpz-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,10 @@ end
R = Native.GF(ZZ(19))
@test R([5]) == R(5)
end

@testset "gfp_fmpz.bug" begin
R = Native.GF(ZZRingElem(123456789012345678949))
z = R(1)
mul!(z, z, ZZ(10))
@test z == 10
end

0 comments on commit 522970d

Please sign in to comment.