mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 14:35:28 +01:00
add general matrix groups
This commit is contained in:
parent
40cd92e3c4
commit
46c95dbb83
@ -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")
|
||||
|
||||
|
36
src/matrix_groups/matrix_generators.jl
Normal file
36
src/matrix_groups/matrix_generators.jl
Normal file
@ -0,0 +1,36 @@
|
||||
struct MatrixElt{N,T,N²} <: Groups.GSymbol
|
||||
id::Symbol
|
||||
inv::Bool
|
||||
mat::StaticArrays.SMatrix{N,N,T,N²}
|
||||
|
||||
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
|
25
src/matrix_groups/matrix_group.jl
Normal file
25
src/matrix_groups/matrix_group.jl
Normal 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)
|
Loading…
Reference in New Issue
Block a user