Skip to content

Commit

Permalink
feat: add roots/factor for embedded field polys (#1347)
Browse files Browse the repository at this point in the history
Just foward the methods to the underlying number field.
  • Loading branch information
thofma authored Jan 10, 2024
1 parent 961afd7 commit b3420ea
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Hecke"
uuid = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
version = "0.24.0"
version = "0.24.1"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
22 changes: 22 additions & 0 deletions src/NumField/Embedded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,25 @@ end
function is_rational(x::EmbeddedElem)
return is_rational(data(x))
end

################################################################################
#
# Factorization and roots
#
################################################################################

function roots(f::PolyRingElem{<:EmbeddedElem})
E = base_ring(parent(f))
K = number_field(E)
return E.(roots(map_coefficients(data, f, cached = false)))
end

function factor(f::PolyRingElem{<:EmbeddedElem})
Ex = parent(f)
E = base_ring(parent(f))
K = number_field(E)
fa = factor(map_coefficients(data, f, cached = false))
return Fac(Ex(E(constant_coefficient(unit(fa)))),
Dict{typeof(f), Int}(
(map_coefficients(E, g, parent = Ex), e) for (g, e) in fa))
end
14 changes: 14 additions & 0 deletions test/NumField/Embedded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,19 @@ test_elem(E::Hecke.EmbeddedField) = E(rand(number_field(E), -10:10))
@test @inferred is_rational(a^0)
@test !is_rational(a)
@test (@inferred QQ(2*a^0)) == 2 * one(QQ)

# roots and factor
begin
Qx, x = QQ["x"]
K, _a = number_field(x^2 - 2, "a")
i = Hecke.real_embedding(K, 1.41)
E, a = Hecke.embedded_field(K, i)
Et, t = E["t"]
@test issetequal(roots(t^2 - 2), [a, -a])
fa = factor(t^2 - 2)
@test unit(fa) * prod(g^e for (g, e) in fa) == t^2 - 2
fa = factor(t^2 - a)
@test unit(fa) * prod(g^e for (g, e) in fa) == t^2 - a
end
end

2 comments on commit b3420ea

@thofma
Copy link
Owner Author

@thofma thofma commented on b3420ea Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/98677

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.24.1 -m "<description of version>" b3420eab2983e781e6ebe4bb6cec957e03c54e7d
git push origin v0.24.1

Please sign in to comment.