Docstrings

Multivector types

GeometricAlgebra.GradeType
Grade{K} >: BasisBlade{Sig,K}, Multivector{Sig,K}

Type alias for a BasisBlade or Multivector with grade parameter K.

Example

julia> prod(basis(3))::Grade{3}
BasisBlade{3, 3, Int64}:
 1 v123
source
GeometricAlgebra.AbstractMultivectorType
AbstractMultivector{Sig,K}

Supertype of elements of the geometric algebra with metric signature Sig and grade(s) K.

Subtypes

         AbstractMultivector{Sig,K}
            /               \
BasisBlade{Sig,K,T}   Multivector{Sig,K,S}
  • BasisBlade: a scalar multiple of a wedge product of orthogonal basis vectors.
  • Multivector: a homogeneous or inhomogeneous multivector; a sum of basis blades.
source
GeometricAlgebra.BasisBladeType
BasisBlade{Sig,K,T} <: AbstractMultivector{Sig,K}

A basis blade of grade K and scalar coefficient of type T.

Basis blades are scalar multiples of wedge products of orthogonal basis vectors.

Note

Not every $k$-blade (i.e., wedge product of $k$ linearly independent vectors) is representable as a BasisBlade. However, every $k$-blade is a Multivector of grade k.

Parameters

  • Sig: Metric signature defining the geometric algebra, retrieved with signature().
  • K::Int: Grade of the blade, equal to count_ones(bits), retrieved with grade().
  • T: Numerical type of the scalar coefficient, retrieved with eltype().
source
GeometricAlgebra.BasisBladeMethod
BasisBlade{Sig}(bits, coeff)

Basis blade with indices encoded by bits and scalar coefficient coeff.

Indices are encoded in binary (e.g., $v₁∧v₃∧v₄$ has bits 0b1101).

Examples

julia> BasisBlade{3}(42, 0b110) # a grade 2 blade in 3 dimensions
BasisBlade{3, 2, Int64}:
 42 v23
source
GeometricAlgebra.MultivectorType
Multivector{Sig,K,S} <: AbstractMultivector{Sig,K}

A general multivector with parts of grade ∈ K.

For homogeneous k-vectors, the grade parameter K is an integer. Inhomogeneous multivectors may be specified with a range or tuple of grades.

Parameters

  • Sig: Metric signature defining the geometric algebra, retrieved with signature().
  • K: Grade(s) present in the multivector. Can be an integer or a collection of integers (a range or tuple).
  • S: Storage type of the multivector components, usually a subtype of AbstractVector.
source
GeometricAlgebra.MultivectorMethod
Multivector{Sig,K}(comps)

Multivector with grade(s) K and component vector comps.

Components are ordered first by grade, then lexicographically by bits (see componentbits).

Examples

julia> Multivector{3,0:3}(1:2^3)
8-component Multivector{3, 0:3, UnitRange{Int64}}:
 1
 2 v1 + 3 v2 + 4 v3
 5 v12 + 6 v13 + 7 v23
 8 v123

julia> grade(ans, 1)
3-component Multivector{3, 1, UnitRange{Int64}}:
 2 v1
 3 v2
 4 v3
