mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 06:30:29 +01:00
fix error in packed Int4 pair
This commit is contained in:
parent
5ede922ab8
commit
f438d0483b
@ -5,27 +5,21 @@ struct Transvection <: GSymbol
|
|||||||
|
|
||||||
function Transvection(id::Symbol, i::Integer, j::Integer, inv = false)
|
function Transvection(id::Symbol, i::Integer, j::Integer, inv = false)
|
||||||
@assert id in (:ϱ, :λ)
|
@assert id in (:ϱ, :λ)
|
||||||
return new(id, _indices(UInt8(i), UInt8(j)), inv)
|
@boundscheck @assert 0 < i <= (typemax(UInt8) >> 4)
|
||||||
|
@boundscheck @assert 0 < j <= (typemax(UInt8) >> 4)
|
||||||
|
return new(id, (convert(UInt8, i) << 4) + convert(UInt8, j), inv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ϱ(i, j) = Transvection(:ϱ, i, j)
|
ϱ(i, j) = Transvection(:ϱ, i, j)
|
||||||
λ(i, j) = Transvection(:λ, i, j)
|
λ(i, j) = Transvection(:λ, i, j)
|
||||||
|
|
||||||
_indices(ij::UInt8) = (ij & 0xf0) >> 4, (ij & 0x0f)
|
_tophalf(ij::UInt8) = (ij & 0xf0) >> 4
|
||||||
|
_bothalf(ij::UInt8) = (ij & 0x0f)
|
||||||
function _indices(i::UInt8, j::UInt8)
|
|
||||||
@boundscheck @assert i < typemax(i) ÷ 2
|
|
||||||
@boundscheck @assert j < typemax(j) ÷ 2
|
|
||||||
sizeof
|
|
||||||
return (i << 4) + j
|
|
||||||
end
|
|
||||||
|
|
||||||
indices(t::Transvection) = Int.(_indices(t.ij))
|
|
||||||
|
|
||||||
function Base.getproperty(t::Transvection, s::Symbol)
|
function Base.getproperty(t::Transvection, s::Symbol)
|
||||||
s === :i && return first(indices(t))
|
s === :i && return _tophalf(t.ij)
|
||||||
s === :j && return last(indices(t))
|
s === :j && return _bothalf(t.ij)
|
||||||
return Core.getfield(t, s)
|
return Core.getfield(t, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -39,14 +33,15 @@ function Base.show(io::IO, t::Transvection)
|
|||||||
t.inv && print(io, "^-1")
|
t.inv && print(io, "^-1")
|
||||||
end
|
end
|
||||||
|
|
||||||
Base.inv(t::Transvection) = Transvection(t.id, _indices(t.ij)..., !t.inv)
|
Base.inv(t::Transvection) =
|
||||||
|
Transvection(t.id, _tophalf(t.ij), _bothalf(t.ij), !t.inv)
|
||||||
|
|
||||||
Base.:(==)(t::Transvection, s::Transvection) =
|
Base.:(==)(t::Transvection, s::Transvection) =
|
||||||
t.id === s.id && t.ij == s.ij && t.inv == s.inv
|
t.id === s.id && t.ij == s.ij && t.inv == s.inv
|
||||||
Base.hash(t::Transvection, h::UInt) = hash(t.id, hash(t.ij, hash(t.inv, h)))
|
Base.hash(t::Transvection, h::UInt) = hash(t.id, hash(t.ij, hash(t.inv, h)))
|
||||||
|
|
||||||
Base.@propagate_inbounds function evaluate!(v::NTuple{T, N}, t::Transvection, A::Alphabet, tmp=one(first(v))) where {T, N}
|
Base.@propagate_inbounds function evaluate!(v::NTuple{T, N}, t::Transvection, A::Alphabet, tmp=one(first(v))) where {T, N}
|
||||||
i, j = indices(t)
|
i, j = t.i, t.j
|
||||||
@assert i ≤ length(v) && j ≤ length(v)
|
@assert i ≤ length(v) && j ≤ length(v)
|
||||||
|
|
||||||
@inbounds begin
|
@inbounds begin
|
||||||
|
Loading…
Reference in New Issue
Block a user