Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed May 3, 2024
1 parent bb349db commit b93b62c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 111 deletions.
4 changes: 2 additions & 2 deletions experimental/GModule/Cohomology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ function Oscar.direct_product(C::GModule...; task::Symbol = :none)
@assert all(x->x.G == G, C)
mM, pro, inj = direct_product([x.M for x = C]..., task = :both)

mC = gmodule(G, [direct_sum(mM, mM, [action(C[i], g) for i=1:length(C)]) for g = gens(G)])
mC.iac = [direct_sum(mM, mM, [action(C[i], inv(g)) for i=1:length(C)]) for g = gens(G)]
mC = gmodule(G, [hom(mM, mM, [action(C[i], g) for i=1:length(C)]) for g = gens(G)])
mC.iac = [hom(mM, mM, [action(C[i], inv(g)) for i=1:length(C)]) for g = gens(G)]

if task == :none
return mC
Expand Down
111 changes: 2 additions & 109 deletions experimental/GModule/Misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Misc
using Oscar
import Base: ==, parent

export coimage
export relative_field

Hecke.minpoly(a::QQBarFieldElem) = minpoly(Hecke.Globals.Qx, a)
Expand Down Expand Up @@ -194,11 +193,6 @@ end
## functions that will eventually get defined in Hecke.jl,
## and then should get removed here

function Hecke.roots(a::FinFieldElem, i::Int)
kx, x = polynomial_ring(parent(a), cached = false)
return roots(x^i-a)
end

function Oscar.dual(h::Map{FinGenAbGroup, FinGenAbGroup})
A = domain(h)
B = codomain(h)
Expand Down Expand Up @@ -254,12 +248,12 @@ Hecke.extend(::Hecke.QQEmb, mp::MapFromFunc{QQField, AbsSimpleNumField}) = compl
Hecke.restrict(::Hecke.NumFieldEmb, ::Map{QQField, AbsSimpleNumField}) = complex_embeddings(QQ)[1]

"""
direct_sum(G::FinGenAbGroup, H::FinGenAbGroup, V::Vector{<:Map{FinGenAbGroup, FinGenAbGroup}})
hom(G::FinGenAbGroup, H::FinGenAbGroup, V::Vector{<:Map{FinGenAbGroup, FinGenAbGroup}})
For groups `G = prod G_i` and `H = prod H_i` as well as maps `V_i: G_i -> H_i`,
build the induced map from `G -> H`.
"""
function Oscar.direct_sum(G::FinGenAbGroup, H::FinGenAbGroup, V::Vector{<:Map{FinGenAbGroup, FinGenAbGroup}})
function Oscar.hom(G::FinGenAbGroup, H::FinGenAbGroup, V::Vector{<:Map{FinGenAbGroup, FinGenAbGroup}})
dG = get_attribute(G, :direct_product)
dH = get_attribute(H, :direct_product)

Expand Down Expand Up @@ -407,113 +401,12 @@ end
## functions that will eventually get defined in AbstractAlgebra.jl,
## and then should get removed here

Base.pairs(M::MatElem) = Base.pairs(IndexCartesian(), M)
Base.pairs(::IndexCartesian, M::MatElem) = Base.Iterators.Pairs(M, CartesianIndices(axes(M)))

Oscar.matrix(phi::Generic.IdentityMap{<:AbstractAlgebra.FPModule}) = identity_matrix(base_ring(domain(phi)), dim(domain(phi)))

Oscar.gen(M::AbstractAlgebra.FPModule, i::Int) = M[i]

Oscar.is_free(M::Generic.FreeModule) = true
Oscar.is_free(M::Generic.DirectSumModule) = all(is_free, M.m)

function Base.iterate(M::AbstractAlgebra.FPModule{T}) where T <: FinFieldElem
k = base_ring(M)
if dim(M) == 0
return zero(M), iterate([1])
end
p = Base.Iterators.ProductIterator(Tuple([k for i=1:dim(M)]))
f = iterate(p)
return M(elem_type(k)[f[1][i] for i=1:dim(M)]), (f[2], p)
end

function Base.iterate(::AbstractAlgebra.FPModule{<:FinFieldElem}, ::Tuple{Int64, Int64})
return nothing
end

Oscar.issubset(M::AbstractAlgebra.FPModule{T}, N::AbstractAlgebra.FPModule{T}) where T<:RingElement = is_submodule(M, N)

