Skip to main content

Module matrix

Module matrix 

Source
Expand description

Dense row-major matrix type and utility functions.

Matrix<T> is a simple dense 2D matrix in row-major layout, indexed by m[[row, col]]. It is used throughout the TCI infrastructure for pivot block computations, cross interpolation factors, and dense submatrix extraction.

§Examples

use tensor4all_tcicore::{Matrix, from_vec2d, matrix};

let m = from_vec2d(vec![
    vec![1.0_f64, 2.0],
    vec![3.0, 4.0],
]);
assert_eq!(m.nrows(), 2);
assert_eq!(m.ncols(), 2);
assert_eq!(m[[0, 1]], 2.0);
assert_eq!(m[[1, 0]], 3.0);

Structs§

Matrix
A dense 2D matrix in row-major layout.

Traits§

BlasMul
BLAS-backed matrix multiplication dispatch.

Functions§

a_inv_times_b
Calculates A^{-1} * B using Gaussian elimination.
a_times_b_inv
Calculates A * B^{-1} using Gaussian elimination.
append_col
Append a column to the right of a matrix.
append_row
Append a row to the bottom of a matrix.
dot
Dot product of two vectors.
eye
Create an n x n identity matrix.
from_vec2d
Create a matrix from a 2D vector (row-major).
get_col
Get a column as a vector.
get_row
Get a row as a vector.
mat_mul
Matrix multiplication: A * B.
ncols
Get number of columns.
nrows
Get number of rows.
random_subset
Select a random subset of up to n elements from a slice.
set_diff
Set difference: elements in set that are not in exclude.
submatrix
Get a submatrix by selecting specific rows and columns.
submatrix_argmax
Find the position and value of the maximum absolute value in a submatrix.
swap_cols
Swap two columns in a matrix in-place.
swap_rows
Swap two rows in a matrix in-place.
transpose
Transpose the matrix.
zeros
Create a zeros matrix with given dimensions.