add general matrix groups

This commit is contained in:
Marek Kaluba 2023-03-15 18:26:45 +01:00
parent 40cd92e3c4
commit 46c95dbb83
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
3 changed files with 63 additions and 1 deletions

View File

@ -9,10 +9,11 @@ import GroupsCore.Random # GroupsCore rand
using ..Groups
using Groups.KnuthBendix
export SpecialLinearGroup, SymplecticGroup
export MatrixGroup, SpecialLinearGroup, SymplecticGroup
include("abstract.jl")
include("matrix_group.jl")
include("SLn.jl")
include("Spn.jl")

View File

@ -0,0 +1,36 @@
struct MatrixElt{N,T,} <: Groups.GSymbol
id::Symbol
inv::Bool
mat::StaticArrays.SMatrix{N,N,T,}
function MatrixElt{N,T}(
id::Symbol,
mat::AbstractMatrix,
inv::Bool = false,
) where {N,T}
n = LinearAlgebra.checksquare(mat)
@assert N == n
@assert !iszero(LinearAlgebra.det(mat))
return new{N,T,N^2}(id, inv, mat)
end
end
function MatrixElt{N}(
id::Symbol,
mat::AbstractMatrix,
inv::Bool = false,
) where {N}
return MatrixElt{N,eltype(mat)}(id, mat, inv)
end
Base.show(io::IO, m::MatrixElt) = print(io, m.id, m.inv ? "⁻¹" : "")
Base.:(==)(m::MatrixElt, n::MatrixElt) = m.mat == n.mat
Base.hash(m::MatrixElt, h::UInt) = hash(m.mat, hash(typeof(m), h))
function Base.inv(m::MatrixElt{N,T}) where {N,T}
return MatrixElt{N,T}(m.id, round.(T, inv(m.mat)), !m.inv)
end
matrix(m::MatrixElt) = m.mat

View File

@ -0,0 +1,25 @@
include("matrix_generators.jl")
struct MatrixGroup{N,T,R,S} <: AbstractMatrixGroup{N,T}
base_ring::R
alphabet::Alphabet{S}
gens::Vector{S}
end
function MatrixGroup{N}(
gens::AbstractVector{<:AbstractMatrix{T}},
base_ring = T,
) where {N,T}
S = map(enumerate(gens)) do (i, mat)
id = Symbol('m', Groups.subscriptify(i))
return MatrixElt{N}(id, mat)
end
alphabet = Alphabet(S)
R = typeof(base_ring)
St = eltype(S)
return MatrixGroup{N,T,R,St}(base_ring, alphabet, S)
end
GroupsCore.ngens(M::MatrixGroup) = length(M.gens)