source
Base.zeroMethod
zero(::Type{Multivector{Sig,K,S})
zero(::Type{Multivector{Sig,K}}, [T])

Multivector of metric signature Sig and grade(s) K with components all equal to zero. If specified, the components array is of type S, or is the default array type with element type T.

source
GeometricAlgebra.dimensionMethod
dimension(sig)
dimension(::AbstractMultivector)

The dimension of the underlying vector space of the geometric algebra. See ncomponents for the dimension of the algebra (i.e., the number of independent components of a general multivector).

source
GeometricAlgebra.gradeMethod
grade(a)

Grade or grades present in a multivector a.

The grade of a BasisBlade{Sig,K} or Multivector{Sig,K} is the second type parameter, K. In the case of a multivector, K may be an integer (if it is homogeneous) or a collection (a range or tuple of grades).

See also ishomogeneous.

source
GeometricAlgebra.resulting_multivector_typeMethod
resulting_multivector_type(f, a, b, ...)

Return a Multivector{Sig,K,S} type with parameters (signature Sig, grade(s) K and storage type S) appropriate for representing the result of f(a, b).

Calls resulting_grades(f, dimension(Sig), grade(a), grade(b), ...) to determine K.

source
GeometricAlgebra.signatureMethod
signature(::AbstractMultivector{Sig}) = Sig

The metric signature type parameter of the multivector instance (or type).

source

Multivector operations

Base.:~Method
~a
reversion(a::AbstractMultivector)

Reversion of a multivector.

Reversion is an anti-automorphism defined by reversing the order of the geometric product: ~(a*b) == ~b * ~a. For a k-vector a, the reversion is reversion_sign(k)*a where the sign is given by $(-1)^{k(k - 1)/2}$.

See also involution and clifford_conj.

source
GeometricAlgebra.:∧Method
a ∧ b
wedge(a, b, ...)

Wedge product of multivectors (a.k.a. the outer, exterior, progressive or alternating product, or join).

This is a grade-raising operation, equivalent to graded_prod(+, a, b). If a and b are of grades $p$ and $q$ respectively, then a ∧ b is defined as the grade $p + q$ part of a*b.

source
GeometricAlgebra.:∨Method
a ∨ b
antiwedge(a, b)

Anti-wedge product of multivectors (a.k.a. the regressive product or meet).

The anti-wedge product satisfies

\[D(a ∨ b) = (D a) ∧ (D b)\]

where $D$ is a duality operation such as ldual, rdual or, if $I^2 ≠ 0$, hodgedual.

The anti-wedge product is metric independent like the wedge product, but does depend on the choice of orientation (the ordering of basis vectors).

source
GeometricAlgebra.:⋅Method
a ⋅ b
inner(a, b)

Inner product of multivectors.

This is a grade lowering operation, equivalent to graded_prod(abs∘-, a, b). If a and b are of grades $p$ and $q$ respectively, then a ⋅ b is defined as the grade $|p - q|$ part of a*b.

Note that for scalars a and b, the inner product reduces to scalar multiplication, in contrast to some authors (see [1] for discussion).

See also lcontract and rcontract.

source
GeometricAlgebra.add!Method
add!(a::Multivector, b::Blade)
add!(a::Multivector, bits, coeff)

Add the blade coefficient to the corresponding component of a multivector, if the multivector has such a component.

Warning

If the multivector cannot represent components of the required grade, it is returned unmodified.

This mutates and returns a if it is a mutable type, otherwise it returns a new multivector of identical type. (Thus, the blade coefficient must be convertible to the multivector’s eltype.)

source
GeometricAlgebra.antiwedgeMethod
a ∨ b
antiwedge(a, b)

Anti-wedge product of multivectors (a.k.a. the regressive product or meet).

The anti-wedge product satisfies

\[D(a ∨ b) = (D a) ∧ (D b)\]

where $D$ is a duality operation such as ldual, rdual or, if $I^2 ≠ 0$, hodgedual.

The anti-wedge product is metric independent like the wedge product, but does depend on the choice of orientation (the ordering of basis vectors).

source
GeometricAlgebra.embedMethod
embed(sig, a::Multivector)

Embed a multivector into the algebra of metric signature sig, adding or discarding dimensions as necessary.

Basis vectors in the original and new spaces are associated by the order in which they appear. Components are dropped if dimension(sig) < dimension(a), and extra zero components are added if dimension(sig) > dimension(a).

Examples

julia> embed(Cl(2,2), Multivector{3,2}([1, 2, 3]))
6-component Multivector{Cl(2,2), 2, SVector{6, Float64}}:
 1.0 v12
 2.0 v13
 3.0 v23
 0.0 v14
 0.0 v24
 0.0 v34

julia> embed(2, Multivector{3,1}([1,2,3]))
2-component Multivector{2, 1, SVector{2, Int64}}:
 1 v1
 2 v2
source
GeometricAlgebra.flipdualFunction
flipdual(a)

A dual of a multivector, for when the overall sign isn’t important.

For a unit a::BasisBlade, the flipdual satisfies a*flipdual(a) == ±I where ±I is the unit pseudoscalar or its negative.

The flipdual is cheap to compute and is its own inverse. It simply flips the bits of a BasisBlade, or reverses the components vector of a Multivector.

The flipdual is metric independent (but depends on a choice of orientation, or the order of basis vectors).

See also hodgedual.

source
GeometricAlgebra.graded_prodMethod
graded_prod(grade_selector::Function, a, b)

A grade-filtered product of multivectors.

Terms of the geometric product a*b are filtered according to grade_selector. For instance, if grade(a) == p and grade(b) == q, then graded_prod(f, a, b) is the grade f(p, q) part of a*b. The extends linearly to general multivectors $A$ and $B$ as

\[ (A, B) ↦ \sum_{p,q} ⟨⟨A⟩_p ⟨B⟩_q⟩_{f(p, q)}\]

where $⟨⋅⟩_k$ denotes the grade $k$ part.

The wedge $∧$, inner $⋅$ and contraction products are special cases of this product. For example, the wedge product is defined as:

wedge(a, b) = graded_prod(+, a, b)
source
GeometricAlgebra.hodgedualFunction
hodgedual(a) = ~a*I

Hodge dual of a multivector.

The Hodge dual is defined by

\[H(a) = ã I\]

where $ã$ is the reversion of $a$ and $I$ is the unit pseudoscalar. For $k$-vectors $a$ and $b$, it is alternatively defined by

\[a ∧ H(b) = ⟨a, b⟩ I\]

where $⟨a, b⟩ = a ⊙ b̃$ is the induced inner product on $k$-vectors.

The Hodge dual is metric dependent, since it involves multiplication by I.

See also invhodgedual and ldual, rdual.

Examples

julia> u = Multivector{3,1}(1:3)
3-component Multivector{3, 1, UnitRange{Int64}}:
 1 v1
 2 v2
 3 v3

julia> hodgedual(u)
3-component Multivector{3, 2, SVector{3, Int64}}:
  3 v12
 -2 v13
  1 v23
source
GeometricAlgebra.innerMethod
a ⋅ b
inner(a, b)

Inner product of multivectors.

This is a grade lowering operation, equivalent to graded_prod(abs∘-, a, b). If a and b are of grades $p$ and $q$ respectively, then a ⋅ b is defined as the grade $|p - q|$ part of a*b.

Note that for scalars a and b, the inner product reduces to scalar multiplication, in contrast to some authors (see [1] for discussion).

See also lcontract and rcontract.

source
GeometricAlgebra.invhodgedualFunction
invhodgedual(a)

Inverse of the multivector Hodge dual.

In degenerate algebras (for which $I^2 = 0$), the Hodge dual is not invertible. However, if a is a basis blade with a non-zero Hodge dual, then invhodgedual(hodgedual(a)) == a holds.

See also hodgedual.

source
GeometricAlgebra.ldualFunction
ldual(a)
rdual(a)

Left and right multivector duals (a.k.a., complements). The right dual is also called the Poincaré dual.

For a unit basis blade a, the duals satisfy a*rdual(a) == I == ldual(a)*a where I is the unit pseudoscalar. If dimension(a) is odd, rdual and ldual are identical and self-inverse; in general, they are inverses of each other.

The left and right duals are metric independent (but depend on a choice of orientation, or the order of basis vectors). This makes them useful in degenerate algebras where I^2 == 0, since a non-zero multivector always has a non-zero dual, even if its Hodge dual is zero.

See also hodgedual.

source
GeometricAlgebra.outermorphismMethod
outermorphism(mat, a)

Outermorphism of the multivector a specified by the matrix mat.

If $f$ is a linear map, then the outermorphism $f̲$ is a linear map satisfying $f̲(𝒖) = f(𝒖)$ on vectors $𝒖$ and $f̲(a ∧ b) = f̲(a) ∧ f̲(b)$ on general multivectors.

source
GeometricAlgebra.rdualFunction
ldual(a)
rdual(a)

Left and right multivector duals (a.k.a., complements). The right dual is also called the Poincaré dual.

For a unit basis blade a, the duals satisfy a*rdual(a) == I == ldual(a)*a where I is the unit pseudoscalar. If dimension(a) is odd, rdual and ldual are identical and self-inverse; in general, they are inverses of each other.

The left and right duals are metric independent (but depend on a choice of orientation, or the order of basis vectors). This makes them useful in degenerate algebras where I^2 == 0, since a non-zero multivector always has a non-zero dual, even if its Hodge dual is zero.

See also hodgedual.

source
GeometricAlgebra.reversionMethod
~a
reversion(a::AbstractMultivector)

Reversion of a multivector.

Reversion is an anti-automorphism defined by reversing the order of the geometric product: ~(a*b) == ~b * ~a. For a k-vector a, the reversion is reversion_sign(k)*a where the sign is given by $(-1)^{k(k - 1)/2}$.

See also involution and clifford_conj.

source
GeometricAlgebra.wedgeMethod
a ∧ b
wedge(a, b, ...)

Wedge product of multivectors (a.k.a. the outer, exterior, progressive or alternating product, or join).

This is a grade-raising operation, equivalent to graded_prod(+, a, b). If a and b are of grades $p$ and $q$ respectively, then a ∧ b is defined as the grade $p + q$ part of a*b.

source
GeometricAlgebra.factorbladeMethod
factorblade(A::AbstractMultivector)

Find a factorisation $A = u₁ ∧ ⋯ ∧ uₖ$ of a $k$-blade $A$ using the "fast factorisation" algorithm [1], so that wedge(factorblade(A)...) ≈ A.

Warning

The multivector A is assumed to be a blade without checking. If it is not a blade, then factorblade(A) is undefined.

source
GeometricAlgebra.inv_flv_methodMethod
inv_flv_method(::AbstractMultivector)

Inverse of a multivector using the Faddeev–LeVerrier algorithm [1].

This algorithm requires $2^{d - 1}$ many geometric multiplications, where $d$ is the dimension of the algebra.

source
GeometricAlgebra.matrix_reprFunction
matrix_repr(a::AbstractMultivector, k=0:dim)

Matrix representation of the grade k parts of a multivector.

By default, the full $2^d × 2^d$ linear representation is used in $d$ dimensions. Smaller representations can be used for elements in

  • the even subalgebra, k=0:2:dim
  • the scalar-pseudoscalar subalgebra, k=(0, dim)

by restricting k to those grades.

Examples

julia> @basis 2
[ Info: Defined basis blades v1, v2, v12, I in Main

julia> matrix_repr(1 + 7v12)
4×4 Matrix{Int64}:
 1   0  0  -7
 0   1  7   0
 0  -7  1   0
 7   0  0   1

julia> matrix_repr(1 + 7v12, (0, 2))
2×2 Matrix{Int64}:
 1  -7
 7   1

julia> matrix_repr(v1*v2) == matrix_repr(v1)matrix_repr(v2)
true
source
GeometricAlgebra.try_ensure_realMethod
try_ensure_real(a::Multivector)

Tries to convert a complex-valued Multivector into an equivalent real one, returning the original multivector if it failed.

If an algebra $G$ has a commuting pseudoscalar squaring to $-1$, then there is a canonical map $G ⊗ ℂ ↦ G$ from the complexified algebra into itself given my sending the imaginary unit to the pseudoscalar.

source

Metric signatures

GeometricAlgebra.ClType
Cl(p, q=0, r=0)

Metric signature where p, q and r are the number of basis vectors of norm +1, -1 and 0, respectively.

Examples

julia> basis(Cl(1,3))
4-element Vector{BasisBlade{Cl(1,3), 1, Int64}}:
 1 v1
 1 v2
 1 v3
 1 v4

julia> ans .^ 2
4-element Vector{BasisBlade{Cl(1,3), 0, Int64}}:
  1
 -1
 -1
 -1
source
GeometricAlgebra.ClMethod
Cl(sig::String) -> Tuple

Shorthand for a tuple specifying a metric signature, e.g., Cl("-+++") === (-1, +1, +1, +1). String may contain '+', '-' and '0'.

For readability, AbstractMultivector types with a tuple metric signature display the signature as Cl("...").

Examples

julia> Cl("+++") # 3D Euclidean metric signature
(1, 1, 1)

julia> basis(ans)
3-element Vector{BasisBlade{Cl("+++"), 1, Int64}}:
 1 v1
 1 v2
 1 v3

julia> Multivector{(0,-1,1,1,1),2}
Multivector{Cl("0-+++"), 2} (pretty-printed Multivector{(0, -1, 1, 1, 1), 2})
source
GeometricAlgebra.canonical_signatureMethod
canonical_signature(sig)

Canonical tuple representation of a metric signature.

Examples

julia> Cl(1,3)
Cl(1,3) (pretty-printed Cl{1, 3, 0}())

julia> GeometricAlgebra.canonical_signature(ans)
(1, -1, -1, -1)
source
GeometricAlgebra.cayleytableMethod
cayleytable(sig, op=*)
cayleytable(objs, op=*)

Display a multivector multiplication table.

The first argument may be a metric signature or any vector of objects which can be combined with the binary operator op.

The keyword argument title sets the contents of the top-left cell.

Examples

julia> cayleytable(3)
 (↓) * (→) │    1 │   v1     v2    v3 │  v12    v13   v23 │ v123
───────────┼──────┼───────────────────┼───────────────────┼──────
         1 │    1 │   v1     v2    v3 │  v12    v13   v23 │ v123
───────────┼──────┼───────────────────┼───────────────────┼──────
        v1 │   v1 │    1    v12   v13 │   v2     v3  v123 │  v23
        v2 │   v2 │ -v12      1   v23 │  -v1  -v123    v3 │ -v13
        v3 │   v3 │ -v13   -v23     1 │ v123    -v1   -v2 │  v12
───────────┼──────┼───────────────────┼───────────────────┼──────
       v12 │  v12 │  -v2     v1  v123 │   -1   -v23   v13 │  -v3
       v13 │  v13 │  -v3  -v123    v1 │  v23     -1  -v12 │   v2
       v23 │  v23 │ v123    -v3    v2 │ -v13    v12    -1 │  -v1
───────────┼──────┼───────────────────┼───────────────────┼──────
      v123 │ v123 │  v23   -v13   v12 │  -v3     v2   -v1 │   -1

julia> cayleytable(basis((t=-1, x=1, y=1, z=1), 2), ∧)
 (↓) ∧ (→) │   tx     ty    xy    tz     xz    yz
───────────┼──────────────────────────────────────
        tx │    0      0     0     0      0  txyz
        ty │    0      0     0     0  -txyz     0
        xy │    0      0     0  txyz      0     0
        tz │    0      0  txyz     0      0     0
        xz │    0  -txyz     0     0      0     0
        yz │ txyz      0     0     0      0     0
source
GeometricAlgebra.componentstypeMethod
componentstype(sig, N) -> Type{<:AbstractVector}

The component array type for N-component multivectors with signature sig.

You can redefine this method to customise the default array type. The fallback method returns MVector{N} for N <= 16, and Vector otherwise.

source
GeometricAlgebra.ncomponentsMethod
ncomponents(sig) = 2^dimension(sig)
ncomponents(sig, k) = binomial(dimension(sig), k)

Dimension of (the grade-k subspace of) the geometric algebra of metric signature sig, viewed as a vector space.

If the dimension of the underlying vector space (see dimension) in $n$, then the algebra is $2^n$-dimensional, and its grade-$k$ subspace $\binom{n}{k}$-dimensional.

source
GeometricAlgebra.show_basis_bladeMethod
show_basis_blade(io, sig, indices::Vector{Int})

Show the basis blade $𝒗_{i₁}⋯𝒗_{iₖ}$ with each $iⱼ$ in indices in the geometric algebra defined by sig. Methods dispatching on sig should be added to customise basis blade labels for particular algebras.

Examples

julia> GeometricAlgebra.show_basis_blade(stdout, (1, 1, 1), [1, 3])
v13

julia> using GeometricAlgebra: subscript

julia> GeometricAlgebra.show_basis_blade(io, sig, indices) = print(io, join("𝒆".*subscript.(indices), "∧"))

julia> prod(basis(4))
BasisBlade{⟨++++⟩, 4, Int64} of grade 4:
 1 𝒆₁∧𝒆₂∧𝒆₃∧𝒆₄
source
GeometricAlgebra.show_signatureMethod
show_signature(io, sig)

Pretty-print the metric signature sig.

This is used to display the metric signature type parameter in AbstractMultivector subtypes to reduce visual noise. Methods may optionally be added for user-defined metric signatures, in a similar fashion to Base.show.

Examples

julia> sig = (+1,-1,-1,-1)
(1, -1, -1, -1)

julia> GeometricAlgebra.show_signature(stdout, sig)
Cl("+---")

julia> BasisBlade{sig}
BasisBlade{Cl("+---")} (pretty-printed BasisBlade{(1, -1, -1, -1)})
source
GeometricAlgebra.BASIS_DISPLAY_STYLESConstant
GeometricAlgebra.BASIS_DISPLAY_STYLES

A dictionary specifying the BasisDisplayStyle to use for each metric signature key.

The style for the key sig must have the same dimension as sig.

To use the default display style, remove the entry for sig with delete!(GeometricAlgebra.BASIS_DISPLAY_STYLES, sig) or remove all with empty!.

source
GeometricAlgebra.BasisDisplayStyleType
BasisDisplayStyle(dim, blades[, blade_order]; kwargs...)
BasisDisplayStyle(dim, blades_and_order; kwargs...)

Specifies how basis blades are displayed and ordered. The default style for multivectors of metric signature sig can be set with GeometricAlgebra.BASIS_DISPLAY_STYLES[sig] = style.

  • dim::Int is the dimension of the algebra (number of basis vectors).
  • blades::Dict{UInt,Vector{Int}} encodes the order of basis vectors in basis blades. E.g., 0b101 => [1, 3] is the default style.
  • blade_order::Dict{Int,Vector{UInt}} specifies the order of basis blades in a single grade. E.g., 3 => [0b011, 0b101, 0b110] is the default ordering.
  • blades_and_order::Dict{Int,Vector{Int}} gives a way of specifying the previous two mappings at once. E.g., 3 => [[1,2], [1,3], [2,3]].

Keyword arguments

  • indices=1:dim specifies the symbols used for each basis vector.
  • prefix="v" is the prefix string for basis blades (if sep == nothing) or for each basis vector.
  • sep=nothing is a string (e.g., "∧") to separate each basis vector in a blade. If sep is nothing, blades are shown as e.g., v123, whereas an empty string results in v1v2v3.
  • labels is a dictionary allowing individual basis blades to be given custom labels. E.g., [3,2] => "𝒊" means 4v32 is displayed as 4𝒊 (so long as the order 0b110 => [3,2] is also specified in the blades argument — otherwise it would display as the default -4v23).
Note

BasisDisplayStyle only affects how multivectors are displayed. The actual internal layout of multivectors is never affected. However, the active style for sig can affect the value of basis(sig).

Examples

julia> Multivector{Cl(0,3),2}([3, -2, 1])
3-component Multivector{Cl(0,3), 2, Vector{Int64}}:
  3 v12
 -2 v13
  1 v23

julia> cyclical_style = BasisDisplayStyle(
           3, Dict(2 => [[2,3], [3,1], [1,2]]);
           indices = "₁₂₃",
           prefix = "e",
           sep = "",
           labels = Dict([1,2,3] => "I"),
       );

julia> GeometricAlgebra.BASIS_DISPLAY_STYLES[Cl(0,3)] = cyclical_style;

julia> Multivector{Cl(0,3),2}([3, -2, 1])
3-component Multivector{Cl(0,3), 2, Vector{Int64}}:
 1 e₂e₃
 2 e₃e₁
 3 e₁e₂

julia> ans*rdual(ans) # pseudoscalar `e₁e₂e₃` displayed as `I`
8-component Multivector{Cl(0,3), 0:3, SVector{8, Int64}}:
 14 I

To recover the default style:

julia> delete!(GeometricAlgebra.BASIS_DISPLAY_STYLES, Cl(0,3))
IdDict{Any, BasisDisplayStyle}() 
source
GeometricAlgebra.basisFunction
basis(sig, k=1)

Vector of BasisBlades of specified grade(s) k for the geometric algebra defined by the metric signature sig. The value k=:all is a shortcut for 0:dimension(sig).

The particular basis blades returned by basis and their order reflects the signature’s BasisDisplayStyle. You can guarantee the default style by using

	BasisBlade{sig}.(1, componentbits(dimension(sig), k))

instead of basis(sig, k).

See also @basis.

Examples

julia> basis(3)
3-element Vector{BasisBlade{3, 1, Int64}}:
 1 v1
 1 v2
 1 v3

julia> basis("-+++", 0:2:4)
8-element Vector{BasisBlade{Cl("-+++"), _A, Int64} where _A}:
 1
 1 v12
 1 v13
 1 v23
 1 v14
 1 v24
 1 v34
 1 v1234

julia> basis(Cl(1,3), :all) |> sum
16-component Multivector{Cl(1,3), 0:4, MVector{16, Int64}}:
 1
 1 v1 + 1 v2 + 1 v3 + 1 v4
 1 v12 + 1 v13 + 1 v23 + 1 v14 + 1 v24 + 1 v34
 1 v123 + 1 v124 + 1 v134 + 1 v234
 1 v1234
source
GeometricAlgebra.basisMethod
basis(sig, k, i::Integer)

The ith basis blade of grade(s) k in the geometric algebra of signature sig.

If k is a collection, indexing is done in the canonical order, with lower grades first (see componentbits).

source
GeometricAlgebra.basisMethod
basis(::Type{<:Multivector})

Create a generator which iterates over basis elements of the given multivector type.

Examples

julia> basis(Multivector{3,1}) |> collect
3-element Vector{Multivector{3, 1, SVector{3, Int64}}}:
 v1
 v2
 v3

julia> basis(Multivector{2,0:2,Vector{Bool}}) |> collect
4-element Vector{Multivector{2, 0:2, Vector{Bool}}}:
 (1)
 (v1)
 (v2)
 (v12)
source
GeometricAlgebra.@basisMacro
@basis sig grades=:all scalar=false pseudoscalar=:I allperms=false prefix=nothing

Populate namespace with basis blades for the geometric algebra defined by metric signature sig.

Variable names are generated with show_basis_blade().

Keyword arguments

  • grades: which grades to define basis blades for (default :all).
  • scalar: whether to include the unit scalar blade (e.g., v).
  • pseudoscalar: alias for unit pseudoscalar (default :I). pseudoscalar=nothing defines no alias.
  • allperms: include all permutations of each basis blade (e.g., define v21 as well as v12).
  • prefix: prefix for basis blades names (nothing leaves default names unchanged).
Warning

This defines 2^dimension(sig) variables with grades=:all, and more with allperms=true!

Examples

julia> @basis 3
[ Info: Defined basis blades v1, v2, v3, v12, v13, v23, v123, I in Main

julia> 1v2 + 3v12
8-component Multivector{3, 0:3, SVector{8, Int64}}:
 1 v2
 3 v12

julia> @basis "0++" prefix=:e
[ Info: Defined basis blades e1, e2, e3, e12, e13, e23, e123, I in Main

julia> @basis 2 allperms=true scalar=true pseudoscalar=nothing
[ Info: Defined basis blades v, v1, v2, v12, v21 in Main

julia> @basis (t=1,x=-1,y=-1,z=-1) grades=2 allperms=true
[ Info: Defined basis blades tx, xt, ty, yt, xy, yx, tz, zt, xz, zx, yz, zy in Main
source

Multivector promotion

GeometricAlgebra.signature_convertMethod
signature_convert(::Val{Sig}, a::AbstractMultivector{Sig′}) -> AbstractMultivector{Sig}

Convert a multivector to a different metric signature.

If it makes sense for multivectors of specific distinct signatures to be interoperable, this method should be defined along with a signature promotion rule.

See also signature_promote_rule.

Example

signature_convert(::Val{CGA{Sig}}, a::AbstractMultivector{Sig}) where Sig = embed(CGA{Sig}, a)
source
GeometricAlgebra.signature_promote_ruleFunction
signature_promote_rule(Val(Sig1), Val(Sig2)) -> Sig

Define a promotion rule for multivector signatures.

This works in much the same way as Base.promote_rule, except that this does not operate on the full types, but only on the metric signature parameter of AbstractMultivector.

Operations between multivectors of different signatures is not defined unless there is an applicable method of signature_promote_rule defining the common signature to convert arguments to. Signatures must be wrapped in Val{}, not Type{}, because signatures are allowed to be isbits values as well as types.

To convert multivectors between signatures, there must be a corresponding method signature_convert(::Val{Sig}, a).

See also signature_convert.

Example

signature_promote_rule(::Val{CGA{Sig}}, ::Val{Sig}) where Sig = CGA{Sig}
source

Logic for bits and grades

GeometricAlgebra.bits_of_gradeMethod
bits_of_grade(k[, dim])

Generate basis blade bits of grade k in ascending order. Yields all basis blades in the dimension dim, if given, otherwise iterates indefinitely.

Examples

julia> GeometricAlgebra.bits_of_grade(2, 4) .|> UInt8 .|> bitstring
6-element Vector{String}:
 "00000011"
 "00000101"
 "00000110"
 "00001001"
 "00001010"
 "00001100"
source
GeometricAlgebra.bits_to_indicesMethod
bits_to_indices(bits)

Return the positions of the ones in the unsigned integer bits.

Used to convert between representations of a unit basis blade. Inverse of indices_to_bits.

Examples

julia> GeometricAlgebra.bits_to_indices(0b1001101)
4-element Vector{Int64}:
 1
 3
 4
 7
source
GeometricAlgebra.componentbitsMethod
componentbits(n, k)
componentbits(::Val{N}, ::Val{K})

Vector of bits corresponding to components of an n-dimensional Multivector of grade(s) k.

Bits are ordered first by grade (count_ones), then lexicographically (in ascending numerical order).

Passing Val arguments calls a faster, memoized method.

Examples

julia> componentbits(4, 2) .|> UInt8 .|> bitstring
6-element Vector{String}:
 "00000011"
 "00000101"
 "00000110"
 "00001001"
 "00001010"
 "00001100"

julia> componentbits(3, 0:3) .|> UInt8 .|> bitstring
8-element Vector{String}:
 "00000000"
 "00000001"
 "00000010"
 "00000100"
 "00000011"
 "00000101"
 "00000110"
 "00000111"
source
GeometricAlgebra.indices_to_bitsFunction
indices_to_bits(indices, T=UInt)

Create unsigned integer with bits at the positions given in the vector indices.

Used to convert between representations of a unit basis blade. Inverse of bits_to_indices.

Warning

Only correct if maximum(indices) does not exceed number of bits in T.

Examples

julia> GeometricAlgebra.indices_to_bits([1, 2, 5], UInt8) |> bitstring
"00010011"
source
GeometricAlgebra.sign_from_swapsMethod
sign_from_swaps(a::Unsigned, b::Unsigned)

Compute sign flips of blade product due to transposing basis vectors into sorted order. (The full sign of the product will also depend on the basis norms.)

source
Base.getindexMethod
a[k]
getindex(a::Multivector, k)

Get the grade(s) k part of a multivector a if k ⊆ grade(a). The components of the resulting Multivector are a view into the components of a, so modifying a[k].comps changes a.

source
GeometricAlgebra.componentindicesMethod
componentindices(a, k)

Indices of the components of grade(s) k in multivector a. Throws an error if k ∉ grade(a).

The grade k may be an integer (returning a range) or a collection of grades (returning a vector of indices).

source
GeometricAlgebra.gradeMethod
grade(::AbstractMultivector{Sig}, k) -> Multivector{Sig,k}

Construct a Multivector{Sig,k} from the grade k parts of a blade or multivector. Multiple grades may be specified with a range or tuple.

The operators + and - may be used as shortcuts for the even and odd parts, respectively.

If the return type must be inferable, use grade(a, Val(k)).

Examples

julia> grade(BasisBlade{3}(42, 0b101), 2)
3-component Multivector{3, 2, SVector{3, Int64}}:
  0 v12
 42 v13
  0 v23

julia> a = Multivector{3, 0:3}(1:8);

julia> grade(a, 1)
3-component Multivector{3, 1, UnitRange{Int64}}:
 2 v1
 3 v2
 4 v3

julia> grade(a, 0:3:3)
2-component Multivector{3, 0:3:3, SVector{2, Int64}}:
 1
 8 v123

julia> grade(a, +) # only even grades
4-component Multivector{3, 0:2:2, SVector{4, Int64}}:
 1
 5 v12 + 6 v13 + 7 v23
source
GeometricAlgebra.promote_gradesMethod
promote_grades(dim, k)

Canonicalize the grade type parameter k.

Returns a subset of 0:dim, while attempting to normalize equivalent representations, such as 0:1:3 => 0:3 or (3, 0) => (0, 3).

source
GeometricAlgebra.promote_gradesMethod
promote_grades(dim, p, q, ...)

Return a suitable grade type parameter which contains the grades p ∪ q ∪ ....

In order to reduce the number of possible type parameters, the result may be larger than the exact union. Specifically, when combining different grades, promote_grades will try to return the narrowest grade(s) out of:

  • an integer k ∈ 0:dim for homogeneous elements (fewest components)
  • 0:dim:dim, for elements in the scalar-pseudoscalar subalgebra
  • 0:2:dim, for elements in the even subalgebra
  • 0:dim, for general inhomogeneous elements (most components)

Examples

julia> promote_grades(4, 0:4, 2, 7)
0:4

julia> promote_grades(4, 0, 2) # even multivectors are worth representing specifically
0:2:4

julia> promote_grades(4, 0, 3) # not worth having a specific type for grades (0, 3) in 4 dims
0:4
source
GeometricAlgebra.resulting_gradesMethod
resulting_grades(combine, dim, p, q)

Non-zero grade(s) resulting from the application of combine on dim-dimensional multivectors of grade(s) p and q.

source

Display methods

GeometricAlgebra.show_bladeMethod

Display blade with parentheses surrounding coefficient if necessary.

Example

julia> GeometricAlgebra.show_blade(stdout, BasisBlade{(x=1,)}(1 + im, 0b1))
(1 + 1im) x
source
GeometricAlgebra.show_multivectorMethod
show_multivector(io, a; kwargs...)

Display multivector components in a column or inline, optionally grouping by grade.

Keyword arguments

  • inline::Bool: print on one line (default true).
  • groupgrades::Bool: visually group components by grade (default true). If inline, prints parentheses around parts of each grade; if multiline, prints each grade on its own line.
  • showzeros::Bool: whether to omit zero components from display.
  • eps::Real: supprxess components with a magnitude smaller than a threshold (default 0).
  • indent::Integer: indentation width.
  • parseable::Bool: use parseable style (used by repr) instead of human-readable style.
  • compact::Bool: omit unnecessary spaces, coefficients of unity, etc (default: false).
  • basis_display_style::BasisDisplayStyle: style to use to print basis blades.

Examples

julia> a = Multivector{2,0:2}((1:4) .^ 2);

julia> GeometricAlgebra.show_multivector(stdout, a; inline=false, groupgrades=false)
 1
 4 v1
 9 v2
16 v12

julia> GeometricAlgebra.show_multivector(stdout, a; inline=false, groupgrades=true)
1
4 v1 + 9 v2
16 v12

julia> GeometricAlgebra.show_multivector(stdout, a; inline=true, groupgrades=true)
(1) + (4 v1 + 9 v2) + (16 v12)

julia> GeometricAlgebra.show_multivector(stdout, a; inline=true, groupgrades=false)
1 + 4 v1 + 9 v2 + 16 v12

julia> GeometricAlgebra.show_multivector(stdout, a; parseable=true)
Multivector{2, 0:2}([1, 4, 9, 16])
source

Code generation

GeometricAlgebra.MultivectorMethod
Multivector{Sig,K}(sym::Symbol)

Multivector with independent symbolic components.

See also make_symbolic.

Example

julia> a = Multivector{3,1}(:a)
3-component Multivector{3, 1, Vector{ProductNode{Expr}}}:
 a[1] v1
 a[2] v2
 a[3] v3

julia> a ⊙ a
SumNode{Expr, Int64}:
 a[1] ^ 2 + a[2] ^ 2 + a[3] ^ 2
source
GeometricAlgebra.make_symbolicMethod
make_symbolic(a, label)

Multivector with symbolic components of the same type as the Multivector instance or type a.

See also MiniCAS.variables.

Example

julia> GeometricAlgebra.make_symbolic(Multivector{3,1}, :A)
3-component Multivector{3, 1, Vector{ProductNode{Expr}}}:
 A[1] v1
 A[2] v2
 A[3] v3
source
GeometricAlgebra.symbolic_multivector_evalMethod
symbolic_multivector_eval(sig::Val, f::Function, args...)

Evaluate f(args...) using symbolically optimised code for operations on Multivectors.

This is a generated function which first evaluates f on symbolic versions of the multivector arguments make_symbolic.(args) and then converts the symbolic result into unrolled code.

If the result is a Multivector, it is given the metric signature sig.

Calling symbolic_multivector_eval(Expr, sig, f, args...) with Expr as the first argument returns the expression to be compiled.

See also @symbolic_optim.

Example

julia> A, B = randn(Multivector{3,0:3}, 2)

julia> symbolic_multivector_eval(Expr, Val(2), geometric_prod, A, B)
:(let a = (Multivector(args[1])).comps, b = (Multivector(args[2])).comps
      Multivector{2, 0:2}(
          a[1] * b[1] + -1 * (b[4] * a[4]) + b[2] * a[2] + b[3] * a[3],
          b[3] * a[4] + b[1] * a[2] + -1 * (b[4] * a[3]) + a[1] * b[2],
          -1 * (a[4] * b[2]) + b[4] * a[2] + b[3] * a[1] + b[1] * a[3],
          b[3] * a[2] + a[4] * b[1] + -1 * (b[2] * a[3]) + b[4] * a[1],
      )
  end)

julia> @btime symbolic_multivector_eval(Val(2), geometric_prod, A, B);
  19.684 ns (2 allocations: 64 bytes)

julia> @btime geometric_prod(Val(:nosym), A, B); # opt-out of symbolic optim
  7.312 μs (125 allocations: 4.67 KiB)
source
GeometricAlgebra.symbolic_optimMethod
symbolic_optim(f, args...)

Evaluate f(args...) by invoking the generated function symbolic_multivector_eval.

Because of the rules of generated functions, symbolic_multivector_eval must not call methods that may be later (re)defined. However, we still want the methods

  • dimension(sig)
  • basis_vector_square(sig, i)
  • componentstype(sig)

to work for user-defined signature types, as part of the “metric signature interface”. Since these methods may be defined in a newer world-age than symbolic_multivector_eval, we must move calls to such methods outside the generated function.

To do this, the metric signatures in args are replaced with the equivalent canonical tuple signature. (We assume that dimension(::Tuple), etc, are core functionality that won’t be modified by the user.)

Warning

If f(args...) is a Multivector, its signature is assumed to be identical to the signature of the first AbstractMultivector argument in args. (The actual signature is lost because signatures are converted to canonical tuples.)

source
GeometricAlgebra.use_symbolic_optimMethod
use_symbolic_optim(sig) -> Bool

Whether to use symbolic optimization in algebras of metric signature sig.

By default, this is enabled if dimension(sig) ≤ 8 (in many dimensions, algebraic expressions may become too unwieldy).

source
GeometricAlgebra.@symbolic_optimMacro
@symbolic_optim <method definition>

Convert a single method definition f(args...) into two methods:

  1. The original method f(Val(:nosym), args...), called with Val(:nosym) as the first argument. This calls the original method, without any symbolic optimization.
  2. An optimized method f(args...) which calls symbolic_multivector_eval. Code for this method is generated by calling f(Val(:nosym), args...) with symbolic versions of the Multivector arguments.

This is to reduce boilerplate when writing symbolically optimized versions of each method. It only makes sense for methods with at least one AbstractMultivector argument for which the exact return type is inferable.

Example

# This macro call...
@symbolic_optim foo(a, b) = (a + b)^2
# ...is equivalent to the following two method definitions:

foo(::Val{:nosym}, a, b) = (a + b) ^ 2

function foo(a, b)
    if use_symbolic_optim(foo, a, b)
        symbolic_optim(foo, Val(:nosym), a, b)
    else
        foo(Val(:nosym), a, b)
    end
end
source
GeometricAlgebra.@symbolicgaMacro
@symbolicga sig mv_grades expr [result_type]

Evaluate a symbolically optimised geometric algebra expression.

Upon macro expansion, expr is evaluated with symbolic multivectors (specified by mv_grades) in the algebra defined by metric signature sig. The resulting symbolic expression is then compiled and executed at runtime.

The mv_grades argument is a NamedTuple where keys(mv_grades) defines the identifiers in expr to be interpreted as Multivectors, while values(mv_grades) defines their respective grades. The identifiers must exist at runtime, and can be a Multivector with matching signature/grade or any iterable with the correct number of components.

If result_type is given, then the components of the resulting multivector are converted to that type. The result type T should implement T(::Tuple), e.g., Tuple or MVector.

Warning

Operations that are not amenable to symbolic evaluation (such as exp, log, sqrt, etc) are not supported.

(You may test if operations work on symbolic multivectors created with GeometricAlgebra.make_symbolic.)

Examples

julia> v = (1, 2, 0); R = exp(Multivector{3,2}([0, π/8, 0]));

julia> # Rotate a tuple (interpreted as a grade 1 vector)
       # by a rotor, returning a tuple.
       @symbolicga 3 (v=1, R=0:2:4) grade(R*v*~R, 1) Tuple
(0.7071067811865475, 2.0, -0.7071067811865476)
# This macro call...
@symbolicga 3 (a=1, b=1) wedge(a, b)
# ...is equivalent to the following:
let a = Multivector{3, 1}(a).comps, b = Multivector{3, 1}(b).comps
    Multivector{3, 2}(
        a[1]*b[2] - a[2]*b[1],
        a[1]*b[3] - a[3]*b[1],
        a[2]*b[3] - a[3]*b[2],
    )
end
source

Symbolic utilities

GeometricAlgebra.MiniCAS.variableFunction
variable(label::Symbol)
variables(label::Symbol, dims::Integer...)

A symbolic real value or array of symbolic components.

Example

julia> variables(:a, 2, 2)
2×2 Matrix{ProductNode{Expr}}:
 a[1, 1]  a[1, 2]
 a[2, 1]  a[2, 2]

julia> prod(ans) + variable(:b)
SumNode{Any, Int64}:
 a[1, 1] * a[1, 2] * a[2, 1] * a[2, 2] + b
source
GeometricAlgebra.MiniCAS.variablesFunction
variable(label::Symbol)
variables(label::Symbol, dims::Integer...)

A symbolic real value or array of symbolic components.

Example

julia> variables(:a, 2, 2)
2×2 Matrix{ProductNode{Expr}}:
 a[1, 1]  a[1, 2]
 a[2, 1]  a[2, 2]

julia> prod(ans) + variable(:b)
SumNode{Any, Int64}:
 a[1, 1] * a[1, 2] * a[2, 1] * a[2, 2] + b
source
GeometricAlgebra.MiniCAS.factorMethod
factor(x::SumNode)

Naively collect factors that are common to all terms in x. For example, x*y + x*z becomes x*(y + z), but x^2 + 2x + 1 is left as is.

source
GeometricAlgebra.MiniCAS.SubexprListType
SubexprList <: AbstractDict{SubexprPointer,Expr}

Represents a directed acyclic graph of expressions as an ordered list of definitions. The last entry defines the full expression in terms of preceding subexpressions. Subexpressions are referenced with a SubexprPointer, which are the keys of the underlying OrderedDict and are pretty printed as Greek letters.

See also subexprs.

Examples

julia> subexprs(:(A + f(A) + g(f(A))))
SubexprList with 3 entries:
  α => :(f(A))
  β => :(g(α))
  γ => :(A + α + β)
source
GeometricAlgebra.MiniCAS.squashFunction
squash(::SubexprList, maxcount=1)::SubexprList

Eliminate subexpressions which are only referenced up to maxcount times substituting their definitions into subsequent expressions.

Example

julia> subexprs(:(A + f(A) + g(f(A))^2))
SubexprList with 4 entries:
  α => :(f(A))
  β => :(g(α))
  γ => :(β ^ 2)
  δ => :(A + α + γ)

julia> squash(ans, 1)
ERROR: UndefVarError: `squash` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] top-level scope
   @ none:1

julia> squash(ans, 2)
ERROR: UndefVarError: `squash` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] top-level scope
   @ none:1
source
GeometricAlgebra.MiniCAS.subexprsMethod
subexprs(::Expr)::SubexprList

Flatten an expression tree into a list of atomic expressions so that common subexpressions are identified.

See also squash.

Example

julia> subexprs(:(A + f(A) + g(f(A))))
SubexprList with 3 entries:
  α => :(f(A))
  β => :(g(α))
  γ => :(A + α + β)

julia> toexpr(ans, pretty=true)
:(let α = f(A), β = g(α)
      A + α + β
  end)
source
GeometricAlgebra.MiniCAS.toexprMethod
toexpr(::SubexprList; pretty=false)

Render a subexpression list as a let ... end expression.

Example

julia> toexpr(subexprs(:(x^2 + f(x^2))), pretty=true)
:(let α = x ^ 2, β = f(α)
      α + β
  end)
source

Conformal geometric algebra

GeometricAlgebra.ConformalModule

Conformal geometric algebra

Tools for working with conformal geometric algebra.

The algebra CGA{Sig} is an extension of the base space Sig with two additional dimensions, vp^2 = +1 and vm^2 = -1. Points in the base space p::Multivector{Sig,a} are associated to null vectors in the higher space by

up(x) = o + x + x^2/2*oo

where o = origin(CGA{Sig}) is the null vector representing the origin and oo = origin(CGA{Sig}) represents the point at infinity.

Conformal geometric algebra has covariant representations of points, point-pairs, lines, circles, spheres, and other geometric primitives.

source
GeometricAlgebra.Conformal.CGAType

Metric signature for the conformal geometric algebra over a base space with metric signature $Sig$. A conformal algebra CGA{Sig} has dimension dimension(Sig) + 2, with the two extra basis vectors squaring to $+1$ and $-1$, respectively.

source
GeometricAlgebra.Conformal.CGABladeType
CGABlade{Sig,K}:
	DirectionBlade{Sig,K}(E)
	FlatBlade{Sig,K}(E, p)
	DualFlatBlade{Sig,K}(E, p)
	RoundBlade{Sig,K}(E, p, r2)

Standard forms of blades in the conformal geometric algebra CGA{Sig} over base space Sig.

ValueMathematical form
DirectionBlade(E)$E ∧ n_∞$
FlatBlade(E, p)$𝚃ₚ[n₀ ∧ E ∧ n_∞]$
DualFlatBlade(E, p)$𝚃ₚ[E]$
RoundBlade(E, p, r2)$𝚃ₚ[(n₀ + r2/2 n_∞) ∧ E]$

Any blade in CGA{Sig} is of exactly one of the forms above, where:

  • $E$ is a K-blade in the base space
  • $p$ is a position vector in the base space
  • $r2$ is a square-radius, which may be positive or negative
  • $n₀$ and $n_∞$ are the points at the origin and at infinity
  • $Tₚ$ is the translation operator sending $n₀$ to $p$

The method standardform classifies any blade in CGA{Sig} to one of these forms. A standard blade X::CGABlade may be converted back to the usual additive form with Multivector(X).

See table 14.1 of [1] for discussion.

source
GeometricAlgebra.Conformal.DirectionBladeType
CGABlade{Sig,K}:
	DirectionBlade{Sig,K}(E)
	FlatBlade{Sig,K}(E, p)
	DualFlatBlade{Sig,K}(E, p)
	RoundBlade{Sig,K}(E, p, r2)

Standard forms of blades in the conformal geometric algebra CGA{Sig} over base space Sig.

ValueMathematical form
DirectionBlade(E)$E ∧ n_∞$
FlatBlade(E, p)$𝚃ₚ[n₀ ∧ E ∧ n_∞]$
DualFlatBlade(E, p)$𝚃ₚ[E]$
RoundBlade(E, p, r2)$𝚃ₚ[(n₀ + r2/2 n_∞) ∧ E]$

Any blade in CGA{Sig} is of exactly one of the forms above, where:

  • $E$ is a K-blade in the base space
  • $p$ is a position vector in the base space
  • $r2$ is a square-radius, which may be positive or negative
  • $n₀$ and $n_∞$ are the points at the origin and at infinity
  • $Tₚ$ is the translation operator sending $n₀$ to $p$

The method standardform classifies any blade in CGA{Sig} to one of these forms. A standard blade X::CGABlade may be converted back to the usual additive form with Multivector(X).

See table 14.1 of [1] for discussion.

source
GeometricAlgebra.Conformal.DualFlatBladeType
CGABlade{Sig,K}:
	DirectionBlade{Sig,K}(E)
	FlatBlade{Sig,K}(E, p)
	DualFlatBlade{Sig,K}(E, p)
	RoundBlade{Sig,K}(E, p, r2)

Standard forms of blades in the conformal geometric algebra CGA{Sig} over base space Sig.

ValueMathematical form
DirectionBlade(E)$E ∧ n_∞$
FlatBlade(E, p)$𝚃ₚ[n₀ ∧ E ∧ n_∞]$
DualFlatBlade(E, p)$𝚃ₚ[E]$
RoundBlade(E, p, r2)$𝚃ₚ[(n₀ + r2/2 n_∞) ∧ E]$

Any blade in CGA{Sig} is of exactly one of the forms above, where:

  • $E$ is a K-blade in the base space
  • $p$ is a position vector in the base space
  • $r2$ is a square-radius, which may be positive or negative
  • $n₀$ and $n_∞$ are the points at the origin and at infinity
  • $Tₚ$ is the translation operator sending $n₀$ to $p$

The method standardform classifies any blade in CGA{Sig} to one of these forms. A standard blade X::CGABlade may be converted back to the usual additive form with Multivector(X).

See table 14.1 of [1] for discussion.

source
GeometricAlgebra.Conformal.FlatBladeType
CGABlade{Sig,K}:
	DirectionBlade{Sig,K}(E)
	FlatBlade{Sig,K}(E, p)
	DualFlatBlade{Sig,K}(E, p)
	RoundBlade{Sig,K}(E, p, r2)

Standard forms of blades in the conformal geometric algebra CGA{Sig} over base space Sig.

ValueMathematical form
DirectionBlade(E)$E ∧ n_∞$
FlatBlade(E, p)$𝚃ₚ[n₀ ∧ E ∧ n_∞]$
DualFlatBlade(E, p)$𝚃ₚ[E]$
RoundBlade(E, p, r2)$𝚃ₚ[(n₀ + r2/2 n_∞) ∧ E]$

Any blade in CGA{Sig} is of exactly one of the forms above, where:

  • $E$ is a K-blade in the base space
  • $p$ is a position vector in the base space
  • $r2$ is a square-radius, which may be positive or negative
  • $n₀$ and $n_∞$ are the points at the origin and at infinity
  • $Tₚ$ is the translation operator sending $n₀$ to $p$

The method standardform classifies any blade in CGA{Sig} to one of these forms. A standard blade X::CGABlade may be converted back to the usual additive form with Multivector(X).

See table 14.1 of [1] for discussion.

source
GeometricAlgebra.Conformal.FlatGeometryType
FlatGeometry{Sig,K}(p, E) <: CGAGeometry{Sig}

A K-flat in the base space Sig through the point p::Multivector{Sig,1} spanning the K-blade E::Multivector{Sig,K}.

A 0-flat is a point, a 1-flat is a line, a 2-flat is a plane, etc. All flats include the unique point at infinity.

See also RoundGeometry and CGAGeometry.

source
GeometricAlgebra.Conformal.RoundBladeType
CGABlade{Sig,K}:
	DirectionBlade{Sig,K}(E)
	FlatBlade{Sig,K}(E, p)
	DualFlatBlade{Sig,K}(E, p)
	RoundBlade{Sig,K}(E, p, r2)

Standard forms of blades in the conformal geometric algebra CGA{Sig} over base space Sig.

ValueMathematical form
DirectionBlade(E)$E ∧ n_∞$
FlatBlade(E, p)$𝚃ₚ[n₀ ∧ E ∧ n_∞]$
DualFlatBlade(E, p)$𝚃ₚ[E]$
RoundBlade(E, p, r2)$𝚃ₚ[(n₀ + r2/2 n_∞) ∧ E]$

Any blade in CGA{Sig} is of exactly one of the forms above, where:

  • $E$ is a K-blade in the base space
  • $p$ is a position vector in the base space
  • $r2$ is a square-radius, which may be positive or negative
  • $n₀$ and $n_∞$ are the points at the origin and at infinity
  • $Tₚ$ is the translation operator sending $n₀$ to $p$

The method standardform classifies any blade in CGA{Sig} to one of these forms. A standard blade X::CGABlade may be converted back to the usual additive form with Multivector(X).

See table 14.1 of [1] for discussion.

source
GeometricAlgebra.Conformal.RoundGeometryType
RoundGeometry{Sig,K}(p, E, r2) <: CGAGeometry{Sig}

A K-round in the base space Sig around the point p::Multivector{Sig,1} spanning the K-blade E::Multivector{Sig,K} with square radius r2.

A 0-round is a point, a 1-round is a point pair, a 2-round is a circle, a 3-round is a sphere, etc. No rounds include the point at infinity.

Note

The square radius r2 may be negative, in which case the round is formallythe empty set, but one may also interpret this as an "imaginary" radius.

See also FlatGeometry and CGAGeometry.

source
GeometricAlgebra.Conformal.dnFunction
up(::Multivector{Sig,1})::Multivector{CGA{Sig},1}
dn(::Multivector{CGA{Sig},1})::Multivector{Sig,1}

"Lift up" a 1-vector in a base space Sig to a null vector in the 2d-up conformal algebra CGA{Sig}, or "project down" a conformal 1-vector back into the base space.

The up map is given by

\[up(x) = o + embed(x) + 1/2 x^2 oo\]

where o = origin(CGA{Sig}) and oo = infinity(CGA{Sig}) are the points representing the origin and infinity.

For any vector u we have dn(up(u)) == n and up∘dn is idempotent.

source
GeometricAlgebra.Conformal.infinityFunction
nullbasis(n) = (origin(n), infinity(n))
origin(n)
infinity(n)

Standard null basis vectors in the conformal geometric algebra CGA{n}.

The point at the origin $e₀$ and the point at infinity $e∞$ in the n-dimensional conformal geometric algebra model are defined as $e₀ = (e₊ + e₋)/2$ and $e∞ = e₋ - e₊$ where $e₊$ and $e₋$ are the standard extra basis vectors squaring to $+1$ and $-1$.

Type-stable methods exist which accept the type CGA{n} instead of an integer n.

source
GeometricAlgebra.Conformal.ipnsFunction
ipns(A) -> CGAGeometry
opns(A) -> CGAGeometry

Inner or outer product null space of the blade A.

This is the set of points $x$ satisfying up(x)⋅A ≈ 0 (IPNS) or up(x)∧A ≈ 0 (OPNS), possibly including the point at infinity.

source
GeometricAlgebra.Conformal.nullbasisFunction
nullbasis(n) = (origin(n), infinity(n))
origin(n)
infinity(n)

Standard null basis vectors in the conformal geometric algebra CGA{n}.

The point at the origin $e₀$ and the point at infinity $e∞$ in the n-dimensional conformal geometric algebra model are defined as $e₀ = (e₊ + e₋)/2$ and $e∞ = e₋ - e₊$ where $e₊$ and $e₋$ are the standard extra basis vectors squaring to $+1$ and $-1$.

Type-stable methods exist which accept the type CGA{n} instead of an integer n.

source
GeometricAlgebra.Conformal.opnsFunction
ipns(A) -> CGAGeometry
opns(A) -> CGAGeometry

Inner or outer product null space of the blade A.

This is the set of points $x$ satisfying up(x)⋅A ≈ 0 (IPNS) or up(x)∧A ≈ 0 (OPNS), possibly including the point at infinity.

source
GeometricAlgebra.Conformal.originFunction
nullbasis(n) = (origin(n), infinity(n))
origin(n)
infinity(n)

Standard null basis vectors in the conformal geometric algebra CGA{n}.

The point at the origin $e₀$ and the point at infinity $e∞$ in the n-dimensional conformal geometric algebra model are defined as $e₀ = (e₊ + e₋)/2$ and $e∞ = e₋ - e₊$ where $e₊$ and $e₋$ are the standard extra basis vectors squaring to $+1$ and $-1$.

Type-stable methods exist which accept the type CGA{n} instead of an integer n.

source
GeometricAlgebra.Conformal.translateMethod
translate(p)
translate(p, X) -> X′ = sandwich_prod(translate(p), X)

Translate X::Multivector{CGA{Sig}} by the displacement vector p::Multivector{Sig,1}.

The single-argument method returns the translation rotor and the two-argument form applies the rotor to X with sandwich_prod.

The translation rotor is defined as $𝚃ₚ = \exp(½ n_∞ ∧ p)$ where $n_∞$ is the point at infinity.

Examples

julia> (p, x), noo = randn(Multivector{3,1}, 2), infinity(3);

julia> translate(p, up(x)) ≈ up(x + p)
true

julia> translate(p, noo) ≈ noo
true
source
GeometricAlgebra.Conformal.upFunction
up(::Multivector{Sig,1})::Multivector{CGA{Sig},1}
dn(::Multivector{CGA{Sig},1})::Multivector{Sig,1}

"Lift up" a 1-vector in a base space Sig to a null vector in the 2d-up conformal algebra CGA{Sig}, or "project down" a conformal 1-vector back into the base space.

The up map is given by

\[up(x) = o + embed(x) + 1/2 x^2 oo\]

where o = origin(CGA{Sig}) and oo = infinity(CGA{Sig}) are the points representing the origin and infinity.

For any vector u we have dn(up(u)) == n and up∘dn is idempotent.

source

Utilities

  • 1Fontijne, D., & Dorst, L. (2010). Efficient Algorithms for Factorization and Join of Blades. In E. Bayro-Corrochano & G. Scheuermann (Eds.), Geometric Algebra Computing (pp. 457–476). Springer London. https://doi.org/10.1007/978-1-84996-108-0_21
  • 1"Algorithmic Computation of Multivector Inverses and Characteristic Polynomials in Non-degenerate Clifford Algebras", [4].
  • 1Dorst, L., Fontijne, D., & Mann, S. (2010). Geometric Algebra for Computer Science: An Object-Oriented Approach to Geometry. Elsevier.
  • 1Dorst, L., Fontijne, D., & Mann, S. (2010). Geometric Algebra for Computer Science: An Object-Oriented Approach to Geometry. Elsevier.
  • 1Dorst, L., Fontijne, D., & Mann, S. (2010). Geometric Algebra for Computer Science: An Object-Oriented Approach to Geometry. Elsevier.
  • 1Dorst, L., Fontijne, D., & Mann, S. (2010). Geometric Algebra for Computer Science: An Object-Oriented Approach to Geometry. Elsevier.
  • 1Dorst, L., Fontijne, D., & Mann, S. (2010). Geometric Algebra for Computer Science: An Object-Oriented Approach to Geometry. Elsevier.