clifford.Layout¶
-
class
clifford.
Layout
(sig, *, ids=None, order=None, names=None)[source]¶ Layout stores information regarding the geometric algebra itself and the internal representation of multivectors.
- Parameters
sig (List[int]) –
The signature of the vector space. This should be a list of positive and negative numbers where the sign determines the sign of the inner product of the corresponding vector with itself. The values are irrelevant except for sign. This list also determines the dimensionality of the vectors.
Examples:
sig=[+1, -1, -1, -1] # Hestenes', et al. Space-Time Algebra sig=[+1, +1, +1] # 3-D Euclidean signature
ids (Optional[BasisVectorIds[Any]]) –
A list of ids to associate with each basis vector. These ids are used to generate names (if not passed explicitly), and also used when using tuple-notation to access elements, such as
mv[(1, 3)] = 1
. Defaults toBasisVectorIds.ordered_integers(len(sig))
; that is, integers starting at 1. This supersedes the old firstIdx argument.Examples:
ids=BasisVectorIds.ordered_integers(2, first_index=1) ids=BasisVectorIds([10, 20, 30])
New in version 1.3.0.
order (Optional[BasisBladeOrder]) –
A specification of the memory order to use when storing the basis blades. Defaults to
BasisBladeOrder.shortlex(len(sig))
. This supersedes the old bladeTupList argument.Warning
Various tools within clifford assume this default, so do not change this unless you know what you’re doing!
New in version 1.3.0.
bladeTupList (List[Tuple[int, ..]]) –
List of tuples corresponding to the blades in the whole algebra. This list determines the order of coefficients in the internal representation of multivectors. The entry for the scalar must be an empty tuple, and the entries for grade-1 vectors must be singleton tuples. Remember, the length of the list will be ``2**dims`.
Example:
bladeTupList = [(), (0,), (1,), (0, 1)] # 2-D
Deprecated since version 1.3.0: Use the new order and ids arguments instead. The above example can be spelt with the slightly longer:
ids = BasisVectorIds([.ordered_integers(2, first_index=0)]) order = ids.order_from_tuples([(), (0,), (1,), (0, 1)]) Layout(sig, ids=ids, order=order)
firstIdx (int) –
The index of the first vector. That is, some systems number the base vectors starting with 0, some with 1.
Deprecated since version 1.3.0: Use the new ids argument instead, for which the docs show an equivalent replacement
names (List[str]) –
List of names of each blade. When pretty-printing multivectors, use these symbols for the blades. names should be in the same order as order. You may use an empty string for scalars. By default, the name for each non-scalar blade is ‘e’ plus the ids of the blade as given in ids.
Example:
names=['', 's0', 's1', 'i'] # 2-D
-
dims
¶ dimensionality of vectors (
len(self.sig)
)
-
sig
¶ normalized signature, with all values
+1
or-1
-
gradeList
¶ corresponding list of the grades of each blade
-
gaDims
¶ 2**dims
-
names
¶ pretty-printing symbols for the blades
-
gmt
[source]¶ Multiplication table for the geometric product.
This is a tensor of rank 3 such that \(a = b c\) can be computed as \(a_j = \sum_{i,k} b_i \mathit{M}_{ijk} c_k\).
-
property
firstIdx
¶ Starting point for vector indices
Deprecated since version 1.3.0: This attribute has been deprecated, to match the deprecation of the matching argument in the constructor. Internal code should be using
self._basis_vector_ids.values[x]
instead ofx + self.firstIdx
. This replacement API is not yet finalized, so if you need it please file an issue on github!
-
parse_multivector
(mv_string: str) → clifford._multivector.MultiVector[source]¶ Parses a multivector string into a MultiVector object
-
get_grade_projection_matrix
(grade)[source]¶ Returns the matrix M_g that performs grade projection via left multiplication eg.
M_g@A.value = A(g).value
-
inv_func
[source]¶ Get a function that returns left-inverse using a computational linear algebra method proposed by Christian Perwass.
- -1
-1
M where M * M == 1
-
get_left_gmt_matrix
(x)[source]¶ This produces the matrix X that performs left multiplication with x eg.
X@b == (x*b).value
-
get_right_gmt_matrix
(x)[source]¶ This produces the matrix X that performs right multiplication with x eg.
X@b == (b*x).value
-
load_ga_file
(filename: str) → clifford._mvarray.MVArray[source]¶ Loads the data from a ga file, checking it matches this layout.
-
grade_mask
(grade: int) → numpy.ndarray[source]¶
-
property
rotor_mask
¶
-
property
metric
¶
-
property
scalar
¶ the scalar of value 1, for this GA (a MultiVector object)
useful for forcing a MultiVector type
-
property
pseudoScalar
¶ the psuedoScalar
-
property
I
¶ the psuedoScalar
-
randomMV
(n=1, **kwargs) → clifford._multivector.MultiVector[source]¶ Convenience method to create a random multivector.
see clifford.randomMV for details
-
randomRotor
() → clifford._multivector.MultiVector[source]¶ generate a random Rotor.
this is created by muliplying an N unit vectors, where N is the dimension of the algebra if its even; else its one less.
-
property
basis_vectors
¶ dictionary of basis vectors
-
property
basis_names
¶ Get the names of the basis vectors, in the order they are stored.
Changed in version 1.3.0: Returns a list instead of a numpy array
-
property
basis_vectors_lst
¶ Like
blades_of_grade(1)
, but ordered based on theids
parameter passed at construction.
-
blades_of_grade
(grade: int) → List[clifford._multivector.MultiVector][source]¶ return all blades of a given grade,
-
property
blades_list
¶ List of blades in this layout matching the order argument this layout was constructed from.
-
property
blades
¶
-
bases
(mvClass=<class 'clifford._multivector.MultiVector'>, grades: Optional[Container[int]] = None) → Dict[str, clifford._multivector.MultiVector][source]¶ Returns a dictionary mapping basis element names to their MultiVector instances, optionally for specific grades
if you are lazy, you might do this to populate your namespace with the variables of a given layout.
>>> locals().update(layout.blades())
Changed in version 1.1.0: This dictionary includes the scalar