clifford.MultiVector¶
- class clifford.MultiVector(layout, value=None, string=None, *, dtype: numpy.dtype = <class 'numpy.float64'>)[source]¶
An element of the algebra
- Parameters
layout (instance of
clifford.Layout
) – The layout of the algebravalue (sequence of length
layout.gaDims
) – The coefficients of the base bladesdtype (numpy.dtype) –
The datatype to use for the multivector, if no value was passed.
New in version 1.1.0.
Notes
The following operators are overloaded:
A * B
: geometric productA ^ B
: outer productA | B
: inner productA << B
: left contraction~M
: reversionM(N)
: grade or subspace projectionM[N]
: blade projection
- vee(other) → clifford._multivector.MultiVector[source]¶
Vee product \(A \vee B\).
This is often defined as:
\[\begin{split}(A \vee B)^* &= A^* \wedge B^* \\ \implies A \vee B &= (A^* \wedge B^*)^{-*}\end{split}\]This is very similar to the
meet()
function, but always uses the dual in the full space .Internally, this is actually implemented using the complement functions instead, as these work in degenerate metrics like PGA too, and are equivalent but faster in other metrics.
- __and__(other) → clifford._multivector.MultiVector[source]¶
self & other
, an alias forvee()
- __mul__(other) → clifford._multivector.MultiVector[source]¶
self * other
, the geometric product \(MN\)
- __xor__(other) → clifford._multivector.MultiVector[source]¶
self ^ other
, the Outer product \(M \wedge N\)
- __or__(other) → clifford._multivector.MultiVector[source]¶
self | other
, the inner product \(M \cdot N\)
- __add__(other) → clifford._multivector.MultiVector[source]¶
self + other
, addition
- __sub__(other) → clifford._multivector.MultiVector[source]¶
self - other
, Subtraction
- right_complement() → clifford._multivector.MultiVector[source]¶
- left_complement() → clifford._multivector.MultiVector[source]¶
- as_array() → numpy.ndarray[source]¶
- mag2() → numbers.Number[source]¶
Magnitude (modulus) squared, \({|M|}^2\)
Note in mixed signature spaces this may be negative
- adjoint() → clifford._multivector.MultiVector[source]¶
Adjoint / reversion, \(\tilde M\)
Aliased as
~M
to reflect \(\tilde M\), one of several conflicting notations.Note that
~(N * M) == ~M * ~N
.
- __invert__() → clifford._multivector.MultiVector¶
Adjoint / reversion, \(\tilde M\)
Aliased as
~M
to reflect \(\tilde M\), one of several conflicting notations.Note that
~(N * M) == ~M * ~N
.
- __getitem__(key: Union[clifford._multivector.MultiVector, tuple, int]) → numbers.Number[source]¶
value = self[key]
.If key is a blade tuple (e.g.
(0, 1)
or(1, 3)
), or a blade, (e.g.e12
), then return the (real) value of that blade’s coefficient.Deprecated since version 1.4.0: If an integer is passed, it is treated as an index into
self.value
. Useself.value[i]
directly.
- __call__(other, *others) → clifford._multivector.MultiVector[source]¶
Return a new multi-vector projected onto a grade or another MultiVector
M(g1, ... gn)
gives \(\left<M\right>_{g1} + \cdots + \left<M\right>_{gn}\)M(N)
callsproject()
asN.project(M)
.Changed in version 1.4.0: Grades larger than the dimension of the multivector now return 0 instead of erroring.
Examples
>>> from clifford.g2 import * >>> M = 1 + 2*e1 + 3*e12 >>> M(0) 1 >>> M(0, 2) 1 + (3^e12)
- clean(eps=None) → clifford._multivector.MultiVector[source]¶
Sets coefficients whose absolute value is < eps to exactly 0.
eps defaults to the current value of the global _settings._eps.
- round(eps=None) → clifford._multivector.MultiVector[source]¶
Rounds all coefficients according to Python’s rounding rules.
eps defaults to the current value of the global _settings._eps.
- lc(other) → clifford._multivector.MultiVector[source]¶
The left-contraction of two multivectors, \(M\rfloor N\)
- property pseudoScalar: clifford._multivector.MultiVector¶
Returns a MultiVector that is the pseudoscalar of this space.
- property I: clifford._multivector.MultiVector¶
Returns a MultiVector that is the pseudoscalar of this space.
- invPS() → clifford._multivector.MultiVector[source]¶
Returns the inverse of the pseudoscalar of the algebra.
- isVersor() → bool[source]¶
Returns true if multivector is a versor. From [DFM09] section 21.5, definition from 7.6.4
- grades(eps=None) → Set[int][source]¶
Return the grades contained in the multivector.
Changed in version 1.1.0: Now returns a set instead of a list
Changed in version 1.3.0: Accepts an eps argument
- property blades_list: List[clifford._multivector.MultiVector]¶
ordered list of blades present in this MV
- normal() → clifford._multivector.MultiVector[source]¶
Return the (mostly) normalized multivector.
The _mostly_ comes from the fact that some multivectors have a negative squared-magnitude. So, without introducing formally imaginary numbers, we can only fix the normalized multivector’s magnitude to +-1.
\(\frac{M}{|M|}\) up to a sign
- hitzer_inverse()[source]¶
Obtain the inverse \(M^{-1}\) via the algorithm in the paper [HS17].
New in version 1.4.0.
- Raises
NotImplementedError : – on algebras with more than 5 non-null dimensions
- shirokov_inverse()[source]¶
Obtain the inverse \(M^{-1}\) via the algorithm in Theorem 4, page 16 of Dmitry Shirokov’s ICCA 2020 paper [Shi20].
New in version 1.4.0.
- leftLaInv() → clifford._multivector.MultiVector[source]¶
Return left-inverse using a computational linear algebra method proposed by Christian Perwass.
- normalInv(check=True) → clifford._multivector.MultiVector[source]¶
The inverse of itself if \(M \tilde M = |M|^2\).
\[M^{-1} = \tilde M / (M \tilde M)\]- Parameters
check (bool) – When true, the default, validate that it is appropriate to use this method of inversion.
- inv() → clifford._multivector.MultiVector[source]¶
Obtain the inverse \(M^{-1}\).
This tries a handful of approaches in order:
If \(M \tilde M = |M|^2\), then this uses
normalInv()
.If \(M\) is of sufficiently low dimension, this uses
hitzer_inverse()
.Otherwise, this uses
leftLaInv()
.
Note that
shirokov_inverse()
is not used as its numeric stability is unknown.Changed in version 1.4.0: Now additionally tries
hitzer_inverse()
before falling back toleftLaInv()
.
- leftInv() → clifford._multivector.MultiVector¶
Return left-inverse using a computational linear algebra method proposed by Christian Perwass.
- rightInv() → clifford._multivector.MultiVector¶
Return left-inverse using a computational linear algebra method proposed by Christian Perwass.
- dual(I=None) → clifford._multivector.MultiVector[source]¶
The dual of the multivector against the given subspace I, \(\tilde M = MI^{-1}\)
I defaults to the pseudoscalar.
- commutator(other) → clifford._multivector.MultiVector[source]¶
The commutator product of two multivectors.
\([M, N] = M \times N = (MN + NM)/2\)
- x(other) → clifford._multivector.MultiVector¶
The commutator product of two multivectors.
\([M, N] = M \times N = (MN + NM)/2\)
- anticommutator(other) → clifford._multivector.MultiVector[source]¶
The anti-commutator product of two multivectors, \((MN + NM)/2\)
- gradeInvol() → clifford._multivector.MultiVector[source]¶
The grade involution of the multivector.
\[M^* = \sum_{i=0}^{\text{dims}} {(-1)^i \left<M\right>_i}\]
- property even: clifford._multivector.MultiVector¶
Even part of this multivector
defined as
M + M.gradInvol()
- property odd: clifford._multivector.MultiVector¶
Odd part of this mulitvector
defined as
M +- M.gradInvol()
- conjugate() → clifford._multivector.MultiVector[source]¶
The Clifford conjugate (reversion and grade involution).
\(M^*\) =
(~M).gradeInvol()
- project(other) → clifford._multivector.MultiVector[source]¶
Projects the multivector onto the subspace represented by this blade.
\(P_A(M) = (M \rfloor A) A^{-1}\)
- factorise() → Tuple[List[clifford._multivector.MultiVector], numbers.Number][source]¶
Factorises a blade into basis vectors and an overall scale.
Uses the algorithm from [DFM09], section 21.6.
- basis() → List[clifford._multivector.MultiVector][source]¶
Finds a vector basis of this subspace.
- join(other) → clifford._multivector.MultiVector[source]¶
The join of two blades, \(J = A \cup B\)
Similar to the wedge, \(W = A \wedge B\), but without decaying to 0 for blades which share a vector.
- meet(other, subspace=None) → clifford._multivector.MultiVector[source]¶
The meet of two blades, \(A \cap B\).
Computation is done with respect to a subspace that defaults to the
join()
if none is given.Similar to the
vee()
, \(V = A \vee B\), but without decaying to 0 for blades lying in the same subspace.