symforce.geo.matrix module

class Matrix(*args, **kwargs)[source]

Bases: Storage

Matrix type that wraps the SymPy Matrix class. Care has been taken to allow this class to create fixed-size child classes like Matrix31. Anytime __new__() is called, the appropriate fixed size class is returned rather than the type of the arguments. The API is meant to parallel the way Eigen’s C++ matrix classes work with dynamic and fixed sizes, as well as internal use cases within SymPy and SymEngine.

Examples:

1) Matrix32()  # Zero constructed Matrix32
2) Matrix(sm.Matrix([[1, 2], [3, 4]]))  # Matrix22 with [1, 2, 3, 4] data
3A) Matrix([[1, 2], [3, 4]])  # Matrix22 with [1, 2, 3, 4] data
3B) Matrix22([1, 2, 3, 4])  # Matrix22 with [1, 2, 3, 4] data (must matched fixed shape)
3C) Matrix([1, 2, 3, 4])  # Matrix41 with [1, 2, 3, 4] data - column vector assumed
4) Matrix(4, 3)  # Zero constructed Matrix43
5) Matrix(2, 2, [1, 2, 3, 4])  # Matrix22 with [1, 2, 3, 4] data (first two are shape)
6) Matrix(2, 2, lambda row, col: row + col)  # Matrix22 with [0, 1, 1, 2] data
7) Matrix22(1, 2, 3, 4)  # Matrix22 with [1, 2, 3, 4] data (must match fixed length)

References

https://docs.sympy.org/latest/tutorial/matrices.html https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html https://en.wikipedia.org/wiki/Vector_space

Matrix does not implement the group or lie group concepts using instance/class methods directly, because we want it to represent the group R^{NxM}, not GL(n), which leads to the identity and inverse methods being confusingly named. For the group ops and lie group ops, use symforce.ops.group_ops.GroupOps and symforce.ops.lie_group_ops.LieGroupOps respectively, which use the implementation in symforce.ops.impl.vector_class_lie_group_ops of the R^{NxM} group under matrix addition. For the identity matrix and inverse matrix, see Matrix.eye() and Matrix.inv() respectively.

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

MatrixT = ~MatrixT
SHAPE = (-1, -1)
static __new__(cls, *args, **kwargs)[source]

Beast of a method for creating a Matrix. Handles a variety of construction use cases and always returns a fixed size child class of Matrix rather than Matrix itself. The available construction options depend on whether cls is a fixed size type or not. See the Matrix docstring for a summary of the construction options.

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Matrix

property rows: int
property cols: int
property shape: Tuple[int, int]
property is_Matrix: bool
classmethod storage_dim()[source]

Dimension of underlying storage

Return type:

int

classmethod from_storage(vec)[source]

Construct from a flat list representation. Opposite of to_storage().

Parameters:

vec (_T.Union[_T.Sequence[_T.Scalar], Matrix]) –

Return type:

MatrixT

to_storage()[source]

Flat list representation of the underlying storage, length of storage_dim(). This is used purely for plumbing, it is NOT like a tangent space.

Return type:

List[float]

classmethod tangent_dim()[source]
Return type:

int

classmethod from_tangent(vec, epsilon=0.0)[source]
Parameters:
  • vec (_T.Sequence[_T.Scalar]) –

  • epsilon (_T.Scalar) –

Return type:

MatrixT

to_tangent(epsilon=0.0)[source]
Parameters:

epsilon (float) –

Return type:

List[float]

storage_D_tangent()[source]
Return type:

Matrix

tangent_D_storage()[source]
Return type:

Matrix

classmethod zero()[source]

Matrix of zeros.

Return type:

MatrixT

classmethod zeros(rows, cols)[source]

Matrix of zeros.

Parameters:
  • rows (int) –

  • cols (int) –

Return type:

MatrixT

classmethod one()[source]

Matrix of ones.

Return type:

MatrixT

classmethod ones(rows, cols)[source]

Matrix of ones.

Parameters:
  • rows (int) –

  • cols (int) –

Return type:

