Built-ins#
Built-in matrix type definitions
- class matrixlib.builtins.Matrix(array: Mesh[M_co, N_co, T_co])#
- class matrixlib.builtins.Matrix(array: Matrix[M_co, N_co, T_co])
- class matrixlib.builtins.Matrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.ROW: 0>])
- class matrixlib.builtins.Matrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.COL: 1>])
- class matrixlib.builtins.Matrix(array: Iterable[T_co], shape: Rule)
- class matrixlib.builtins.Matrix(array: Iterable[T_co], shape: tuple[+M_co, +N_co])
A “hybrid” one and two-rank immutable sequence
Implements the
collections.abc.Sequence
interface, alongside two-dimensional transformations and access abilities. Provides only a few vectorized operations that are usable on objects of any type.- __init__(array: Mesh[M_co, N_co, T_co]) None #
- __init__(array: Matrix[M_co, N_co, T_co]) None
- __init__(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.ROW: 0>]) None
- __init__(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.COL: 1>]) None
- __init__(array: Iterable[T_co], shape: Rule) None
- __init__(array: Iterable[T_co], shape: tuple[+M_co, +N_co]) None
Construct a matrix from an iterable and shape, or from another matrix instance
If
shape
is aRule
,array
is interpreted as either a row or column vector, depending on the given member.Raises
ValueError
if any of the shape’s values are negative, or if the shape’s product does not equal the length ofarray
(debug-only).Construction-by-matrix (what we call “casting”), is a constant-time operation. Providing a matrix with some
shape
is usually a constant-time operation as well, but can vary depending on its material state (this is also how matrices can be “re-shaped”).
- __repr__() str #
Return a canonical representation of the matrix
- __str__() str #
Return a string representation of the matrix
- __eq__(other: object) bool #
Return true if the two matrices are equal, otherwise false
- __hash__() int #
Return a hash of the matrix
Matrices are hashable if its values are also hashable.
- __len__() int #
Return the matrix’s size
- __getitem__(key: int) T_co #
- __getitem__(key: slice) Matrix[Literal[1], Any, T_co]
- __getitem__(key: tuple[int, int]) T_co
- __getitem__(key: tuple[int, slice]) Matrix[Literal[1], Any, T_co]
- __getitem__(key: tuple[slice, int]) Matrix[Any, Literal[1], T_co]
- __getitem__(key: tuple[slice, slice]) Matrix[Any, Any, T_co]
Return the value or sub-matrix corresponding to
key
- __iter__() Iterator[T_co] #
Return an iterator over the values of the matrix in row-major order
- __reversed__() Iterator[T_co] #
Return an iterator over the values of the matrix in reverse row-major order
- __contains__(value: object) bool #
Return true if the matrix contains
value
, otherwise false
- final __deepcopy__(memo=None) Self #
Return the matrix
- final __copy__() Self #
Return the matrix
- property array: Sequence[T_co]#
The underlying sequence of matrix values, aligned in row-major order
This object will, at minimum, have an implementation of the
Sequence
interface. We make no guarantee of any concrete types, as it depends on a variety of internal conditions.
- property shape: tuple[+M_co, +N_co]#
The number of rows and columns as a
tuple
- property nrows: M_co#
The number of rows
- property ncols: N_co#
The number of columns
- classmethod from_nesting(nesting: Iterable[Iterable[T_co]]) Self #
Construct a matrix from a singly-nested iterable, using the shallowest iterable’s length to deduce the number of rows, and the nested iterables’ length to deduce the number of columns
Raises
ValueError
if the length of the nested iterables is inconsistent (debug-only).
- index(value: Any, start: int = 0, stop: int | None = None) int #
Return the first index where
value
appears in the matrixRaises
ValueError
ifvalue
is not present.
- count(value: Any) int #
Return the number of times
value
appears in the matrix
- materialize() Matrix[M_co, N_co, T_co] #
Return a materialized copy of the matrix
Certain methods (particularly those that permute the matrix’s values in some fashion) construct a view onto the underlying sequence to preserve memory. These views can “stack” onto one another, which can drastically increase access time.
This method addresses said issue by shallowly placing the elements into a new sequence - a process that we call “materialization”. The resulting matrix instance will have access times identical to that of an instance created from an array-and-shape pairing, but note that this may consume significant amounts of memory (depending on the size of the matrix).
If the matrix does not store a kind of view, this method returns a matrix that is semantically equivalent to the original. We call such matrices “materialized”, or “material”, as they store a sequence whose elements already exist in the desired order.
Think of materialization as being akin to compiling regular expressions: if the same matrix permutation is required in many different places, it’s much more time-efficient to materialize it, and use the resulting material matrix as a substituting variable.
- rotate(n: Literal[-16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16]) Matrix[M_co, N_co, T_co] #
- rotate(n: Literal[-15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]) Matrix[N_co, M_co, T_co]
- rotate(n: int) Matrix[Any, Any, T_co]
- rotate() Matrix[N_co, M_co, T_co]
Return a rotated view of the matrix
Rotates the matrix
n
times in increments of 90 degrees. The matrix is rotated counter-clockwise ifn
is positive, and clockwise ifn
is negative. All integers are accepted, but many (particularly those outside of a small range near zero) will lose typing precision.
- n(by: ~typing.Literal[<Rule.ROW: 0>]) M_co #
- n(by: ~typing.Literal[<Rule.COL: 1>]) N_co
- n(by: Rule) M_co | N_co
Return the dimension corresponding to the given
Rule
- values(*, by: ~typing.Literal[<Rule.ROW: 0>], reverse: bool = False) Iterator[T_co] #
- values(*, by: ~typing.Literal[<Rule.COL: 1>], reverse: bool = False) Iterator[T_co]
- values(*, by: Rule, reverse: bool = False) Iterator[T_co]
- values(*, reverse: bool = False) Iterator[T_co]
Return an iterator over the values of the matrix in row or column-major order
- slices(*, by: ~typing.Literal[<Rule.ROW: 0>], reverse: bool = False) Iterator[Matrix[Literal[1], N_co, T_co]] #
- slices(*, by: ~typing.Literal[<Rule.COL: 1>], reverse: bool = False) Iterator[Matrix[M_co, Literal[1], T_co]]
- slices(*, by: Rule, reverse: bool = False) Iterator[Matrix[Any, Any, T_co]]
- slices(*, reverse: bool = False) Iterator[Matrix[Literal[1], N_co, T_co]]
Return an iterator over the rows or columns of the matrix
- format(*, field_width: int = 8) str #
Return a formatted string representation of the matrix
Writes all contained values to fields of a multi-line string. If the value’s string representation exceeds
field_width
, it is truncated, with its last character slot re-purposed to an include an ellipsis character (…
, U+2026) - signifying that the field width must be larger for the value to appear in its entirety.Raises
ValueError
iffield_width
is not positive.This method is primarily intended for use in interactive sessions. Relying on this method for serialization (or similar) is discouraged, as its format may change without regard for backwards compatability.
- equal(other: Matrix[M_co, N_co, object]) IntegerMatrix[M_co, N_co, bool] #
- equal(other: object) IntegerMatrix[M_co, N_co, bool]
Return element-wise
a == b
- not_equal(other: Matrix[M_co, N_co, object]) IntegerMatrix[M_co, N_co, bool] #
- not_equal(other: object) IntegerMatrix[M_co, N_co, bool]
Return element-wise
a != b
- class matrixlib.builtins.ComplexMatrix(array: Mesh[M_co, N_co, T_co])#
- class matrixlib.builtins.ComplexMatrix(array: Matrix[M_co, N_co, T_co])
- class matrixlib.builtins.ComplexMatrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.ROW: 0>])
- class matrixlib.builtins.ComplexMatrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.COL: 1>])
- class matrixlib.builtins.ComplexMatrix(array: Iterable[T_co], shape: Rule)
- class matrixlib.builtins.ComplexMatrix(array: Iterable[T_co], shape: tuple[+M_co, +N_co])
Built-in
Matrix
sub-class constrained to instances ofcomplex
- __getitem__(key: int) C_co #
- __getitem__(key: slice) ComplexMatrix[Literal[1], Any, C_co]
- __getitem__(key: tuple[int, int]) C_co
- __getitem__(key: tuple[int, slice]) ComplexMatrix[Literal[1], Any, C_co]
- __getitem__(key: tuple[slice, int]) ComplexMatrix[Any, Literal[1], C_co]
- __getitem__(key: tuple[slice, slice]) ComplexMatrix[Any, Any, C_co]
Return the value or sub-matrix corresponding to
key
- __add__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int] #
- __add__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __add__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __add__(other: int) ComplexMatrix[M_co, N_co, int]
- __add__(other: float) ComplexMatrix[M_co, N_co, float]
- __add__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a + b
- __sub__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int] #
- __sub__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __sub__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __sub__(other: int) ComplexMatrix[M_co, N_co, int]
- __sub__(other: float) ComplexMatrix[M_co, N_co, float]
- __sub__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a - b
- __mul__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int] #
- __mul__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __mul__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __mul__(other: int) ComplexMatrix[M_co, N_co, int]
- __mul__(other: float) ComplexMatrix[M_co, N_co, float]
- __mul__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a * b
- __matmul__(other: ComplexMatrix[N_co, P_co, int]) ComplexMatrix[M_co, P_co, int] #
- __matmul__(other: ComplexMatrix[N_co, P_co, float]) ComplexMatrix[M_co, P_co, float]
- __matmul__(other: ComplexMatrix[N_co, P_co, complex]) ComplexMatrix[M_co, P_co, complex]
Return the matrix product
- __truediv__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float] #
- __truediv__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __truediv__(other: float) ComplexMatrix[M_co, N_co, float]
- __truediv__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a / b
- __radd__(other: int) ComplexMatrix[M_co, N_co, int] #
- __radd__(other: float) ComplexMatrix[M_co, N_co, float]
- __radd__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b + a
- __rsub__(other: int) ComplexMatrix[M_co, N_co, int] #
- __rsub__(other: float) ComplexMatrix[M_co, N_co, float]
- __rsub__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b - a
- __rmul__(other: int) ComplexMatrix[M_co, N_co, int] #
- __rmul__(other: float) ComplexMatrix[M_co, N_co, float]
- __rmul__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b * a
- __rtruediv__(other: float) ComplexMatrix[M_co, N_co, float] #
- __rtruediv__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b / a
- __neg__() ComplexMatrix[M_co, N_co, int] #
- __neg__() ComplexMatrix[M_co, N_co, float]
- __neg__() ComplexMatrix[M_co, N_co, complex]
Return element-wise
-a
- __pos__() ComplexMatrix[M_co, N_co, int] #
- __pos__() ComplexMatrix[M_co, N_co, float]
- __pos__() ComplexMatrix[M_co, N_co, complex]
Return element-wise
+a
- __abs__() RealMatrix[M_co, N_co, int] #
- __abs__() RealMatrix[M_co, N_co, float]
Return element-wise
abs(a)
- materialize() ComplexMatrix[M_co, N_co, C_co] #
Return a materialized copy of the matrix
Certain methods (particularly those that permute the matrix’s values in some fashion) construct a view onto the underlying sequence to preserve memory. These views can “stack” onto one another, which can drastically increase access time.
This method addresses said issue by shallowly placing the elements into a new sequence - a process that we call “materialization”. The resulting matrix instance will have access times identical to that of an instance created from an array-and-shape pairing, but note that this may consume significant amounts of memory (depending on the size of the matrix).
If the matrix does not store a kind of view, this method returns a matrix that is semantically equivalent to the original. We call such matrices “materialized”, or “material”, as they store a sequence whose elements already exist in the desired order.
Think of materialization as being akin to compiling regular expressions: if the same matrix permutation is required in many different places, it’s much more time-efficient to materialize it, and use the resulting material matrix as a substituting variable.
- transpose() ComplexMatrix[N_co, M_co, C_co] #
Return a transposed view of the matrix
- flip(*, by: Rule = Rule.ROW) ComplexMatrix[M_co, N_co, C_co] #
Return a flipped view of the matrix
- rotate(n: Literal[-16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16]) ComplexMatrix[M_co, N_co, C_co] #
- rotate(n: Literal[-15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]) ComplexMatrix[N_co, M_co, C_co]
- rotate(n: int) ComplexMatrix[Any, Any, C_co]
- rotate() ComplexMatrix[N_co, M_co, C_co]
Return a rotated view of the matrix
Rotates the matrix
n
times in increments of 90 degrees. The matrix is rotated counter-clockwise ifn
is positive, and clockwise ifn
is negative. All integers are accepted, but many (particularly those outside of a small range near zero) will lose typing precision.
- reverse() ComplexMatrix[M_co, N_co, C_co] #
Return a reversed view of the matrix
- slices(*, by: ~typing.Literal[<Rule.ROW: 0>], reverse: bool = False) Iterator[ComplexMatrix[Literal[1], N_co, C_co]] #
- slices(*, by: ~typing.Literal[<Rule.COL: 1>], reverse: bool = False) Iterator[ComplexMatrix[M_co, Literal[1], C_co]]
- slices(*, by: Rule, reverse: bool = False) Iterator[ComplexMatrix[Any, Any, C_co]]
- slices(*, reverse: bool = False) Iterator[ComplexMatrix[Literal[1], N_co, C_co]]
Return an iterator over the rows or columns of the matrix
- conjugate() ComplexMatrix[M_co, N_co, int] #
- conjugate() ComplexMatrix[M_co, N_co, float]
- conjugate() ComplexMatrix[M_co, N_co, complex]
Return element-wise
a.conjugate()
- transjugate() ComplexMatrix[N_co, M_co, int] #
- transjugate() ComplexMatrix[N_co, M_co, float]
- transjugate() ComplexMatrix[N_co, M_co, complex]
Return the conjugate transpose
The returned matrix may or may not be a view depending on the active class.
- class matrixlib.builtins.RealMatrix(array: Mesh[M_co, N_co, T_co])#
- class matrixlib.builtins.RealMatrix(array: Matrix[M_co, N_co, T_co])
- class matrixlib.builtins.RealMatrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.ROW: 0>])
- class matrixlib.builtins.RealMatrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.COL: 1>])
- class matrixlib.builtins.RealMatrix(array: Iterable[T_co], shape: Rule)
- class matrixlib.builtins.RealMatrix(array: Iterable[T_co], shape: tuple[+M_co, +N_co])
Built-in
ComplexMatrix
sub-class constrained to instances offloat
- __lt__(other: RealMatrix[Any, Any, float]) bool #
Return true if lexicographic
a < b
, otherwise false
- __le__(other: RealMatrix[Any, Any, float]) bool #
Return true if lexicographic
a <= b
, otherwise false
- __gt__(other: RealMatrix[Any, Any, float]) bool #
Return true if lexicographic
a > b
, otherwise false
- __ge__(other: RealMatrix[Any, Any, float]) bool #
Return true if lexicographic
a >= b
, otherwise false
- __getitem__(key: int) R_co #
- __getitem__(key: slice) RealMatrix[Literal[1], Any, R_co]
- __getitem__(key: tuple[int, int]) R_co
- __getitem__(key: tuple[int, slice]) RealMatrix[Literal[1], Any, R_co]
- __getitem__(key: tuple[slice, int]) RealMatrix[Any, Literal[1], R_co]
- __getitem__(key: tuple[slice, slice]) RealMatrix[Any, Any, R_co]
Return the value or sub-matrix corresponding to
key
- __add__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int] #
- __add__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __add__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int]
- __add__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __add__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __add__(other: int) RealMatrix[M_co, N_co, int]
- __add__(other: float) RealMatrix[M_co, N_co, float]
- __add__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a + b
- __sub__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int] #
- __sub__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __sub__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int]
- __sub__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __sub__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __sub__(other: int) RealMatrix[M_co, N_co, int]
- __sub__(other: float) RealMatrix[M_co, N_co, float]
- __sub__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a - b
- __mul__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int] #
- __mul__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __mul__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int]
- __mul__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __mul__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __mul__(other: int) RealMatrix[M_co, N_co, int]
- __mul__(other: float) RealMatrix[M_co, N_co, float]
- __mul__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a * b
- __matmul__(other: RealMatrix[N_co, P_co, int]) RealMatrix[M_co, P_co, int] #
- __matmul__(other: RealMatrix[N_co, P_co, float]) RealMatrix[M_co, P_co, float]
- __matmul__(other: ComplexMatrix[N_co, P_co, int]) ComplexMatrix[M_co, P_co, int]
- __matmul__(other: ComplexMatrix[N_co, P_co, float]) ComplexMatrix[M_co, P_co, float]
- __matmul__(other: ComplexMatrix[N_co, P_co, complex]) ComplexMatrix[M_co, P_co, complex]
Return the matrix product
- __truediv__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float] #
- __truediv__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __truediv__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __truediv__(other: float) RealMatrix[M_co, N_co, float]
- __truediv__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a / b
- __floordiv__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int] #
- __floordiv__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __floordiv__(other: int) RealMatrix[M_co, N_co, int]
- __floordiv__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
a // b
- __mod__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int] #
- __mod__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __mod__(other: int) RealMatrix[M_co, N_co, int]
- __mod__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
a % b
- __divmod__(other: RealMatrix[M_co, N_co, int]) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, int], matrixlib.builtins.RealMatrix[+M_co, +N_co, int]] #
- __divmod__(other: RealMatrix[M_co, N_co, float]) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, float], matrixlib.builtins.RealMatrix[+M_co, +N_co, float]]
- __divmod__(other: int) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, int], matrixlib.builtins.RealMatrix[+M_co, +N_co, int]]
- __divmod__(other: float) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, float], matrixlib.builtins.RealMatrix[+M_co, +N_co, float]]
Return element-wise
divmod(a, b)
- __radd__(other: int) RealMatrix[M_co, N_co, int] #
- __radd__(other: float) RealMatrix[M_co, N_co, float]
- __radd__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b + a
- __rsub__(other: int) RealMatrix[M_co, N_co, int] #
- __rsub__(other: float) RealMatrix[M_co, N_co, float]
- __rsub__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b - a
- __rmul__(other: int) RealMatrix[M_co, N_co, int] #
- __rmul__(other: float) RealMatrix[M_co, N_co, float]
- __rmul__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b * a
- __rtruediv__(other: float) RealMatrix[M_co, N_co, float] #
- __rtruediv__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b / a
- __rfloordiv__(other: int) RealMatrix[M_co, N_co, int] #
- __rfloordiv__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
b // a
- __rmod__(other: int) RealMatrix[M_co, N_co, int] #
- __rmod__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
b % a
- __rdivmod__(other: int) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, int], matrixlib.builtins.RealMatrix[+M_co, +N_co, int]] #
- __rdivmod__(other: float) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, float], matrixlib.builtins.RealMatrix[+M_co, +N_co, float]]
Return element-wise
divmod(b, a)
- __neg__() RealMatrix[M_co, N_co, int] #
- __neg__() RealMatrix[M_co, N_co, float]
Return element-wise
-a
- __pos__() RealMatrix[M_co, N_co, int] #
- __pos__() RealMatrix[M_co, N_co, float]
Return element-wise
+a
- materialize() RealMatrix[M_co, N_co, R_co] #
Return a materialized copy of the matrix
Certain methods (particularly those that permute the matrix’s values in some fashion) construct a view onto the underlying sequence to preserve memory. These views can “stack” onto one another, which can drastically increase access time.
This method addresses said issue by shallowly placing the elements into a new sequence - a process that we call “materialization”. The resulting matrix instance will have access times identical to that of an instance created from an array-and-shape pairing, but note that this may consume significant amounts of memory (depending on the size of the matrix).
If the matrix does not store a kind of view, this method returns a matrix that is semantically equivalent to the original. We call such matrices “materialized”, or “material”, as they store a sequence whose elements already exist in the desired order.
Think of materialization as being akin to compiling regular expressions: if the same matrix permutation is required in many different places, it’s much more time-efficient to materialize it, and use the resulting material matrix as a substituting variable.
- transpose() RealMatrix[N_co, M_co, R_co] #
Return a transposed view of the matrix
- flip(*, by: Rule = Rule.ROW) RealMatrix[M_co, N_co, R_co] #
Return a flipped view of the matrix
- rotate(n: Literal[-16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16]) RealMatrix[M_co, N_co, R_co] #
- rotate(n: Literal[-15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]) RealMatrix[N_co, M_co, R_co]
- rotate(n: int) RealMatrix[Any, Any, R_co]
- rotate() RealMatrix[N_co, M_co, R_co]
Return a rotated view of the matrix
Rotates the matrix
n
times in increments of 90 degrees. The matrix is rotated counter-clockwise ifn
is positive, and clockwise ifn
is negative. All integers are accepted, but many (particularly those outside of a small range near zero) will lose typing precision.
- reverse() RealMatrix[M_co, N_co, R_co] #
Return a reversed view of the matrix
- slices(*, by: ~typing.Literal[<Rule.ROW: 0>], reverse: bool = False) Iterator[RealMatrix[Literal[1], N_co, R_co]] #
- slices(*, by: ~typing.Literal[<Rule.COL: 1>], reverse: bool = False) Iterator[RealMatrix[M_co, Literal[1], R_co]]
- slices(*, by: Rule, reverse: bool = False) Iterator[RealMatrix[Any, Any, R_co]]
- slices(*, reverse: bool = False) Iterator[RealMatrix[Literal[1], N_co, R_co]]
Return an iterator over the rows or columns of the matrix
- conjugate() RealMatrix[M_co, N_co, int] #
- conjugate() RealMatrix[M_co, N_co, float]
Return element-wise
a.conjugate()
- transjugate() RealMatrix[N_co, M_co, int] #
- transjugate() RealMatrix[N_co, M_co, float]
Return the conjugate transpose
The returned matrix may or may not be a view depending on the active class.
- compare(other: RealMatrix[Any, Any, float]) Literal[-1, 0, 1] #
Return literal
-1
,0
, or+1
if the matrix lexicographically compares less than, equal, or greater thanother
, respectivelyMatrices are lexicographically compared values first, shapes second - similar to how built-in sequences compare values first, lengths second.
- lesser(other: RealMatrix[M_co, N_co, float]) IntegerMatrix[M_co, N_co, bool] #
- lesser(other: float) IntegerMatrix[M_co, N_co, bool]
Return element-wise
a < b
- lesser_equal(other: RealMatrix[M_co, N_co, float]) IntegerMatrix[M_co, N_co, bool] #
- lesser_equal(other: float) IntegerMatrix[M_co, N_co, bool]
Return element-wise
a <= b
- greater(other: RealMatrix[M_co, N_co, float]) IntegerMatrix[M_co, N_co, bool] #
- greater(other: float) IntegerMatrix[M_co, N_co, bool]
Return element-wise
a > b
- greater_equal(other: RealMatrix[M_co, N_co, float]) IntegerMatrix[M_co, N_co, bool] #
- greater_equal(other: float) IntegerMatrix[M_co, N_co, bool]
Return element-wise
a >= b
- class matrixlib.builtins.IntegerMatrix(array: Mesh[M_co, N_co, T_co])#
- class matrixlib.builtins.IntegerMatrix(array: Matrix[M_co, N_co, T_co])
- class matrixlib.builtins.IntegerMatrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.ROW: 0>])
- class matrixlib.builtins.IntegerMatrix(array: ~collections.abc.Iterable[~matrixlib.builtins.T_co], shape: ~typing.Literal[<Rule.COL: 1>])
- class matrixlib.builtins.IntegerMatrix(array: Iterable[T_co], shape: Rule)
- class matrixlib.builtins.IntegerMatrix(array: Iterable[T_co], shape: tuple[+M_co, +N_co])
Built-in
RealMatrix
sub-class constrained to instances ofint
- __getitem__(key: int) I_co #
- __getitem__(key: slice) IntegerMatrix[Literal[1], Any, I_co]
- __getitem__(key: tuple[int, int]) I_co
- __getitem__(key: tuple[int, slice]) IntegerMatrix[Literal[1], Any, I_co]
- __getitem__(key: tuple[slice, int]) IntegerMatrix[Any, Literal[1], I_co]
- __getitem__(key: tuple[slice, slice]) IntegerMatrix[Any, Any, I_co]
Return the value or sub-matrix corresponding to
key
- __add__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int] #
- __add__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int]
- __add__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __add__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int]
- __add__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __add__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __add__(other: int) IntegerMatrix[M_co, N_co, int]
- __add__(other: float) RealMatrix[M_co, N_co, float]
- __add__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a + b
- __sub__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int] #
- __sub__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int]
- __sub__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __sub__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int]
- __sub__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __sub__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __sub__(other: int) IntegerMatrix[M_co, N_co, int]
- __sub__(other: float) RealMatrix[M_co, N_co, float]
- __sub__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a - b
- __mul__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int] #
- __mul__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int]
- __mul__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __mul__(other: ComplexMatrix[M_co, N_co, int]) ComplexMatrix[M_co, N_co, int]
- __mul__(other: ComplexMatrix[M_co, N_co, float]) ComplexMatrix[M_co, N_co, float]
- __mul__(other: ComplexMatrix[M_co, N_co, complex]) ComplexMatrix[M_co, N_co, complex]
- __mul__(other: int) IntegerMatrix[M_co, N_co, int]
- __mul__(other: float) RealMatrix[M_co, N_co, float]
- __mul__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
a * b
- __matmul__(other: IntegerMatrix[N_co, P_co, int]) IntegerMatrix[M_co, P_co, int] #
- __matmul__(other: RealMatrix[N_co, P_co, int]) RealMatrix[M_co, P_co, int]
- __matmul__(other: RealMatrix[N_co, P_co, float]) RealMatrix[M_co, P_co, float]
- __matmul__(other: ComplexMatrix[N_co, P_co, int]) ComplexMatrix[M_co, P_co, int]
- __matmul__(other: ComplexMatrix[N_co, P_co, float]) ComplexMatrix[M_co, P_co, float]
- __matmul__(other: ComplexMatrix[N_co, P_co, complex]) ComplexMatrix[M_co, P_co, complex]
Return the matrix product
- __floordiv__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int] #
- __floordiv__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int]
- __floordiv__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __floordiv__(other: int) IntegerMatrix[M_co, N_co, int]
- __floordiv__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
a // b
- __mod__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int] #
- __mod__(other: RealMatrix[M_co, N_co, int]) RealMatrix[M_co, N_co, int]
- __mod__(other: RealMatrix[M_co, N_co, float]) RealMatrix[M_co, N_co, float]
- __mod__(other: int) IntegerMatrix[M_co, N_co, int]
- __mod__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
a % b
- __divmod__(other: IntegerMatrix[M_co, N_co, int]) tuple[matrixlib.builtins.IntegerMatrix[+M_co, +N_co, int], matrixlib.builtins.IntegerMatrix[+M_co, +N_co, int]] #
- __divmod__(other: RealMatrix[M_co, N_co, int]) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, int], matrixlib.builtins.RealMatrix[+M_co, +N_co, int]]
- __divmod__(other: RealMatrix[M_co, N_co, float]) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, float], matrixlib.builtins.RealMatrix[+M_co, +N_co, float]]
- __divmod__(other: int) tuple[matrixlib.builtins.IntegerMatrix[+M_co, +N_co, int], matrixlib.builtins.IntegerMatrix[+M_co, +N_co, int]]
- __divmod__(other: float) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, float], matrixlib.builtins.RealMatrix[+M_co, +N_co, float]]
Return element-wise
divmod(a, b)
- __lshift__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int] #
- __lshift__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
a << b
- __rshift__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int] #
- __rshift__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
a >> b
- __and__(other: IntegerMatrix[M_co, N_co, bool]) IntegerMatrix[M_co, N_co, bool] #
- __and__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int]
- __and__(other: bool) IntegerMatrix[M_co, N_co, bool]
- __and__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
a & b
- __xor__(other: IntegerMatrix[M_co, N_co, bool]) IntegerMatrix[M_co, N_co, bool] #
- __xor__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int]
- __xor__(other: bool) IntegerMatrix[M_co, N_co, bool]
- __xor__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
a ^ b
- __or__(other: IntegerMatrix[M_co, N_co, bool]) IntegerMatrix[M_co, N_co, bool] #
- __or__(other: IntegerMatrix[M_co, N_co, int]) IntegerMatrix[M_co, N_co, int]
- __or__(other: bool) IntegerMatrix[M_co, N_co, bool]
- __or__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
a | b
- __radd__(other: int) IntegerMatrix[M_co, N_co, int] #
- __radd__(other: float) RealMatrix[M_co, N_co, float]
- __radd__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b + a
- __rsub__(other: int) IntegerMatrix[M_co, N_co, int] #
- __rsub__(other: float) RealMatrix[M_co, N_co, float]
- __rsub__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b - a
- __rmul__(other: int) IntegerMatrix[M_co, N_co, int] #
- __rmul__(other: float) RealMatrix[M_co, N_co, float]
- __rmul__(other: complex) ComplexMatrix[M_co, N_co, complex]
Return element-wise
b * a
- __rfloordiv__(other: int) IntegerMatrix[M_co, N_co, int] #
- __rfloordiv__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
b // a
- __rmod__(other: int) IntegerMatrix[M_co, N_co, int] #
- __rmod__(other: float) RealMatrix[M_co, N_co, float]
Return element-wise
b % a
- __rdivmod__(other: int) tuple[matrixlib.builtins.IntegerMatrix[+M_co, +N_co, int], matrixlib.builtins.IntegerMatrix[+M_co, +N_co, int]] #
- __rdivmod__(other: float) tuple[matrixlib.builtins.RealMatrix[+M_co, +N_co, float], matrixlib.builtins.RealMatrix[+M_co, +N_co, float]]
Return element-wise
divmod(b, a)
- __rlshift__(other: int) IntegerMatrix[M_co, N_co, int] #
Return element-wise
b << a
- __rrshift__(other: int) IntegerMatrix[M_co, N_co, int] #
Return element-wise
b >> a
- __rand__(other: bool) IntegerMatrix[M_co, N_co, bool] #
- __rand__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
b & a
- __rxor__(other: bool) IntegerMatrix[M_co, N_co, bool] #
- __rxor__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
b ^ a
- __ror__(other: bool) IntegerMatrix[M_co, N_co, bool] #
- __ror__(other: int) IntegerMatrix[M_co, N_co, int]
Return element-wise
b | a
- __neg__() IntegerMatrix[M_co, N_co, int] #
Return element-wise
-a
- __pos__() IntegerMatrix[M_co, N_co, int] #
Return element-wise
+a
- __abs__() IntegerMatrix[M_co, N_co, int] #
Return element-wise
abs(a)
- __invert__() IntegerMatrix[M_co, N_co, bool] #
- __invert__() IntegerMatrix[M_co, N_co, int]
Return element-wise
~a
- materialize() IntegerMatrix[M_co, N_co, I_co] #
Return a materialized copy of the matrix
Certain methods (particularly those that permute the matrix’s values in some fashion) construct a view onto the underlying sequence to preserve memory. These views can “stack” onto one another, which can drastically increase access time.
This method addresses said issue by shallowly placing the elements into a new sequence - a process that we call “materialization”. The resulting matrix instance will have access times identical to that of an instance created from an array-and-shape pairing, but note that this may consume significant amounts of memory (depending on the size of the matrix).
If the matrix does not store a kind of view, this method returns a matrix that is semantically equivalent to the original. We call such matrices “materialized”, or “material”, as they store a sequence whose elements already exist in the desired order.
Think of materialization as being akin to compiling regular expressions: if the same matrix permutation is required in many different places, it’s much more time-efficient to materialize it, and use the resulting material matrix as a substituting variable.
- transpose() IntegerMatrix[N_co, M_co, I_co] #
Return a transposed view of the matrix
- flip(*, by: Rule = Rule.ROW) IntegerMatrix[M_co, N_co, I_co] #
Return a flipped view of the matrix
- rotate(n: Literal[-16, -14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, 14, 16]) IntegerMatrix[M_co, N_co, I_co] #
- rotate(n: Literal[-15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15]) IntegerMatrix[N_co, M_co, I_co]
- rotate(n: int) IntegerMatrix[Any, Any, I_co]
- rotate() IntegerMatrix[N_co, M_co, I_co]
Return a rotated view of the matrix
Rotates the matrix
n
times in increments of 90 degrees. The matrix is rotated counter-clockwise ifn
is positive, and clockwise ifn
is negative. All integers are accepted, but many (particularly those outside of a small range near zero) will lose typing precision.
- reverse() IntegerMatrix[M_co, N_co, I_co] #
Return a reversed view of the matrix
- slices(*, by: ~typing.Literal[<Rule.ROW: 0>], reverse: bool = False) Iterator[IntegerMatrix[Literal[1], N_co, I_co]] #
- slices(*, by: ~typing.Literal[<Rule.COL: 1>], reverse: bool = False) Iterator[IntegerMatrix[M_co, Literal[1], I_co]]
- slices(*, by: Rule, reverse: bool = False) Iterator[IntegerMatrix[Any, Any, I_co]]
- slices(*, reverse: bool = False) Iterator[IntegerMatrix[Literal[1], N_co, I_co]]
Return an iterator over the rows or columns of the matrix
- conjugate() IntegerMatrix[M_co, N_co, int] #
Return element-wise
a.conjugate()
- transjugate() IntegerMatrix[N_co, M_co, int] #
Return the conjugate transpose
The returned matrix may or may not be a view depending on the active class.
- matrixlib.builtins.IntegralMatrix: TypeAlias = <class 'matrixlib.builtins.IntegerMatrix'>#
Type alias of
IntegerMatrix