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 to BasisVectorIds.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

gaDims

2**dims

names

pretty-printing symbols for the blades

property gradeList
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\).

omt[source]

Multiplication table for the inner product, stored in the same way as gmt

imt[source]

Multiplication table for the outer product, stored in the same way as gmt

lcmt[source]

Multiplication table for the left-contraction, stored in the same way as gmt

bladeTupList[source]
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 of x + self.firstIdx. This replacement API is not yet finalized, so if you need it please file an issue on github!

dual_func[source]

Generates the dual function for the pseudoscalar

vee_func[source]

Generates the vee product function

parse_multivector(mv_string: str)clifford._multivector.MultiVector[source]

Parses a multivector string into a MultiVector object

gmt_func_generator(grades_a=None, grades_b=None, filter_mask=None)[source]
imt_func_generator(grades_a=None, grades_b=None, filter_mask=None)[source]
omt_func_generator(grades_a=None, grades_b=None, filter_mask=None)[source]
lcmt_func_generator(grades_a=None, grades_b=None, filter_mask=None)[source]
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

gmt_func[source]
imt_func[source]
omt_func[source]
lcmt_func[source]
left_complement_func[source]
right_complement_func[source]
adjoint_func[source]

This function returns a fast jitted adjoint function

inv_func[source]

Get a function that returns left-inverse using a computational linear algebra method proposed by Christian Perwass.

Computes \(M^{-1}\) where \(M^{-1}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: numpy.ndarray
property metric: numpy.ndarray
property scalar: clifford._multivector.MultiVector

the scalar of value 1, for this GA (a MultiVector object)

useful for forcing a MultiVector type

property pseudoScalar: clifford._multivector.MultiVector

The pseudoscalar, \(I\).

property I: clifford._multivector.MultiVector

The pseudoscalar, \(I\).

randomMV(n=1, **kwargs)clifford._multivector.MultiVector[source]

Convenience method to create a random multivector.

see clifford.randomMV for details

randomV(n=1, **kwargs)clifford._multivector.MultiVector[source]

generate n random 1-vector s

randomRotor(**kwargs)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: Dict[str, clifford._multivector.MultiVector]

dictionary of basis vectors

property basis_names: List[str]

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: List[clifford._multivector.MultiVector]

Like blades_of_grade(1), but ordered based on the ids 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[clifford._multivector.MultiVector]

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

MultiVector(*args, **kwargs)clifford._multivector.MultiVector[source]

Create a multivector in this layout

convenience func to MultiVector(layout)