MatrixT

classmethod diag(diagonal)[source]

Construct a square matrix from the diagonal.

Parameters:

diagonal (_T.Sequence[_T.Scalar]) –

Return type:

MatrixT

classmethod eye(rows=None, cols=None)[source]

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

det()[source]

Determinant of the matrix.

Return type:

float

inv(method='LU')[source]

Inverse of the matrix.

Parameters:
  • self (MatrixT) –

  • method (str) –

Return type:

MatrixT

classmethod symbolic(name, **kwargs)[source]

Create with symbols.

Parameters:
  • name (str) – Name prefix of the symbols

  • **kwargs (dict) – Forwarded to sf.Symbol

Return type:

MatrixT

row_join(right)[source]

Concatenates self with another matrix on the right

Parameters:

right (Matrix) –

Return type:

Matrix

col_join(bottom)[source]

Concatenates self with another matrix below

Parameters:

bottom (Matrix) –

Return type:

Matrix

classmethod block_matrix(array)[source]

Constructs a matrix from block elements.

For example:

[[Matrix22(...), Matrix23(...)], [Matrix11(...), Matrix14(...)]]

constructs a Matrix35 with elements equal to given blocks

Parameters:

array (Sequence[Sequence[Matrix]]) –

Return type:

Matrix

simplify(*args, **kwargs)[source]

Simplify this expression.

This overrides the sympy implementation because that clobbers the class type.

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Matrix

limit(*args, **kwargs)[source]

Take the limit at z = z0

This overrides the sympy implementation because that clobbers the class type.

Parameters:
  • args (Any) –

  • kwargs (Any) –

Return type:

Matrix

jacobian(X, tangent_space=True)[source]

Compute the jacobian with respect to the tangent space of X if tangent_space = True, otherwise returns the jacobian with respect to the storage elements of X.

Note that the jacobian is always 2D, even if self or X are matrices - it will be M x N, where M is the size of self and N is the size of X

Parameters:
  • X (Any) –

  • tangent_space (bool) –

Return type:

Matrix

diff(*args)[source]

Differentiate w.r.t. a scalar.

Parameters:

args (float) –

Return type:

Matrix

property T: Matrix

Matrix Transpose

transpose()[source]

Matrix Transpose

Return type:

Matrix

lower_triangle()[source]

Returns the lower triangle (including diagonal) of self

self must be square

Parameters:

self (MatrixT) –

Return type:

MatrixT

class Triangle(value)[source]

Bases: Enum

An enumeration.

LOWER = 'lower'
UPPER = 'upper'
symmetric_copy(upper_or_lower)[source]

Returns a symmetric copy of self by copying the lower or upper triangle to the opposite triangle.

Parameters:
  • upper_or_lower (Triangle) – The triangle to copy to the opposite triangle

  • self (MatrixT) –

Return type:

MatrixT

reshape(rows, cols)[source]
Parameters:
  • rows (int) –

  • cols (int) –

Return type:

Matrix

dot(other)[source]

Dot product, also known as inner product.

Only supports mapping 1 x n or n x 1 Matrices to scalars. Note that both matrices must have the same shape.

Parameters:

other (Matrix) –

Return type:

float

cross(other)[source]

Cross product.

Parameters:
  • self (MatrixT) –

  • other (MatrixT) –

Return type:

Vector3

squared_norm()[source]

Squared norm of a vector, equivalent to the dot product with itself.

Return type:

float

norm(epsilon=0.0)[source]

Norm of a vector (square root of magnitude).

Parameters:

epsilon (float) –

Return type:

float

normalized(epsilon=0.0)[source]

Returns a unit vector in this direction (divide by norm).

Parameters:
  • self (MatrixT) –

  • epsilon (_T.Scalar) –

Return type:

MatrixT

clamp_norm(max_norm, epsilon=0.0)[source]

Clamp a vector to the given norm in a safe/differentiable way.

Is NOT safe if max_norm can be negative, or if derivatives are needed w.r.t. max_norm and max_norm can be 0 or small enough that max_squared_norm / squared_norm is truncated to 0 in the particular floating point type being used (e.g. all of these are true if max_norm is optimized).

