From a1f5f0a24cd3560a36faaf216f3a9ecc594c9cfb Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Sat, 19 Jun 2021 00:47:30 +0200 Subject: [PATCH] add TrivialMStructure <: MultiplicativeStructure + API --- src/GroupRings.jl | 4 ++++ src/mstructures.jl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/mstructures.jl diff --git a/src/GroupRings.jl b/src/GroupRings.jl index ea6aa29..6f3ffaa 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -565,7 +565,11 @@ end module New + include("bases.jl") + +include("mstructures.jl") + end end # of module GroupRings diff --git a/src/mstructures.jl b/src/mstructures.jl new file mode 100644 index 0000000..2d4e13f --- /dev/null +++ b/src/mstructures.jl @@ -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