mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-26 02:20:30 +01:00
simplify type of AutSymbols
This commit is contained in:
parent
2a359f52b1
commit
3cc6262356
@ -4,22 +4,22 @@
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
struct RTransvect{I<:Integer}
|
struct RTransvect
|
||||||
i::I
|
i::Int8
|
||||||
j::I
|
j::Int8
|
||||||
end
|
end
|
||||||
|
|
||||||
struct LTransvect{I<:Integer}
|
struct LTransvect
|
||||||
i::I
|
i::Int8
|
||||||
j::I
|
j::Int8
|
||||||
end
|
end
|
||||||
|
|
||||||
struct FlipAut{I<:Integer}
|
struct FlipAut
|
||||||
i::I
|
i::Int8
|
||||||
end
|
end
|
||||||
|
|
||||||
struct PermAut{I<:Integer}
|
struct PermAut
|
||||||
perm::Generic.perm{I}
|
perm::Generic.perm{Int8}
|
||||||
end
|
end
|
||||||
|
|
||||||
struct Identity end
|
struct Identity end
|
||||||
@ -41,8 +41,9 @@ mutable struct Automorphism{N} <: GWord{AutSymbol}
|
|||||||
savedhash::UInt
|
savedhash::UInt
|
||||||
parent::AutGroup{N}
|
parent::AutGroup{N}
|
||||||
|
|
||||||
Automorphism{N}(f::Vector{AutSymbol}) where N = new(f, true, zero(UInt))
|
function Automorphism{N}(f::Vector{AutSymbol}) where {N}
|
||||||
|
return new{N}(f, true, zero(UInt))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
export Automorphism, AutGroup, Aut, SAut
|
export Automorphism, AutGroup, Aut, SAut
|
||||||
@ -63,39 +64,47 @@ parent_type(::Automorphism{N}) where N = AutGroup{N}
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function (ϱ::RTransvect{I})(v, pow::Integer=one(I)) where I
|
function (ϱ::RTransvect)(v, pow::Integer=1)
|
||||||
@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{I})(v, pow::Integer=one(I)) where I
|
function (λ::LTransvect)(v, pow::Integer=1)
|
||||||
@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{I})(v, pow::Integer=one(I)) where I
|
function (σ::PermAut)(v, pow::Integer=1)
|
||||||
w = deepcopy(v)
|
w = deepcopy(v)
|
||||||
|
if pow == 1
|
||||||
|
@inbounds for k in eachindex(v)
|
||||||
|
v[k].symbols = w[σ.perm.d[k]].symbols
|
||||||
|
end
|
||||||
|
else
|
||||||
s = (σ.perm^pow).d
|
s = (σ.perm^pow).d
|
||||||
@inbounds for k in eachindex(v)
|
@inbounds for k in eachindex(v)
|
||||||
v[k].symbols = w[s[k]].symbols
|
v[k].symbols = w[s[k]].symbols
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
function (ɛ::FlipAut{I})(v, pow::Integer=one(I)) where I
|
function (ɛ::FlipAut)(v, pow::Integer=1)
|
||||||
@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::Integer=zero(Int8)) = v
|
(::Identity)(v, pow::Integer=1) = 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
|
||||||
function subscriptify(n::Integer)
|
function subscriptify(n::Integer)
|
||||||
subscript_0 = Int(0x2080) # Char(0x2080) -> subscript 0
|
subscript_0 = Int(0x2080) # Char(0x2080) -> subscript 0
|
||||||
return join([Char(subscript_0 + i) for i in reverse(digits(n))])
|
@assert 0 <= n <= 9
|
||||||
|
return Char(subscript_0 + n)
|
||||||
|
# return [Char(subscript_0 + i) for i in reverse(digits(n))])
|
||||||
end
|
end
|
||||||
|
|
||||||
function id_autsymbol()
|
function id_autsymbol()
|
||||||
@ -123,7 +132,9 @@ function flip_autsymbol(i::I; pow::Integer=one(I)) where I<:Integer
|
|||||||
end
|
end
|
||||||
|
|
||||||
function perm_autsymbol(p::Generic.perm{I}; pow::Integer=one(I)) where I<:Integer
|
function perm_autsymbol(p::Generic.perm{I}; pow::Integer=one(I)) where I<:Integer
|
||||||
|
if pow != 1
|
||||||
p = p^pow
|
p = p^pow
|
||||||
|
end
|
||||||
for i in eachindex(p.d)
|
for i in eachindex(p.d)
|
||||||
if p.d[i] != i
|
if p.d[i] != i
|
||||||
str = "σ"*join([subscriptify(i) for i in p.d])
|
str = "σ"*join([subscriptify(i) for i in p.d])
|
||||||
@ -154,9 +165,7 @@ function AutGroup(G::FreeGroup; special=false)
|
|||||||
n = length(gens(G))
|
n = length(gens(G))
|
||||||
n == 0 && return AutGroup{n}(G, S)
|
n == 0 && return AutGroup{n}(G, S)
|
||||||
|
|
||||||
n = convert(Int8, n)
|
indexing = [[i,j] for i in 1:n for j in 1:n if i≠j]
|
||||||
|
|
||||||
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]
|
||||||
@ -170,7 +179,7 @@ function AutGroup(G::FreeGroup; special=false)
|
|||||||
append!(S, [flips; syms])
|
append!(S, [flips; syms])
|
||||||
|
|
||||||
end
|
end
|
||||||
return AutGroup{Int64(n)}(G, S)
|
return AutGroup{n}(G, S)
|
||||||
end
|
end
|
||||||
|
|
||||||
Aut(G::Group) = AutGroup(G)
|
Aut(G::Group) = AutGroup(G)
|
||||||
|
Loading…
Reference in New Issue
Block a user