Currently only L2 norm is supported

Parameters:
  • self (MatrixT) –

  • max_norm (_T.Scalar) –

  • epsilon (_T.Scalar) –

Return type:

MatrixT

multiply_elementwise(rhs)[source]

Do the elementwise multiplication between self and rhs, and return the result as a new Matrix

Parameters:
  • self (MatrixT) –

  • rhs (MatrixT) –

Return type:

MatrixT

applyfunc(func)[source]

Apply a unary operation to every scalar.

Parameters:
  • self (MatrixT) –

  • func (_T.Callable) –

Return type:

MatrixT

__getitem__(item)[source]

Get a scalar value or submatrix slice.

Unlike sympy, for 1D matrices the submatrix slice is returned as a 1D matrix instead of as a list.

Parameters:

item (Any) –

Return type:

Any

row(r)[source]

Extract a row of the matrix

Parameters:

r (int) –

Return type:

Matrix

col(c)[source]

Extract a column of the matrix

Parameters:

c (int) –

Return type:

Matrix

__neg__()[source]

Negate matrix.

Parameters:

self (MatrixT) –

Return type:

MatrixT

__add__(right)[source]

Add a scalar or matrix to this matrix.

Parameters:
  • self (MatrixT) –

  • right (_T.Union[_T.Scalar, MatrixT]) –

Return type:

MatrixT

__sub__(right)[source]

Subtract a scalar or matrix from this matrix.

Parameters:
  • self (MatrixT) –

  • right (_T.Union[_T.Scalar, MatrixT]) –

Return type:

MatrixT

__mul__(right)[source]

Multiply a matrix by a scalar or matrix

Parameters:

right (_T.Union[MatrixT, _T.Scalar, Matrix, sf.sympy.MutableDenseMatrix]) –

Return type:

_T.Union[MatrixT, Matrix]

__rmul__(left)[source]

Left multiply a matrix by a scalar or matrix

Parameters:

left (_T.Union[MatrixT, _T.Scalar, Matrix, sf.sympy.MutableDenseMatrix]) –

Return type:

_T.Union[MatrixT, Matrix]

__truediv__(right)[source]

Divide a matrix by a scalar or a matrix (which takes the inverse).

Parameters:

right (_T.Union[MatrixT, _T.Scalar, Matrix, sf.sympy.MutableDenseMatrix]) –

Return type:

_T.Union[MatrixT, Matrix]

compute_AtA(lower_only=False)[source]

Compute a symmetric product A.transpose() * A

Parameters:

lower_only (bool) – If given, only fill the lower half and set upper to zero

Returns:

(Matrix (N, N)) – Symmetric matrix AtA = self.transpose() * self

Return type:

Matrix

LU()[source]

LU matrix decomposition

Return type:

Tuple[Matrix, Matrix] | Tuple[Matrix, Matrix, List[Tuple[int, int]]]

LDL()[source]

LDL matrix decomposition (stable cholesky)

Return type:

Tuple[Matrix, Matrix]

FFLU()[source]

Fraction-free LU matrix decomposition

Return type:

Tuple[Matrix, Matrix]

FFLDU()[source]

Fraction-free LDU matrix decomposition

Return type:

Tuple[Matrix, Matrix, Matrix] | Tuple[Matrix, Matrix, Matrix, Matrix]

solve(b, method='LU')[source]

Solve a linear system using the given method.

Parameters:
Return type:

Matrix

static are_parallel(a, b, tolerance)[source]

Returns 1 if a and b are parallel within tolerance, and 0 otherwise.

Parameters:
Return type:

float

static skew_symmetric(a)[source]

Compute a skew-symmetric matrix of given a 3-vector.

Parameters:

a (Matrix31) –

Return type:

Matrix33

evalf()[source]

Perform numerical evaluation of each element in the matrix.

Return type:

Matrix

to_list()[source]

Convert to a nested list

Return type:

List[List[float]]

