Skip to content

Commit

Permalink
Add some type stability to allow for zero morphisms.
Browse files Browse the repository at this point in the history
  • Loading branch information
HechtiDerLachs committed Nov 24, 2023
1 parent 9a1597f commit 81a4988
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Modules/UngradedModules/DirectSum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/Modules/UngradedModules/SubQuoHom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 81a4988

Please sign in to comment.