Skip to content

Commit

Permalink
fix: irreducibility of constant polynomials over finite fields
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Jan 9, 2025
1 parent fc77b13 commit 2fc39bc
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/flint/fmpz_mod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ end

function is_irreducible(x::ZZModPolyRingElem)
!is_probable_prime(modulus(x)) && error("Modulus not prime in is_irreducible")
is_constant(x) && return false
return Bool(@ccall libflint.fmpz_mod_poly_is_irreducible(x::Ref{ZZModPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint)
end

Expand Down
1 change: 1 addition & 0 deletions src/flint/fq_default_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ end
################################################################################

function is_irreducible(x::FqPolyRingElem)
is_constant(x) && return false
return Bool(@ccall libflint.fq_default_poly_is_irreducible(x::Ref{FqPolyRingElem}, base_ring(parent(x))::Ref{FqField})::Int32)
end

Expand Down
1 change: 1 addition & 0 deletions src/flint/fq_nmod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ end
################################################################################

function is_irreducible(x::fqPolyRepPolyRingElem)
is_constant(x) && return false
return Bool(@ccall libflint.fq_nmod_poly_is_irreducible(x::Ref{fqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{fqPolyRepField})::Int32)
end

Expand Down
1 change: 1 addition & 0 deletions src/flint/fq_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ end
################################################################################

function is_irreducible(x::FqPolyRepPolyRingElem)
is_constant(x) && return false
return Bool(@ccall libflint.fq_poly_is_irreducible(x::Ref{FqPolyRepPolyRingElem}, base_ring(parent(x))::Ref{FqPolyRepField})::Int32)
end

Expand Down
1 change: 1 addition & 0 deletions src/flint/gfp_fmpz_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ end
################################################################################

function is_irreducible(x::FpPolyRingElem)
is_constant(x) && return false
return Bool(@ccall libflint.fmpz_mod_poly_is_irreducible(x::Ref{FpPolyRingElem}, x.parent.base_ring.ninv::Ref{fmpz_mod_ctx_struct})::Cint)
end

Expand Down
1 change: 1 addition & 0 deletions src/flint/gfp_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ end
################################################################################

function is_irreducible(x::fpPolyRingElem)
is_constant(x) && return false
return Bool(@ccall libflint.nmod_poly_is_irreducible(x::Ref{fpPolyRingElem})::Int32)
end

Expand Down
1 change: 1 addition & 0 deletions src/flint/nmod_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ end

function is_irreducible(x::zzModPolyRingElem)
!is_prime(modulus(x)) && error("Modulus not prime in is_irreducible")
is_constant(x) && return false
return Bool(@ccall libflint.nmod_poly_is_irreducible(x::Ref{zzModPolyRingElem})::Int32)
end

Expand Down
3 changes: 3 additions & 0 deletions test/flint/fmpz_mod_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ end
f = x^2 + 2x + 1

@test is_irreducible(f) == false

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
end

@testset "ZZModPolyRingElem.is_squarefree" begin
Expand Down
3 changes: 3 additions & 0 deletions test/flint/fq_default_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ end
@test is_irreducible(x)

@test is_irreducible(x^16+2*x^9+x^8+x^2+x+1)

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
end

@testset "FqPolyRingElem.is_squarefree" begin
Expand Down
3 changes: 3 additions & 0 deletions test/flint/fq_nmod_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ end
@test is_irreducible(x)

@test is_irreducible(x^16+2*x^9+x^8+x^2+x+1)

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
end

@testset "fqPolyRepPolyRingElem.is_squarefree" begin
Expand Down
3 changes: 3 additions & 0 deletions test/flint/fq_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ end
@test is_irreducible(x)

@test is_irreducible(x^16+2*x^9+x^8+x^2+x+1)

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
end

@testset "FqPolyRepPolyRingElem.is_squarefree" begin
Expand Down
3 changes: 3 additions & 0 deletions test/flint/gfp_fmpz_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ end
f = x^2 + 2x + 1

@test is_irreducible(f) == false

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
end

@testset "FpPolyRingElem.is_squarefree" begin
Expand Down
3 changes: 3 additions & 0 deletions test/flint/gfp_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ end
@test is_irreducible(x)

@test is_irreducible(x^16+2*x^9+x^8+x^2+x+1)

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
end

@testset "fpPolyRingElem.is_squarefree" begin
Expand Down
3 changes: 3 additions & 0 deletions test/flint/nmod_poly-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ end
@test is_irreducible(x)

@test is_irreducible(x^16+2*x^9+x^8+x^2+x+1)

@test !is_irreducible(x^0)
@test !is_irreducible(0*x^0)
end

@testset "zzModPolyRingElem.is_squarefree" begin
Expand Down

0 comments on commit 2fc39bc

Please sign in to comment.