Groups.jl/src/matrix_groups/Spn.jl

62 lines
1.6 KiB
Julia
Raw Normal View History

include("eltary_symplectic.jl")
2023-03-15 17:11:22 +01:00
struct SymplecticGroup{N,T,R,A,S} <: AbstractMatrixGroup{N,T}
base_ring::R
alphabet::A
gens::S
2022-10-14 01:14:38 +02:00
function SymplecticGroup{N}(base_ring) where {N}
S = symplectic_gens(N, eltype(base_ring))
alphabet = Alphabet(S)
return new{
N,
eltype(base_ring),
typeof(base_ring),
typeof(alphabet),
typeof(S)
}(base_ring, alphabet, S)
end
end
GroupsCore.ngens(Sp::SymplecticGroup) = length(Sp.gens)
2023-03-15 17:20:52 +01:00
Base.show(io::IO, ::SymplecticGroup{N,T}) where {N,T} = print(io, "Sp{$N,$T}")
2023-03-15 17:20:52 +01:00
function Base.show(io::IO, ::MIME"text/plain", ::SymplecticGroup{N}) where {N}
return print(io, "group of $N×$N symplectic matrices")
end
2022-10-14 01:14:38 +02:00
_offdiag_idcs(n) = ((i, j) for i in 1:n for j in 1:n if i j)
2022-04-02 16:19:08 +02:00
function symplectic_gens(N, T=Int8)
iseven(N) || throw(ArgumentError("N needs to be even!"))
2022-10-14 01:14:38 +02:00
n = N ÷ 2
2022-10-14 01:14:38 +02:00
a_ijs = [ElementarySymplectic{N}(:A, i, j, one(T)) for (i, j) in _offdiag_idcs(n)]
b_is = [ElementarySymplectic{N}(:B, n + i, i, one(T)) for i in 1:n]
c_ijs = [ElementarySymplectic{N}(:B, n + i, j, one(T)) for (i, j) in _offdiag_idcs(n)]
S = [a_ijs; b_is; c_ijs]
S = [S; transpose.(S)]
return unique(S)
end
function _std_symplectic_form(m::AbstractMatrix)
2022-10-14 01:14:38 +02:00
r, c = size(m)
r == c || return false
iseven(r) || return false
2022-10-14 01:14:38 +02:00
n = r ÷ 2
2022-04-03 18:40:02 +02:00
𝕆 = zeros(eltype(m), n, n)
2022-10-14 01:14:38 +02:00
𝕀 = one(eltype(m)) * LinearAlgebra.I
2022-04-03 18:40:02 +02:00
Ω = [𝕆 -𝕀
2022-10-14 01:14:38 +02:00
𝕀 𝕆]
return Ω
end
2022-10-14 01:14:38 +02:00
function issymplectic(mat::M, Ω=_std_symplectic_form(mat)) where {M<:AbstractMatrix}
return Ω == transpose(mat) * Ω * mat
end