Skip to content

Commit

Permalink
Support for arbitrary ring morphisms with number field domains (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma authored Dec 15, 2023
1 parent 97bd536 commit 1a8328c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
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.23.2-DEV"
version = "0.23.2"

[deps]
AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
Expand Down
22 changes: 16 additions & 6 deletions src/Map/NumField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ end
function hom(K::S, L::T, x...; inverse = nothing,
check::Bool = true,
compute_inverse = false) where {S <: Union{NumField, QQField},
T <: NumField}
T <: Ring}
header = MapHeader(K, L)

#if length(x) == 0
Expand All @@ -166,7 +166,7 @@ function hom(K::S, L::T, x...; inverse = nothing,
typeof(inverse_data)}(header, image_data, inverse_data)

else
z = NumFieldMor{S, T, typeof(image_data), map_data_type(L, K)}()
z = NumFieldMor{S, T, typeof(image_data), map_data_type(L, K)}()
end

z.header = header
Expand Down Expand Up @@ -245,9 +245,9 @@ mutable struct MapDataFromAnticNumberField{T}
end

# Helper functions to create the type
map_data_type(K::AnticNumberField, L::Union{NumField, QQField}) = map_data_type(AnticNumberField, typeof(L))
map_data_type(K::AnticNumberField, L::Union{NumField, QQField, Ring}) = map_data_type(AnticNumberField, typeof(L))

map_data_type(::Type{AnticNumberField}, T::Type{S}) where {S <: Union{NumField, QQField}} = MapDataFromAnticNumberField{elem_type(T)}
map_data_type(::Type{AnticNumberField}, T::Type{S}) where {S <: Union{NumField, QQField, Ring}} = MapDataFromAnticNumberField{elem_type(T)}

# Test if data u, v specfiying a map K -> L define the same morphism
function _isequal(K, L, u::MapDataFromAnticNumberField{T},
Expand All @@ -272,7 +272,7 @@ end
#
map_data(K::AnticNumberField, L, ::Bool) = MapDataFromAnticNumberField{elem_type(L)}(true)

function map_data(K::AnticNumberField, L, x::NumFieldElem; check = true)
function map_data(K::AnticNumberField, L, x::RingElement; check = true)
if parent(x) === L
xx = x
else
Expand Down Expand Up @@ -322,7 +322,7 @@ function map_data_type(T::Type{<: NfRel}, L::Type{<:Any})
MapDataFromNfRel{elem_type(L), map_data_type(base_field_type(T), L)}
end

map_data_type(K::NfRel, L::NumField) = map_data_type(typeof(K), typeof(L))
map_data_type(K::NfRel, L::Ring) = map_data_type(typeof(K), typeof(L))

# Test if data u, v specfiying a map K -> L define the same morphism
function _isequal(K, L, u::MapDataFromNfRel{T, S}, v::MapDataFromNfRel{T, S}) where {T, S}
Expand Down Expand Up @@ -1030,6 +1030,16 @@ end

Base.hash(f::NumFieldMor, h::UInt) = hash(f.image_data, domain(f), codomain(f), h)

################################################################################
#
# Catch all for morphisms into arbitrary rings
#
################################################################################

map_data_type(::Type{<: Any}, x) = Nothing

map_data_type(R, x) = map_data_type(typeof(R), typeof(x))

################################################################################
#
# Restriction
Expand Down
15 changes: 15 additions & 0 deletions test/Map/NumField.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,19 @@
D = Dict(f => 1)
@test haskey(D, g)
end

# Maps into arbitrary rings
begin
K, a = quadratic_field(-1);
Kx, x = K["x"]
h = @inferred hom(K, Kx, Kx(a))
@test h(a + 1) == Kx(a + 1)

Qx, x = QQ["x"]
K, a = number_field([x - 1, x - 2])
QQy, y = polynomial_ring(QQ, 2)
@test_throws ErrorException hom(K, QQy, [0, 0])
h = @inferred hom(K, QQy, [1, 2])
@test h(a[1] + a[2]) == QQy(3)
end
end

2 comments on commit 1a8328c

@thofma
Copy link
Owner Author

@thofma thofma commented on 1a8328c Dec 15, 2023

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/97159

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.23.2 -m "<description of version>" 1a8328cbd1df17cdd65c45ab9ff3bb0d257a5470
git push origin v0.23.2

Please sign in to comment.