function is_sub_with_data(M::AbstractAlgebra.FPModule{T}, N::AbstractAlgebra.FPModule{T}) where T<:RingElement
fl = is_submodule(N, M)
if fl
return fl, hom(M, N, elem_type(N)[N(m) for m = gens(M)])
else
return fl, hom(M, N, elem_type(N)[zero(N) for m = gens(M)])
end
end

function Oscar.hom(V::AbstractAlgebra.Module, W::AbstractAlgebra.Module, v::Vector{<:ModuleElem}; check::Bool = true)
if ngens(V) == 0
return Generic.ModuleHomomorphism(V, W, zero_matrix(base_ring(V), ngens(V), ngens(W)))
end
return Generic.ModuleHomomorphism(V, W, reduce(vcat, [x.v for x = v]))
end
function Oscar.hom(V::AbstractAlgebra.Module, W::AbstractAlgebra.Module, v::MatElem; check::Bool = true)
return Generic.ModuleHomomorphism(V, W, v)
end
function Oscar.inv(M::Generic.ModuleHomomorphism)
return hom(codomain(M), domain(M), inv(matrix(M)))
end

Oscar.is_finite(M::AbstractAlgebra.FPModule{<:FinFieldElem}) = true

function Oscar.order(F::AbstractAlgebra.FPModule{<:FinFieldElem})
return order(base_ring(F))^dim(F)
end

function Base.iterate(M::AbstractAlgebra.FPModule{T}, st::Tuple{<:Tuple, <:Base.Iterators.ProductIterator}) where T <: FinFieldElem
n = iterate(st[2], st[1])
if n === nothing
return n
end
return M(elem_type(base_ring(M))[n[1][i] for i=1:dim(M)]), (n[2], st[2])
end

function Base.length(M::AbstractAlgebra.FPModule{T}) where T <: FinFieldElem
return Int(order(M))
end

function Base.eltype(M::AbstractAlgebra.FPModule{T}) where T <: FinFieldElem
return elem_type(M)
end

function Oscar.dim(M::AbstractAlgebra.Generic.DirectSumModule{<:FieldElem})
return sum(dim(x) for x = M.m)
end

Base.:*(a::T, b::Generic.ModuleHomomorphism{T}) where {T} = hom(domain(b), codomain(b), a * matrix(b))
Base.:*(a::T, b::Generic.ModuleIsomorphism{T}) where {T} = hom(domain(b), codomain(b), a * matrix(b))
Base.:+(a::Generic.ModuleHomomorphism, b::Generic.ModuleHomomorphism) = hom(domain(a), codomain(a), matrix(a) + matrix(b))
Base.:-(a::Generic.ModuleHomomorphism, b::Generic.ModuleHomomorphism) = hom(domain(a), codomain(a), matrix(a) - matrix(b))
Base.:-(a::Generic.ModuleHomomorphism) = hom(domain(a), codomain(a), -matrix(a))

function Base.:(==)(a::Union{Generic.ModuleHomomorphism, Generic.ModuleIsomorphism}, b::Union{Generic.ModuleHomomorphism, Generic.ModuleIsomorphism})
domain(a) === domain(b) || return false
codomain(a) === codomain(b) || return false
return matrix(a) == matrix(b)
end

function Base.hash(a::Union{Generic.ModuleHomomorphism, Generic.ModuleIsomorphism}, h::UInt)
h = hash(domain(a), h)
h = hash(codomain(a), h)
h = hash(matrix(a), h)
return h
end

function Oscar.pseudo_inv(h::Generic.ModuleHomomorphism)
return MapFromFunc(codomain(h), domain(h), x->preimage(h, x))
end

function Oscar.direct_sum(M::AbstractAlgebra.Generic.DirectSumModule{T}, N::AbstractAlgebra.Generic.DirectSumModule{T}, mp::Vector{AbstractAlgebra.Generic.ModuleHomomorphism{T}}) where T
@assert length(M.m) == length(mp) == length(N.m)
return hom(M, N, cat(map(matrix, mp)..., dims = (1,2)))
end

function coimage(h::Map)
return quo(domain(h), kernel(h)[1])
end

end # module
using .Misc
export coimage
export relative_field

0 comments on commit b93b62c

Please sign in to comment.