From 81a49886c9d5d299875145f6fea630cd08b63ec5 Mon Sep 17 00:00:00 2001 From: Matthias Zach Date: Fri, 24 Nov 2023 20:38:18 +0100 Subject: [PATCH] Add some type stability to allow for zero morphisms. --- src/Modules/UngradedModules/DirectSum.jl | 4 ++-- src/Modules/UngradedModules/SubQuoHom.jl | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Modules/UngradedModules/DirectSum.jl b/src/Modules/UngradedModules/DirectSum.jl index 5e0fc7af9ce5..589218cd38d2 100644 --- a/src/Modules/UngradedModules/DirectSum.jl +++ b/src/Modules/UngradedModules/DirectSum.jl @@ -83,8 +83,8 @@ Additionally, return """ function direct_product(M::ModuleFP{T}...; task::Symbol = :prod) where T F, pro, mF = direct_product([ambient_free_module(x) for x = M]..., task = :both) - s, emb_sF = sub(F, vcat([[mF[i](y) for y = ambient_representatives_generators(M[i])] for i=1:length(M)]...), :both) - q::Vector{elem_type(F)} = vcat([[mF[i](y) for y = rels(M[i])] for i=1:length(M)]...) + s, emb_sF = sub(F, vcat([elem_type(F)[mF[i](y) for y = ambient_representatives_generators(M[i])] for i=1:length(M)]...), :both) + q::Vector{elem_type(F)} = vcat([elem_type(F)[mF[i](y) for y = rels(M[i])] for i=1:length(M)]...) pro_quo = nothing if length(q) != 0 s, pro_quo = quo(s, q, :both) diff --git a/src/Modules/UngradedModules/SubQuoHom.jl b/src/Modules/UngradedModules/SubQuoHom.jl index 14413585d037..a2412080eee9 100644 --- a/src/Modules/UngradedModules/SubQuoHom.jl +++ b/src/Modules/UngradedModules/SubQuoHom.jl @@ -919,43 +919,43 @@ end compose(h::ModuleFPHom, g::ModuleFPHom) = h*g --(h::ModuleFPHom{D, C, Nothing}) where {D, C} = hom(domain(h), codomain(h), [-h(x) for x in gens(domain(h))], check=false) --(h::ModuleFPHom{D, C, T}) where {D, C, T} = hom(domain(h), codomain(h), [-h(x) for x in gens(domain(h))], base_ring_map(h), check=false) +-(h::ModuleFPHom{D, C, Nothing}) where {D, C} = hom(domain(h), codomain(h), elem_type(codomain(h))[-h(x) for x in gens(domain(h))], check=false) +-(h::ModuleFPHom{D, C, T}) where {D, C, T} = hom(domain(h), codomain(h), elem_type(codomain(h))[-h(x) for x in gens(domain(h))], base_ring_map(h), check=false) function -(h::ModuleFPHom{D, C, T}, g::ModuleFPHom{D, C, T}) where {D, C, T} @assert domain(h) === domain(g) @assert codomain(h) === codomain(g) @assert base_ring_map(h) === base_ring_map(g) - return hom(domain(h), codomain(h), Vector{elem_type(codomain(h))}([h(x) - g(x) for x in gens(domain(h))]), base_ring_map(h), check=false) + return hom(domain(h), codomain(h), elem_type(codomain(h))[h(x) - g(x) for x in gens(domain(h))], base_ring_map(h), check=false) end function -(h::ModuleFPHom{D, C, Nothing}, g::ModuleFPHom{D, C, Nothing}) where {D, C} @assert domain(h) === domain(g) @assert codomain(h) === codomain(g) - return hom(domain(h), codomain(h), Vector{elem_type(codomain(h))}([h(x) - g(x) for x in gens(domain(h))]), check=false) + return hom(domain(h), codomain(h), elem_type(codomain(h))[h(x) - g(x) for x in gens(domain(h))], check=false) end function +(h::ModuleFPHom{D, C, T}, g::ModuleFPHom{D, C, T}) where {D, C, T} @assert domain(h) === domain(g) @assert codomain(h) === codomain(g) @assert base_ring_map(h) === base_ring_map(g) - return hom(domain(h), codomain(h), Vector{elem_type(codomain(h))}([h(x) + g(x) for x in gens(domain(h))]), base_ring_map(h), check=false) + return hom(domain(h), codomain(h), elem_type(codomain(h))[h(x) + g(x) for x in gens(domain(h))], base_ring_map(h), check=false) end function +(h::ModuleFPHom{D, C, Nothing}, g::ModuleFPHom{D, C, Nothing}) where {D, C} @assert domain(h) === domain(g) @assert codomain(h) === codomain(g) - return hom(domain(h), codomain(h), Vector{elem_type(codomain(h))}([h(x) + g(x) for x in gens(domain(h))]), check=false) + return hom(domain(h), codomain(h), elem_type(codomain(h))[h(x) + g(x) for x in gens(domain(h))], check=false) end function *(a::RingElem, g::ModuleFPHom{D, C, Nothing}) where {D, C} @assert base_ring(codomain(g)) === parent(a) - return hom(domain(g), codomain(g), Vector{elem_type(codomain(g))}([a*g(x) for x in gens(domain(g))]), check=false) + return hom(domain(g), codomain(g), elem_type(codomain(g))[a*g(x) for x in gens(domain(g))], check=false) end function *(a::RingElem, g::ModuleFPHom{D, C, T}) where {D, C, T} @assert base_ring(codomain(g)) === parent(a) - return hom(domain(g), codomain(g), Vector{elem_type(codomain(g))}([a*g(x) for x in gens(domain(g))]), base_ring_map(g), check=false) + return hom(domain(g), codomain(g), elem_type(codomain(g))[a*g(x) for x in gens(domain(g))], base_ring_map(g), check=false) end