Expand description
Utility functions for matrix printing, shape retrieval, identity generation, Kronecker product, trace, transpose operations, …
These functions were necessary for implementing this crate. They are exposed because they can be generally useful, but this is not meant to be a complete collection of linear algebra utilities at this time.
Functions§
- dims2
- Make sure that matrix shapes are compatible with
A * B, and return the dimensions(m, n)safely cast toi32 - dims3
- Make sure that matrix shapes are compatible with
C = A * B, and return the dimensions(m, n, k)safely cast toi32, whereCis(m x n), andkis the common dimension ofAandB - identity
- Creates an identity matrix of size
n x n. - identity_
k - Creates a diagonal matrix of size
n x nwith ones on a specified diagonal. - into_
i32 - Safely casts a value to
i32 - ipiv_
to_ perm_ mat - Convert pivot indices to permutation matrix
- kron
- Computes the Kronecker product of two 2D tensors.
- pretty_
print - Displays a numeric
mdarrayin a human-readable format (NumPy-style) - to_
col_ major - Given an input matrix of shape
(m × n), this function creates and returns a new matrix of shape(n × m), where each element at position(i, j)in the original is moved to position(j, i)in the result. - trace
- Computes the trace of a square matrix (sum of diagonal elements).
- transpose_
in_ place - Transposes a matrix in-place. Dimensions stay the same, only the memory ordering changes.
- unravel_
index - Converts a flat index to multidimensional coordinates.