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

Implement is_squarefree for QQ/ZZPolyRingElem #1742

Open
wants to merge 1 commit 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
18 changes: 18 additions & 0 deletions src/flint/fmpq_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,29 @@ for (factor_fn, factor_fn_inner, flint_fn) in
end)
end

################################################################################
#
# Irreducibility
#
################################################################################

function is_irreducible(x::QQPolyRingElem)
res, _ = _factor(x)
return length(res) == 1 && first(values(res)) == 1
end

################################################################################
#
# Squarefree testing
#
################################################################################

function is_squarefree(x::QQPolyRingElem)
iszero(x) && return false
return Bool(ccall((:fmpq_poly_is_squarefree, libflint), Int32,
(Ref{QQPolyRingElem}, ), x))
end

###############################################################################
#
# Signature
Expand Down
18 changes: 18 additions & 0 deletions src/flint/fmpz_poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,12 @@ for (factor_fn, factor_fn_inner, flint_fn) in
end)
end

################################################################################
#
# Irreducibility
#
################################################################################

function is_irreducible(x::ZZPolyRingElem)
if degree(x) == 0
return is_prime(coeff(x, 0))
Expand All @@ -738,6 +744,18 @@ function is_irreducible(x::ZZPolyRingElem)
end
end

################################################################################
#
# Squarefree testing
#
################################################################################

function is_squarefree(x::ZZPolyRingElem)
iszero(x) && return false
return Bool(ccall((:fmpz_poly_is_squarefree, libflint), Int32,
(Ref{ZZPolyRingElem}, ), x))
end

###############################################################################
#
# Special polynomials
Expand Down
Loading