mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-25 02:05:30 +01:00
Parametrise Automorphisms on Integer type
This commit is contained in:
parent
d46c5dafcc
commit
b8abe64656
@ -4,29 +4,29 @@
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
struct RTransvect
|
struct RTransvect{I<:Integer}
|
||||||
i::Int
|
i::I
|
||||||
j::Int
|
j::I
|
||||||
end
|
end
|
||||||
|
|
||||||
struct LTransvect
|
struct LTransvect{I<:Integer}
|
||||||
i::Int
|
i::I
|
||||||
j::Int
|
j::I
|
||||||
end
|
end
|
||||||
|
|
||||||
struct FlipAut
|
struct FlipAut{I<:Integer}
|
||||||
i::Int
|
i::I
|
||||||
end
|
end
|
||||||
|
|
||||||
struct PermAut
|
struct PermAut{I<:Integer}
|
||||||
perm::Nemo.Generic.perm{Int8}
|
perm::Nemo.Generic.perm{I}
|
||||||
end
|
end
|
||||||
|
|
||||||
struct Identity end
|
struct Identity end
|
||||||
|
|
||||||
struct AutSymbol <: GSymbol
|
struct AutSymbol <: GSymbol
|
||||||
str::String
|
str::String
|
||||||
pow::Int
|
pow::Int8
|
||||||
typ::Union{LTransvect, RTransvect, PermAut, FlipAut, Identity}
|
typ::Union{LTransvect, RTransvect, PermAut, FlipAut, Identity}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,17 +63,17 @@ parent_type(::Automorphism{N}) where N = AutGroup{N}
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function (ϱ::RTransvect)(v, pow=1::Int)
|
function (ϱ::RTransvect{I})(v, pow::Integer=one(I)) where I
|
||||||
@inbounds Groups.r_multiply!(v[ϱ.i], (v[ϱ.j]^pow).symbols, reduced=false)
|
@inbounds Groups.r_multiply!(v[ϱ.i], (v[ϱ.j]^pow).symbols, reduced=false)
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
function (λ::LTransvect)(v, pow=1::Int)
|
function (λ::LTransvect{I})(v, pow::Integer=one(I)) where I
|
||||||
@inbounds Groups.l_multiply!(v[λ.i], (v[λ.j]^pow).symbols, reduced=false)
|
@inbounds Groups.l_multiply!(v[λ.i], (v[λ.j]^pow).symbols, reduced=false)
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
function (σ::PermAut)(v, pow=1::Int)
|
function (σ::PermAut{I})(v, pow::Integer=one(I)) where I
|
||||||
w = deepcopy(v)
|
w = deepcopy(v)
|
||||||
s = (σ.perm^pow).d
|
s = (σ.perm^pow).d
|
||||||
@inbounds for k in eachindex(v)
|
@inbounds for k in eachindex(v)
|
||||||
@ -82,14 +82,14 @@ function (σ::PermAut)(v, pow=1::Int)
|
|||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
function (ɛ::FlipAut)(v, pow=1::Int)
|
function (ɛ::FlipAut{I})(v, pow::Integer=one(I)) where I
|
||||||
@inbounds if isodd(pow)
|
@inbounds if isodd(pow)
|
||||||
v[ɛ.i].symbols = inv(v[ɛ.i]).symbols
|
v[ɛ.i].symbols = inv(v[ɛ.i]).symbols
|
||||||
end
|
end
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
(::Identity)(v, pow=1::Int) = v
|
(::Identity)(v, pow::Integer=zero(Int8)) = v
|
||||||
|
|
||||||
# taken from ValidatedNumerics, under under the MIT "Expat" License:
|
# taken from ValidatedNumerics, under under the MIT "Expat" License:
|
||||||
# https://github.com/JuliaIntervals/ValidatedNumerics.jl/blob/master/LICENSE.md
|
# https://github.com/JuliaIntervals/ValidatedNumerics.jl/blob/master/LICENSE.md
|
||||||
@ -102,38 +102,39 @@ function id_autsymbol()
|
|||||||
return AutSymbol("(id)", 0, Identity())
|
return AutSymbol("(id)", 0, Identity())
|
||||||
end
|
end
|
||||||
|
|
||||||
function rmul_autsymbol(i, j; pow::Int=1)
|
function rmul_autsymbol(i::I, j::I; pow::Integer=one(I)) where I<:Integer
|
||||||
str = "ϱ"*subscriptify(i)*subscriptify(j)
|
str = "ϱ"*subscriptify(i)*subscriptify(j)
|
||||||
return AutSymbol(str, pow, RTransvect(i, j))
|
return AutSymbol(str, I(pow), RTransvect(i, j))
|
||||||
end
|
end
|
||||||
|
|
||||||
function lmul_autsymbol(i, j; pow::Int=1)
|
function lmul_autsymbol(i::I, j::I; pow::Integer=one(I)) where I<:Integer
|
||||||
str = "λ"*subscriptify(i)*subscriptify(j)
|
str = "λ"*subscriptify(i)*subscriptify(j)
|
||||||
return AutSymbol(str, pow, LTransvect(i, j))
|
return AutSymbol(str, I(pow), LTransvect(i, j))
|
||||||
end
|
end
|
||||||
|
|
||||||
function flip_autsymbol(i; pow::Int=1)
|
function flip_autsymbol(i::I; pow::Integer=one(I)) where I<:Integer
|
||||||
pow = (2+pow%2)%2
|
pow = I((2+pow%2)%2)
|
||||||
if pow == 0
|
if pow == zero(I)
|
||||||
return id_autsymbol()
|
return id_autsymbol()
|
||||||
else
|
else
|
||||||
str = "ɛ"*subscriptify(i)
|
str = "ɛ"*subscriptify(i)
|
||||||
return AutSymbol(str, pow, FlipAut(i))
|
return AutSymbol(str, I(pow), FlipAut(i))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function perm_autsymbol(p::Generic.perm{Int8}; pow::Int=1)
|
function perm_autsymbol(p::Generic.perm{I}; pow::Integer=one(I)) where I<:Integer
|
||||||
p = p^pow
|
p = p^pow
|
||||||
if p == parent(p)()
|
for i in eachindex(p.d)
|
||||||
return id_autsymbol()
|
if p.d[i] != i
|
||||||
else
|
|
||||||
str = "σ"*join([subscriptify(i) for i in p.d])
|
str = "σ"*join([subscriptify(i) for i in p.d])
|
||||||
return AutSymbol(str, 1, PermAut(p))
|
return AutSymbol(str, one(I), PermAut(p))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
return id_autsymbol()
|
||||||
end
|
end
|
||||||
|
|
||||||
function perm_autsymbol(a::Vector{T}) where T<:Integer
|
function perm_autsymbol(a::Vector{T}) where T<:Integer
|
||||||
G = PermutationGroup(Int8(length(a)))
|
G = PermutationGroup(T(length(a)))
|
||||||
return perm_autsymbol(G(Vector{Int8}(a)))
|
return perm_autsymbol(G(Vector{Int8}(a)))
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -146,11 +147,13 @@ domain(G::AutGroup)= NTuple{length(G.objectGroup.gens), FreeGroupElem}(gens(G.ob
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function AutGroup(G::FreeGroup; special=false)
|
function AutGroup(G::FreeGroup; special=false)
|
||||||
n = length(gens(G))
|
|
||||||
n == 0 && return AutGroup{n}(G, AutSymbol[])
|
|
||||||
S = AutSymbol[]
|
S = AutSymbol[]
|
||||||
|
n = length(gens(G))
|
||||||
|
n == 0 && return AutGroup{n}(G, S)
|
||||||
|
|
||||||
indexing = [[i,j] for i in 1:n for j in 1:n if i≠j]
|
n = convert(Int8, n)
|
||||||
|
|
||||||
|
indexing = [[i,j] for i in Int8(1):n for j in Int8(1):n if i≠j]
|
||||||
|
|
||||||
rmuls = [rmul_autsymbol(i,j) for (i,j) in indexing]
|
rmuls = [rmul_autsymbol(i,j) for (i,j) in indexing]
|
||||||
lmuls = [lmul_autsymbol(i,j) for (i,j) in indexing]
|
lmuls = [lmul_autsymbol(i,j) for (i,j) in indexing]
|
||||||
@ -159,12 +162,12 @@ function AutGroup(G::FreeGroup; special=false)
|
|||||||
|
|
||||||
if !special
|
if !special
|
||||||
flips = [flip_autsymbol(i) for i in 1:n]
|
flips = [flip_autsymbol(i) for i in 1:n]
|
||||||
syms = [perm_autsymbol(p) for p in elements(PermutationGroup(Int8(n)))][2:end]
|
syms = [perm_autsymbol(p) for p in elements(PermutationGroup(n))][2:end]
|
||||||
|
|
||||||
append!(S, [flips; syms])
|
append!(S, [flips; syms])
|
||||||
|
|
||||||
end
|
end
|
||||||
return AutGroup{n}(G, S)
|
return AutGroup{Int64(n)}(G, S)
|
||||||
end
|
end
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -266,8 +269,8 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function change_pow(s::AutSymbol, n::Int)
|
function change_pow(s::AutSymbol, n::Integer)
|
||||||
if n == 0
|
if n == zero(n)
|
||||||
return id_autsymbol()
|
return id_autsymbol()
|
||||||
end
|
end
|
||||||
symbol = s.typ
|
symbol = s.typ
|
||||||
|
Loading…
Reference in New Issue
Block a user