From e7a4fe01a5c690b6a8883db93d3112c39f799eee Mon Sep 17 00:00:00 2001 From: Claus Fieker Date: Thu, 22 Feb 2024 09:36:02 +0100 Subject: [PATCH] add most of the direct_sum new stuff --- src/AbstractAlgebra.jl | 19 +++++++++++++++++++ src/fundamental_interface.jl | 29 +++++++++++++++++++++++++++++ src/generic/DirectSum.jl | 24 ++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/src/AbstractAlgebra.jl b/src/AbstractAlgebra.jl index c267e98bc4..8430b7e062 100644 --- a/src/AbstractAlgebra.jl +++ b/src/AbstractAlgebra.jl @@ -735,6 +735,10 @@ export cached export can_solve export can_solve_with_solution export can_solve_with_solution_and_kernel +export canonical_injection +export canonical_injections +export canonical_projection +export canonical_projections export canonical_unit export change_base_ring export change_coefficient_ring @@ -851,6 +855,7 @@ export hnf_minors_with_transform export hnf_via_popov export hnf_via_popov_with_transform export hnf_with_transform +export hom export hooklength export ideal export identity_map @@ -1162,6 +1167,12 @@ function YoungTableau(part::Generic.Partition, fill::Vector{T}=collect(1:part.n) Generic.YoungTableau(part, fill) end +################################################################################ +# +# generic stubs for sub, quo, ... +# +################################################################################ + @doc raw""" sub(m::Module{T}, subs::Vector{<:Generic.Submodule{T}}) where T <: RingElement @@ -1177,6 +1188,14 @@ function sub(m::Module{T}, subs::Vector{<:Generic.Submodule{U}}) where {T <: Rin Generic.sub(m, subs) end +function canonical_injections(D) + return [canonical_injection(D, i) for i=1:_number_of_direct_product_factors(D)] +end + +function canonical_projections(D) + return [canonical_projections(D, i) for i=1:_number_of_direct_product_factors(D)] +end + export Generic ############################################################################### diff --git a/src/fundamental_interface.jl b/src/fundamental_interface.jl index 9412ed9833..2b107319fd 100644 --- a/src/fundamental_interface.jl +++ b/src/fundamental_interface.jl @@ -304,3 +304,32 @@ function sub! end Return `b*c`, possibly modifying the object `a` in the process. """ function mul! end + +@doc raw""" + canonical_injection(D, i) + +Return the i-th canonical injection into the direct sum or product objects `D`. +""" +function canonical_injection end + +@doc raw""" + canonical_projection(D, i) + +Return the i-th canonical projection into the direct sum or product objects `D`. +""" +function canonical_projection end + +@doc raw""" + _number_of_direct_product_factors(D) + +Return the number of factors/ summands in the direct product/ sum object `D` +""" +function _number_of_direct_product_factors end + +@doc raw""" + hom(D, C, data) + +Return the homomorphism from the domain `D` into the codomain `C` defined by the data. +""" +function hom end + diff --git a/src/generic/DirectSum.jl b/src/generic/DirectSum.jl index 67cd59dc4a..cd4493e8aa 100644 --- a/src/generic/DirectSum.jl +++ b/src/generic/DirectSum.jl @@ -152,6 +152,13 @@ function direct_sum_injection(i::Int, D::DirectSumModule{T}, v::AbstractAlgebra. return DirectSumModuleElem{T}(D, matv) end +function AbstractAlgebra.canonical_injection(A::DirectSumModule, i::Int) + B = summands(A)[i] + return hom(B, A, [direct_sum_injection(i, A, x) for x = gens(B)]) +end + +AbstractAlgebra._number_of_direct_product_factors(A::DirectSumModule) = length(summands(A)) + function direct_sum_projection(D::DirectSumModule{T}, i::Int, v::AbstractAlgebra.FPModuleElem{T}) where {T <: RingElement} # Find starting point of the given module in the large vectors S = summands(D) @@ -164,6 +171,10 @@ function direct_sum_projection(D::DirectSumModule{T}, i::Int, v::AbstractAlgebra return elem_type(m)(m, matv) end +function AbstractAlgebra.canonical_projection(A::DirectSumModule, i::Int) + return hom(A, summands(A)[i], [direct_sum_projection(A, i, x) for x = gens(A)]) +end + function direct_sum(m::Vector{<:AbstractAlgebra.FPModule{T}}) where T <: RingElement length(m) == 0 && error("Cannot take a direct sum of an empty vector of modules") # Check base rings are the same @@ -239,3 +250,16 @@ function ModuleHomomorphism(D::DirectSumModule{T}, A::DirectSumModule{T}, m::Mat return ModuleHomomorphism(D, A, transpose(hvcat(Tuple([length(SD) for i = 1:length(SA)]), map(x->transpose(x.matrix), m)...))) end + +function AbstractAlgebra.hom(A::AbstractAlgebra.Generic.DirectSumModule{T}, B::AbstractAlgebra.Generic.DirectSumModule{T}, M::Matrix{<:Map{<:AbstractAlgebra.FPModule{T}, <:AbstractAlgebra.FPModule{T}}}) where {T} + pro = canonical_projections(A) + im = canonical_injections(B) + s = hom(A, B, [zero(B) for i = 1:dim(A)]) + for i=1:length(pro) + for j=1:length(im) + s += pro[i]*M[i,j]*im[j] + end + end + return s +end +