Docstrings
Multivector types
GeometricAlgebra.Grade — Type
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 v123sourceGeometricAlgebra.AbstractMultivector — Type
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.
GeometricAlgebra.BasisBlade — Type
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.
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 withsignature().K::Int: Grade of the blade, equal tocount_ones(bits), retrieved withgrade().T: Numerical type of the scalar coefficient, retrieved witheltype().
GeometricAlgebra.BasisBlade — Method
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 v23sourceGeometricAlgebra.Multivector — Type
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 withsignature().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 ofAbstractVector.
GeometricAlgebra.Multivector — Method
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 v3sourceGeometricAlgebra.componentindex — Method
componentindex(a::Multivector, b::Union{Unsigned,BasisBlade})Index of the component of a.comps which corresponds to the basis blade b.
GeometricAlgebra.dimension — Method
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).
GeometricAlgebra.grade — Method
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.
GeometricAlgebra.isblade — Function
GeometricAlgebra.ishomogeneous — Method
GeometricAlgebra.isscalar — Method
isscalar(a)Whether the only non-zero part of a multivector is its scalar part; a == scalar(a).
GeometricAlgebra.ncomponents — Method
ncomponents(::Multivector)Number of independent components of a multivector instance (or type).
sourceGeometricAlgebra.resulting_multivector_type — Method
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.
GeometricAlgebra.scalar — Method
GeometricAlgebra.signature — Method
signature(::AbstractMultivector{Sig}) = SigThe metric signature type parameter of the multivector instance (or type).
sourceGeometricAlgebra.squashgrades — Method
squashgrades(a::Multivector{Sig,K})Drop the grades of a multivector which are zero and which result in a simpler grade parameter K (as returned by promote_grades).
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.
Base.permutedims — Method
GeometricAlgebra.:'ᶜ — Method
a'ᶜ
clifford_conj(a)Clifford conjugate of a multivector.
Equivalent to reversion(involution(a)).
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.
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).
sourceGeometricAlgebra.:⊙ — Method
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.
GeometricAlgebra.:⨼ — Method
a ⨼ b
lcontract(a, b)Left contraction of multivectors.
Equivalent to graded_prod((p, q) -> q - p, a, b). If a and b are of grades $p$ and $q$ respectively, then a ⨼ b is defined as the grade $q - p$ part of a*b.
GeometricAlgebra.:⨽ — Method
a ⨽ b
rcontract(a, b)Right contraction of multivectors.
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.
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.
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.)
GeometricAlgebra.antiwedge — 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).
sourceGeometricAlgebra.clifford_conj — Method
a'ᶜ
clifford_conj(a)Clifford conjugate of a multivector.
Equivalent to reversion(involution(a)).
GeometricAlgebra.embed — Method
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 v2sourceGeometricAlgebra.flipdual — Function
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.
GeometricAlgebra.geometric_prod — Method
GeometricAlgebra.graded_multiply — Method
GeometricAlgebra.graded_prod — Method
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)sourceGeometricAlgebra.hodgedual — Function
hodgedual(a) = ~a*IHodge 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
sourceGeometricAlgebra.inner — 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.
GeometricAlgebra.invhodgedual — Function
GeometricAlgebra.involution — Method
involution(a)Involute of a multivector.
Involution is an automorphism defined by reflecting through the origin: for homogeneous multivectors, involution(a) == (-1)^grade(a)*a.
See also reversion and clifford_conj.
GeometricAlgebra.lcontract — Method
a ⨼ b
lcontract(a, b)Left contraction of multivectors.
Equivalent to graded_prod((p, q) -> q - p, a, b). If a and b are of grades $p$ and $q$ respectively, then a ⨼ b is defined as the grade $q - p$ part of a*b.
GeometricAlgebra.ldual — Function
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.
GeometricAlgebra.outermorphism — Method
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.
sourceGeometricAlgebra.rcontract — Method
a ⨽ b
rcontract(a, b)Right contraction of multivectors.
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.
GeometricAlgebra.rdual — Function
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.
GeometricAlgebra.reversion — 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.
GeometricAlgebra.sandwich_prod — Function
GeometricAlgebra.scalar_prod — Method
GeometricAlgebra.wedge — 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.
GeometricAlgebra.factorblade — Method
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.
The multivector A is assumed to be a blade without checking. If it is not a blade, then factorblade(A) is undefined.
GeometricAlgebra.inv_flv_method — Method
GeometricAlgebra.matrix_repr — Function
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)
truesourceGeometricAlgebra.try_ensure_real — Method
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.
sourceMetric signatures
GeometricAlgebra.Cl — Type
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
-1sourceGeometricAlgebra.Cl — Method
Cl(sig::String) -> TupleShorthand 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})sourceGeometricAlgebra.canonical_signature — Function
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)sourceGeometricAlgebra.cayleytable — Method
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
sourceGeometricAlgebra.componentstype — Method
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.
GeometricAlgebra.ncomponents — Method
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.
GeometricAlgebra.show_basis_blade — Method
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 𝒆₁∧𝒆₂∧𝒆₃∧𝒆₄sourceGeometricAlgebra.show_signature — Method
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)})sourceGeometricAlgebra.BASIS_DISPLAY_STYLES — Constant
GeometricAlgebra.BASIS_DISPLAY_STYLESA 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!.
GeometricAlgebra.BasisDisplayStyle — Type
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::Intis 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:dimspecifies the symbols used for each basis vector.prefix="v"is the prefix string for basis blades (ifsep == nothing) or for each basis vector.sep=nothingis a string (e.g.,"∧") to separate each basis vector in a blade. Ifsepisnothing, blades are shown as e.g.,v123, whereas an empty string results inv1v2v3.labelsis a dictionary allowing individual basis blades to be given custom labels. E.g.,[3,2] => "𝒊"means4v32is displayed as4𝒊(so long as the order0b110 => [3,2]is also specified in thebladesargument — otherwise it would display as the default-4v23).
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 ITo recover the default style:
julia> delete!(GeometricAlgebra.BASIS_DISPLAY_STYLES, Cl(0,3))
IdDict{Any, BasisDisplayStyle}() sourceGeometricAlgebra.basis — Function
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 v1234sourceGeometricAlgebra.basis — Method
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).
GeometricAlgebra.basis — Method
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)
sourceGeometricAlgebra.@basis — Macro
@basis sig grades=:all scalar=false pseudoscalar=:I allperms=false prefix=nothingPopulate 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=nothingdefines no alias.allperms: include all permutations of each basis blade (e.g., definev21as well asv12).prefix: prefix for basis blades names (nothingleaves default names unchanged).
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 MainsourceMultivector promotion
GeometricAlgebra.signature_convert — Method
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)sourceGeometricAlgebra.signature_promote_rule — Function
signature_promote_rule(Val(Sig1), Val(Sig2)) -> SigDefine 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}sourceLogic for bits and grades
GeometricAlgebra.BitPermutations — Type
BitPermutations{T}(n)Infinite iterator returning all unsigned integers of type T, in ascending order, for which Base.count_ones is n.
GeometricAlgebra.bits_of_grade — Method
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"sourceGeometricAlgebra.bits_to_indices — Method
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
7sourceGeometricAlgebra.componentbits — Method
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"sourceGeometricAlgebra.factor_from_squares — Method
factor_from_squares(sig, bits::Unsigned)Compute the overall factor arising from the geometric product between repeated basis vectors.
sourceGeometricAlgebra.geometric_prod_factor — Method
geometric_prod_factor(sig, a::Unsigned, b::Unsigned)The scalar factor resulting from the geometric product between unit blades.
sourceGeometricAlgebra.indices_to_bits — Function
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.
Examples
julia> GeometricAlgebra.indices_to_bits([1, 2, 5], UInt8) |> bitstring
"00010011"sourceGeometricAlgebra.next_bit_permutation — Method
Return the smallest uint larger than the one given which has the same number of binary ones. Algorithm is Gosper’s hack.
Examples
julia> GeometricAlgebra.next_bit_permutation(0b1011) |> bitstring
"00001101"sourceGeometricAlgebra.reversion_sign — Method
reversion_sign(k) = mod(k, 4) <= 1 ? +1 : -1Sign from reversing a $k$-vector, equal to $(-1)^{k(k - 1)/2}$.
sourceGeometricAlgebra.sign_from_swaps — Method
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.)
sourceBase.getindex — Method
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.
GeometricAlgebra.componentindices — Method
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).
GeometricAlgebra.grade — Method
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 v23sourceGeometricAlgebra.promote_grades — Method
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).
GeometricAlgebra.promote_grades — Method
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:dimfor homogeneous elements (fewest components) 0:dim:dim, for elements in the scalar-pseudoscalar subalgebra0:2:dim, for elements in the even subalgebra0: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:4sourceGeometricAlgebra.resulting_grades — Method
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.
Display methods
GeometricAlgebra.show_blade — Method
Display blade with parentheses surrounding coefficient if necessary.
Example
julia> GeometricAlgebra.show_blade(stdout, BasisBlade{(x=1,)}(1 + im, 0b1))
(1 + 1im) xsourceGeometricAlgebra.show_multivector — Method
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 (defaulttrue).groupgrades::Bool: visually group components by grade (defaulttrue). 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 (default0).indent::Integer: indentation width.parseable::Bool: use parseable style (used byrepr) 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])
sourceCode generation
GeometricAlgebra.Multivector — Method
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] ^ 2sourceGeometricAlgebra.make_symbolic — Method
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
sourceGeometricAlgebra.symbolic_multivector_eval — Method
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)sourceGeometricAlgebra.symbolic_optim — Method
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.)
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.)
GeometricAlgebra.use_symbolic_optim — Method
use_symbolic_optim(sig) -> BoolWhether 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).
GeometricAlgebra.@symbolic_optim — Macro
@symbolic_optim <method definition>Convert a single method definition f(args...) into two methods:
- The original method
f(Val(:nosym), args...), called withVal(:nosym)as the first argument. This calls the original method, without any symbolic optimization. - An optimized method
f(args...)which callssymbolic_multivector_eval. Code for this method is generated by callingf(Val(:nosym), args...)with symbolic versions of theMultivectorarguments.
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
endsourceGeometricAlgebra.@symbolicga — Macro
@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.
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],
)
endsourceSymbolic utilities
GeometricAlgebra.MiniCAS.variable — Function
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] + bsourceGeometricAlgebra.MiniCAS.variables — Function
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] + bsourceGeometricAlgebra.MiniCAS.factor — Method
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.
GeometricAlgebra.MiniCAS.SubexprList — Type
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 + α + β)sourceGeometricAlgebra.MiniCAS.cse — Function
cse(a)Perform common subexpression elimination on an Expr or value (to be converted with toexpr).
Returns a let ... end block.
julia> cse(:(A + f(A) + g(f(A))^2))
:(let α = f(A)
A + α + g(α) ^ 2
end)sourceGeometricAlgebra.MiniCAS.squash — Function
squash(::SubexprList, maxcount=1)::SubexprListEliminate 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:1sourceGeometricAlgebra.MiniCAS.subexprs — Method
subexprs(::Expr)::SubexprListFlatten 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)sourceGeometricAlgebra.MiniCAS.toexpr — Method
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)sourceConformal geometric algebra
GeometricAlgebra.Conformal — Module
Conformal geometric algebra
Tools for working with conformal geometric algebra (CGA).
The algebra CGA{Sig} is an extension of the base space Sig with two additional dimensions of square $+1$ and $-1$. Points in the base space p::Multivector{Sig,1} are associated to null vectors in the higher space by
up(x) = n0 + x + x^2/2*noowhere n0, noo = nullbasis(Sig) are the null vectors representing the origin and the point at infinity.
Geometric primitives including flats (points, point pairs, lines, planes, ...) and rounds (point pairs, circles, spheres, ...) can be naturally represented as the inner or outer product null spaces of CGA blades (see ipns and opns).
Geometric primitives may be translated in space with translate and combined with the wedge product to produce meets (for opns geometries) or joins (intersections, for ipns).
Any CGA blade has a standardform from which geometric properties (such as position, radius and carrier) can be easily retrieved.
GeometricAlgebra.Conformal.CGA — Type
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.
GeometricAlgebra.Conformal.CGABlade — Type
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.
| Value | Mathematical 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
originand atinfinity - $Tₚ$ is the translation operator sending $n₀$ to $p$
The method standardform puts any blade in CGA{Sig} into 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.
sourceGeometricAlgebra.Conformal.CGAGeometry — Type
CGAGeometry{Sig}:
FlatGeometry{Sig,K}(p, E)
RoundGeometry{Sig,K}(p, E, r2)
PointAtInfinity{Sig}()
EmptySet{Sig}()Subsets of $ℝⁿ ∪ {∞}$ which are the ipns or opns of a conformal blade.
See also FlatGeometry and RoundGeometry.
GeometricAlgebra.Conformal.DirectionBlade — Type
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.
| Value | Mathematical 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
originand atinfinity - $Tₚ$ is the translation operator sending $n₀$ to $p$
The method standardform puts any blade in CGA{Sig} into 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.
sourceGeometricAlgebra.Conformal.DualFlatBlade — Type
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.
| Value | Mathematical 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
originand atinfinity - $Tₚ$ is the translation operator sending $n₀$ to $p$
The method standardform puts any blade in CGA{Sig} into 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.
sourceGeometricAlgebra.Conformal.EmptySet — Type
CGAGeometry{Sig}:
FlatGeometry{Sig,K}(p, E)
RoundGeometry{Sig,K}(p, E, r2)
PointAtInfinity{Sig}()
EmptySet{Sig}()Subsets of $ℝⁿ ∪ {∞}$ which are the ipns or opns of a conformal blade.
See also FlatGeometry and RoundGeometry.
GeometricAlgebra.Conformal.FlatBlade — Type
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.
| Value | Mathematical 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
originand atinfinity - $Tₚ$ is the translation operator sending $n₀$ to $p$
The method standardform puts any blade in CGA{Sig} into 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.
sourceGeometricAlgebra.Conformal.FlatGeometry — Type
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}.
All flats include the unique point at infinity.
| $k$-flat | name |
|---|---|
| $0$-flat | point |
| $1$-flat | line |
| $2$-flat | plane |
| $3$-flat | volume |
See also RoundGeometry and CGAGeometry.
GeometricAlgebra.Conformal.PointAtInfinity — Type
CGAGeometry{Sig}:
FlatGeometry{Sig,K}(p, E)
RoundGeometry{Sig,K}(p, E, r2)
PointAtInfinity{Sig}()
EmptySet{Sig}()Subsets of $ℝⁿ ∪ {∞}$ which are the ipns or opns of a conformal blade.
See also FlatGeometry and RoundGeometry.
GeometricAlgebra.Conformal.RoundBlade — Type
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.
| Value | Mathematical 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
originand atinfinity - $Tₚ$ is the translation operator sending $n₀$ to $p$
The method standardform puts any blade in CGA{Sig} into 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.
sourceGeometricAlgebra.Conformal.RoundGeometry — Type
RoundGeometry{Sig,K}(p, E, r2) <: CGAGeometry{Sig}A K-round in the base space Sig with center point p::Multivector{Sig,1} spanning the carrier K-blade E::Multivector{Sig,K} with square radius r2.
A $k$-round is a $(k - 1)$-sphere, whose carrier is a $k$-plane. No rounds contain the unique point at infinity.
| $k$-round | $(k - 1)$-sphere | name |
|---|---|---|
| $0$-round | $-1$-sphere | empty set |
| $1$-round | $0$-sphere | point pair |
| $2$-round | $1$-sphere | circle |
| $3$-round | $2$-sphere | sphere |
The square radius r2 may be negative, in which case the round is formally the empty set, but one may also interpret this as an "imaginary" radius.
See also FlatGeometry and CGAGeometry.
GeometricAlgebra.Conformal.dn — Function
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) = n0 + embed(x) + 1/2 x^2 noo\]
where n0, noo = nullbasis(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.
GeometricAlgebra.Conformal.infinity — Function
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.
GeometricAlgebra.Conformal.ipns — Function
ipns(A) -> CGAGeometry
opns(A) -> CGAGeometryInner 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.
GeometricAlgebra.Conformal.nullbasis — Function
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.
GeometricAlgebra.Conformal.opns — Function
ipns(A) -> CGAGeometry
opns(A) -> CGAGeometryInner 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.
GeometricAlgebra.Conformal.origin — Function
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.
GeometricAlgebra.Conformal.standardform — Method
standardform(X::AbstractMultivector{CGA{Sig}}) -> CGABlade{Sig}Put the blade X in standard form, returning a CGABlade object.
GeometricAlgebra.Conformal.translate — Method
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
truesourceGeometricAlgebra.Conformal.up — Function
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) = n0 + embed(x) + 1/2 x^2 noo\]
where n0, noo = nullbasis(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.
Utilities
GeometricAlgebra.SingletonVector — Type
SingletonVector(el, index, length)Efficient representation of a vector of all zeros except for the single element el at the given index.
- 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.