1
0
mirror of https://github.com/kalmarek/GroupRings.jl.git synced 2024-12-28 18:50:29 +01:00

add TrivialMStructure <: MultiplicativeStructure + API

This commit is contained in:
Marek Kaluba 2021-06-19 00:47:30 +02:00
parent e103059b23
commit a1f5f0a24c
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 36 additions and 0 deletions

View File

@ -565,7 +565,11 @@ end
module New
include("bases.jl")
include("mstructures.jl")
end
end # of module GroupRings

32
src/mstructures.jl Normal file
View File

@ -0,0 +1,32 @@
abstract type MultiplicativeStructure{Twisted,I} <: AbstractMatrix{I} end
_istwisted(::MultiplicativeStructure{T}) where {T} = T
_product(ms::MultiplicativeStructure, g, h) = _product(Val(_istwisted(ms)), g, h)
_product(::Val{false}, g, h) = g * h
_product(::Val{true}, g, h) = star(g) * h
# ms::MultiplicativeStructure should implement:
# * getindex(ms, i::Integer, j::Integer)
# * size(ms)
# additionally it may implement
# * basis(ms)
struct TrivialMStructure{Tw,I,B<:AbstractBasis} <: MultiplicativeStructure{Tw,I}
basis::B
end
TrivialMStructure{Tw}(basis::AbstractBasis{T,I}) where {Tw,T,I} =
TrivialMStructure{Tw,I,typeof(basis)}(basis)
basis(mstr::TrivialMStructure) = mstr.basis
Base.size(mstr::TrivialMStructure) = (l = length(basis(mstr)); (l, l))
Base.@propagate_inbounds function Base.getindex(mstr::TrivialMStructure, i::Integer, j::Integer)
@boundscheck checkbounds(mstr, i, j)
b = basis(mstr)
g, h = b[i], b[j]
gh = _product(mstr, g, h)
return b[gh]
end