Grades and indices
Grades
CliffordNumbers.nonzero_grades
— Functionnonzero_grades(::Type{<:AbstractCliffordNumber{Q}}) -> AbstractVector{Int}
nonzero_grades(::Number)
Returns an AbstractVector{Int}
whose elements are all nonzero grades of a Clifford number or type. Any subtype T
of AbstractCliffordNumber
should define this method for Type{T}
; it is automatically implemented for instance arguments.
For arguments that are Real
or Complex
, this function returns 0:0
.
Examples
julia> CliffordNumbers.nonzero_grades(CliffordNumber{VGA(3)})
0:3
julia> CliffordNumbers.nonzero_grades(EvenCliffordNumber{VGA(3)})
0:2:2
julia> CliffordNumbers.nonzero_grades(KVector{2,VGA(3)})
2:2
julia> nonzero_grades(Float64)
0:0
CliffordNumbers.has_grades_of
— Functionhas_grades_of(S::Type{<:AbstractCliffordNumber}, T::Type{<:AbstractCliffordNumber}) -> Bool
has_grades_of(x::AbstractCliffordNumber, y::AbstractCliffordNumber) -> Bool
Returns true
if the grades represented in S are also represented in T; false
otherwise.
BladeIndex
and BladeIndices
CliffordNumbers.BladeIndex
— TypeBladeIndex{Q}
A representation of an index corresponding to a basis blade of the geometric algebra with quadratic form Q
.
CliffordNumbers.is_same_blade
— FunctionCliffordNumbers.is_same_blade(a::BladeIndex{Q}, b::BladeIndex{Q})
Checks if a
and b
perform identical indexing up to sign.
CliffordNumbers.BladeIndices
— TypeBladeIndices{Q,C<:AbstractCliffordNumber{Q}} <: AbstractVector{BladeIndex{Q}}
Represents all valid nonzero indices of an AbstractCliffordNumber
in a lazily generated array of static size.
New subtypes of AbstractCliffordNumber{Q}
should define Base.getindex(::BladeIndex{Q,C}, ::Int)
. For performance, this definition should be annotated with the macros @inline
and Base.@propagate_inbounds
(to preserve the @inbounds
context).
Construction
BladeIndices
can be constructed by calling the type constructor with the Clifford number or its type. This will automatically strip some type parameters so that identical BladeIndices
objects are constructed regardless of the scalar type.
For this reason, you should not use BladeIndices{Q,C}()
; instead use BladeIndices(C)
.
Implementation
This type is implemented as an alias of CliffordNumbers.CGNBladeIndices{Q,C<:AbstractCliffordNumber{Q},false,false,false}
. More information is available at the docstring for CliffordNumbers.CGNBladeIndices
.
Special indices
CliffordNumbers.scalar_index
— Functionscalar_index(x::AbstractCliffordNumber{Q}) -> BladeIndex{Q}
Constructs the BladeIndex
used to obtain the scalar (grade zero) portion of x
.
CliffordNumbers.pseudoscalar_index
— Functionpseudoscalar_index(x::AbstractCliffordNumber{Q}) -> BladeIndex{Q}
Constructs the BladeIndex
used to obtain the pseudoscalar (highest grade) portion of x
.
Tools for implementing mathematical operations
Base.reverse
— Methodreverse(i::BladeIndex) = i' -> BladeIndex
reverse(x::AbstractCliffordNumber) = x' -> typeof(x)
Performs the reverse operation on the basis blade indexed by b
or the Clifford number x
. The sign of the reverse depends on the grade of the basis blade g
, and is positive for g % 4 in 0:1
and negative for g % 4 in 2:3
.
CliffordNumbers.grade_involution
— Methodgrade_involution(i::BladeIndex) -> BladeIndex
grade_involution(x::AbstractCliffordNumber) -> typeof(x)
Calculates the grade involution of the basis blade indexed by b
or the Clifford number x
. This effectively reflects all of the basis vectors of the space along their own mirror operation, which makes elements of odd grade flip sign.
Base.conj
— Methodconj(i::BladeIndex) -> BladeIndex
conj(x::AbstractCliffordNumber) -> typeof(x)
Calculates the Clifford conjugate of the basis blade indexed by b
or the Clifford number x
. This is equal to grade_involution(reverse(x))
.
CliffordNumbers.left_complement
— Methodleft_complement(b::BladeIndex{Q}) -> BladeIndex{Q}
Returns the left complement of b
, define so that left_complement(b) * b
generates the pseudoscalar index of elements of the algebra Q
.
When the left complement is applied twice, the original BladeIndex
object is returned up to a change of sign, given by (-1)^(grade(b) * (dimension(Q) - grade(b))). This implies that in algebras of odd dimension, the left complement and [right complement](@ref right_complement) are identical because either
grade(b)or
dimension(Q) - grade(b)must be even. The complement is independent of the signature of
Q`, depending only on the dimension.
Lengyel's convention for the left complement is an underbar.
CliffordNumbers.right_complement
— Methodright_complement(b::BladeIndex{Q}) -> BladeIndex{Q}
Returns the right complement of b
, define so that b * right_complement(b)
generates the pseudoscalar index of elements of the algebra Q
.
When the right complement is applied twice, the original BladeIndex
object is returned up to a change of sign, given by (-1)^(grade(b) * (dimension(Q) - grade(b))). This implies that in algebras of odd dimension, the [left complement](@ref left_complement) and right complement are identical because either
grade(b)or
dimension(Q) - grade(b)must be even. The complement is independent of the signature of
Q`, depending only on the dimension.
Lengyel's convention for the right complement is an overbar.
CliffordNumbers.grade
— Methodgrade(i::BladeIndex) -> Int
Returns the grade of the basis blade represented by i
, which ranges from 0 to the dimension of the space represented by i
(equal to dimension(signature(i))
).
CliffordNumbers.sign_of_square
— FunctionCliffordNumbers.sign_of_square(b::BladeIndex) -> Int8
Returns the sign associated with squaring the basis blade indexed by b
using an Int8
as proxy: positive signs return Int8(1)
, negative signs return Int8(-1)
, and zeros from degenerate components return Int8(0)
.
CliffordNumbers.signbit_of_square
— FunctionCliffordNumbers.signbit_of_square(b::BladeIndex) -> Bool
Returns the signbit associated with squaring the basis blade indexed by b
.
For basis blades squaring to zero, the result is not meaningful.
CliffordNumbers.nondegenerate_square
— FunctionCliffordNumbers.nondegenerate_square(b::BladeIndex) -> Bool
Returns false
if squaring the basis blade b
is zero due to a degenerate component, true
otherwise. For a nondegenerate metric, this is always true
.
CliffordNumbers.sign_of_mult
— FunctionCliffordNumbers.sign_of_mult(a::T, b::T) where T<:BladeIndex -> Int8
Returns an Int8
that carries the sign associated with the multiplication of two basis blades of Clifford/geometric algebras of the same quadratic form.
CliffordNumbers.signbit_of_mult
— FunctionCliffordNumbers.signbit_of_mult(a::Integer, [b::Integer]) -> Bool
CliffordNumbers.signbit_of_mult(a::BladeIndex, [b::BladeIndex]) -> Bool
Calculates the sign bit associated with multiplying basis elements indexed with bit indices supplied as either integers or BladeIndex
instances. The sign bit flips when the order of a
and b
are reversed, unless a === b
.
As with Base.signbit()
, true
represents a negative sign and false
a positive sign. However, in degenerate metrics (such as those of projective geometric algebras) the sign bit may be irrelevant as the multiplication of those basis blades would result in zero.
CliffordNumbers.nondegenerate_mult
— FunctionCliffordNumbers.nondegenerate_mult(a::T, b::T) where T<:BladeIndex -> Bool
Returns false
if the product of a
and b
is zero due to the squaring of a degenerate component, true
otherwise. This function always returns true
if R === 0
.
Base.:*
— Method*(a::BladeIndex{Q}, b::BladeIndex{Q}) -> BladeIndex{Q}
Returns the BladeIndex
corresponding to the basis blade resulting from the geometric product of the basis blades indexed by a
and b
.
CliffordNumbers.has_wedge
— FunctionCliffordNumbers.has_wedge(a::BladeIndex{Q}, b::BladeIndex{Q}, [c::BladeIndex{Q}...]) -> Bool
Returns true
if the basis blades indexed by a
, b
, or any other blades c...
have a nonzero wedge product; false
otherwise. This is determined by comparing all bits of the arguments (except the sign bit) to identify any matching basis blades using bitwise AND.