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:
parent
e103059b23
commit
a1f5f0a24c
@ -565,7 +565,11 @@ end
|
||||
|
||||
|
||||
module New
|
||||
|
||||
include("bases.jl")
|
||||
|
||||
include("mstructures.jl")
|
||||
|
||||
end
|
||||
|
||||
end # of module GroupRings
|
||||
|
32
src/mstructures.jl
Normal file
32
src/mstructures.jl
Normal 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
|
Loading…
Reference in New Issue
Block a user