to_flat_list()[source]

Convert to a flattened list

Return type:

List[float]

classmethod from_flat_list(vec)[source]
Parameters:

vec (Sequence[float]) –

Return type:

Matrix

to_numpy(scalar_type=<class 'numpy.float64'>)[source]

Convert to a numpy array.

Parameters:

scalar_type (type) –

Return type:

ndarray

classmethod column_stack(*columns)[source]

Take a sequence of 1-D vectors and stack them as columns to make a single 2-D Matrix.

Parameters:

columns (Matrix) – 1-D vectors

Return type:

Matrix

is_vector()[source]
Return type:

bool

static init_printing()[source]

Initialize SymPy pretty printing

_ipython_display_ is sufficient in Jupyter, but this covers other locations

Return type:

None

class Matrix11(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 1)
class Matrix21(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 1)
static unit_x()[source]

The unit vector [1, 0]

Return type:

Matrix21

static unit_y()[source]

The unit vector [0, 1]

Return type:

Matrix21

property x: float

The entry self[0, 0]

property y: float

The entry self[1, 0]

class Matrix31(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 1)
static unit_x()[source]

The unit vector [1, 0, 0]

Return type:

Matrix31

static unit_y()[source]

The unit vector [0, 1, 0]

Return type:

Matrix31

static unit_z()[source]

The unit vector [0, 0, 1]

Return type:

Matrix31

property x: float

The entry self[0, 0]

property y: float

The entry self[1, 0]

property z: float

The entry self[2, 0]

class Matrix41(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 1)
class Matrix51(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 1)
class Matrix61(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 1)
class Matrix71(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 1)
class Matrix81(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 1)
class Matrix91(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 1)
class Matrix12(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 2)
class Matrix22(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 2)
class Matrix32(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 2)
class Matrix42(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 2)
class Matrix52(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 2)
class Matrix62(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 2)
class Matrix72(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 2)
class Matrix82(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 2)
class Matrix92(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 2)
class Matrix13(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 3)
class Matrix23(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 3)
class Matrix33(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 3)
class Matrix43(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 3)
class Matrix53(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 3)
class Matrix63(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 3)
class Matrix73(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 3)
class Matrix83(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 3)
class Matrix93(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 3)
class Matrix14(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 4)
class Matrix24(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 4)
class Matrix34(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 4)
class Matrix44(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 4)
class Matrix54(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 4)
class Matrix64(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 4)
class Matrix74(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 4)
class Matrix84(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 4)
class Matrix94(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 4)
class Matrix15(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 5)
class Matrix25(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 5)
class Matrix35(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 5)
class Matrix45(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 5)
class Matrix55(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 5)
class Matrix65(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 5)
class Matrix75(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 5)
class Matrix85(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 5)
class Matrix95(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 5)
class Matrix16(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 6)
class Matrix26(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 6)
class Matrix36(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 6)
class Matrix46(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 6)
class Matrix56(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 6)
class Matrix66(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 6)
class Matrix76(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 6)
class Matrix86(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 6)
class Matrix96(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 6)
class Matrix17(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 7)
class Matrix27(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 7)
class Matrix37(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 7)
class Matrix47(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 7)
class Matrix57(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 7)
class Matrix67(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 7)
class Matrix77(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 7)
class Matrix87(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 7)
class Matrix97(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 7)
class Matrix18(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 8)
class Matrix28(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 8)
class Matrix38(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 8)
class Matrix48(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 8)
class Matrix58(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 8)
class Matrix68(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 8)
class Matrix78(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 8)
class Matrix88(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 8)
class Matrix98(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 8)
class Matrix19(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (1, 9)
class Matrix29(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (2, 9)
class Matrix39(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (3, 9)
class Matrix49(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (4, 9)
class Matrix59(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (5, 9)
class Matrix69(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (6, 9)
class Matrix79(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (7, 9)
class Matrix89(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (8, 9)
class Matrix99(*args, **kwargs)[source]

Bases: Matrix

Parameters:
  • args (_T.Any) –

  • kwargs (_T.Any) –

Return type:

Matrix

SHAPE = (9, 9)
m

alias of Matrix99

matrix_type_from_shape(shape)[source]

Return a fixed size matrix type (like Matrix32) given a shape

Either uses the statically defined ones or dynamically creates a new one if not available.

Parameters:

shape (Tuple[int, int]) –

Return type:

Type[Matrix]

M

alias of Matrix

Vector1

alias of Matrix11

Vector2

alias of Matrix21

Vector3

alias of Matrix31

Vector4

alias of Matrix41

Vector5

alias of Matrix51

Vector6

alias of Matrix61

Vector7

alias of Matrix71

Vector8

alias of Matrix81

Vector9

alias of Matrix91

V1

alias of Matrix11

V2

alias of Matrix21

V3

alias of Matrix31

V4

alias of Matrix41

V5

alias of Matrix51

V6

alias of Matrix61

V7

alias of Matrix71

V8

alias of Matrix81

V9

alias of Matrix91

M11

alias of Matrix11

M21

alias of Matrix21

M31

alias of Matrix31

M41

alias of Matrix41

M51

alias of Matrix51

M61

alias of Matrix61

M71

alias of Matrix71

M81

alias of Matrix81

M91

alias of Matrix91

M12

alias of Matrix12

M22

alias of Matrix22

M32

alias of Matrix32

M42

alias of Matrix42

M52

alias of Matrix52

M62

alias of Matrix62

M72

alias of Matrix72

M82

alias of Matrix82

M92

alias of Matrix92

M13

alias of Matrix13

M23

alias of Matrix23

M33

alias of Matrix33

M43

alias of Matrix43

M53

alias of Matrix53

M63

alias of Matrix63

M73

alias of Matrix73

M83

alias of Matrix83

M93

alias of Matrix93

M14

alias of Matrix14

M24

alias of Matrix24

M34

alias of Matrix34

M44

alias of Matrix44

M54

alias of Matrix54

M64

alias of Matrix64

M74

alias of Matrix74

M84

alias of Matrix84

M94

alias of Matrix94

M15

alias of Matrix15

M25

alias of Matrix25

M35

alias of Matrix35

M45

alias of Matrix45

M55

alias of Matrix55

M65

alias of Matrix65

M75

alias of Matrix75

M85

alias of Matrix85

M95

alias of Matrix95

M16

alias of Matrix16

M26

alias of Matrix26

M36

alias of Matrix36

M46

alias of Matrix46

M56

alias of Matrix56

M66

alias of Matrix66

M76

alias of Matrix76

M86

alias of Matrix86

M96

alias of Matrix96

M17

alias of Matrix17

M27

alias of Matrix27

M37

alias of Matrix37

M47

alias of Matrix47

M57

alias of Matrix57

M67

alias of Matrix67

M77

alias of Matrix77

M87

alias of Matrix87

M97

alias of Matrix97

M18

alias of Matrix18

M28

alias of Matrix28

M38

alias of Matrix38

M48

alias of Matrix48

M58

alias of Matrix58

M68

alias of Matrix68

M78

alias of Matrix78

M88

alias of Matrix88

M98

alias of Matrix98

M19

alias of Matrix19

M29

alias of Matrix29

M39

alias of Matrix39

M49

alias of Matrix49

M59

alias of Matrix59

M69

alias of Matrix69

M79

alias of Matrix79

M89

alias of Matrix89

M99

alias of Matrix99

I1(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I11(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I2(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I22(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I3(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I33(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I4(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I44(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I5(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I55(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I6(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I66(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I7(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I77(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I8(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I88(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I9(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT

I99(rows=None, cols=None)

Construct an identity matrix

If neither rows nor cols is provided, this must be called as a class method on a fixed-size class.

If rows is provided, returns a square identity matrix of shape (rows x rows).

If rows and cols are provided, returns a (rows x cols) matrix, with ones on the diagonal.

Parameters:
  • rows (_T.Optional[int]) –

  • cols (_T.Optional[int]) –

Return type:

MatrixT