pub struct F32Matrix { /* private fields */ }Expand description
Owned finite f32 matrix stored in row-major order.
Implementations§
Source§impl F32Matrix
impl F32Matrix
Sourcepub fn new(shape: MatrixShape, values: Vec<f32>) -> Result<Self>
pub fn new(shape: MatrixShape, values: Vec<f32>) -> Result<Self>
Creates a row-major matrix after shape and finite-value validation.
Sourcepub fn zeros(rows: usize, cols: usize) -> Result<Self>
pub fn zeros(rows: usize, cols: usize) -> Result<Self>
Creates a row-major matrix filled with zeros.
Sourcepub fn from_rows<const R: usize, const C: usize>(
rows: [[f32; C]; R],
) -> Result<Self>
pub fn from_rows<const R: usize, const C: usize>( rows: [[f32; C]; R], ) -> Result<Self>
Builds a matrix from compile-time-sized row arrays.
Sourcepub fn shape(&self) -> MatrixShape
pub fn shape(&self) -> MatrixShape
Returns the checked row and column dimensions.
Sourcepub fn layout(&self) -> MatrixLayout
pub fn layout(&self) -> MatrixLayout
Returns the matrix storage layout.
Sourcepub fn into_values(self) -> Vec<f32>
pub fn into_values(self) -> Vec<f32>
Consumes the matrix and returns its contiguous values.
Sourcepub fn as_view(&self) -> F32MatrixView<'_>
pub fn as_view(&self) -> F32MatrixView<'_>
Borrows this matrix as a view without copying values.
Sourcepub fn row(&self, index: usize) -> Result<RowView<'_>>
pub fn row(&self, index: usize) -> Result<RowView<'_>>
Borrows one row, respecting the current matrix layout.
Sourcepub fn column(&self, index: usize) -> Result<ColumnView<'_>>
pub fn column(&self, index: usize) -> Result<ColumnView<'_>>
Borrows one column, respecting the current matrix layout.
Sourcepub fn matmul(&self, right: &F32MatrixView<'_>) -> Result<Self>
pub fn matmul(&self, right: &F32MatrixView<'_>) -> Result<Self>
Multiplies this matrix by right.
Sourcepub fn matvec(&self, vector: &[f32]) -> Result<DenseVector>
pub fn matvec(&self, vector: &[f32]) -> Result<DenseVector>
Multiplies this matrix by a finite dense vector.
Sourcepub fn transpose_view(&self) -> F32MatrixView<'_>
pub fn transpose_view(&self) -> F32MatrixView<'_>
Creates a transposed view without copying values.
Sourcepub fn transpose_owned(&self) -> Result<Self>
pub fn transpose_owned(&self) -> Result<Self>
Returns a row-major owned transpose of this matrix.
Sourcepub fn l2_normalize_rows(&self) -> Result<Self>
pub fn l2_normalize_rows(&self) -> Result<Self>
Returns a row-major matrix whose rows have unit L2 norm.
Sourcepub fn l2_normalize_columns(&self) -> Result<Self>
pub fn l2_normalize_columns(&self) -> Result<Self>
Returns a row-major matrix whose columns have unit L2 norm.
Sourcepub fn pairwise_row_cosine(&self, right: &F32MatrixView<'_>) -> Result<Self>
pub fn pairwise_row_cosine(&self, right: &F32MatrixView<'_>) -> Result<Self>
Computes all pairwise row cosine similarities against right.
Sourcepub fn lu_decompose(&self) -> Result<LuDecomposition>
pub fn lu_decompose(&self) -> Result<LuDecomposition>
Decomposes this square matrix using LU factorization with partial pivoting.
Sourcepub fn determinant(&self) -> Result<f32>
pub fn determinant(&self) -> Result<f32>
Computes this square matrix determinant through LU decomposition.
Sourcepub fn solve_vector(&self, b: &[f32]) -> Result<Vec<f32>>
pub fn solve_vector(&self, b: &[f32]) -> Result<Vec<f32>>
Solves A x = b for a finite vector b.
Sourcepub fn solve_matrix(&self, b: &F32MatrixView<'_>) -> Result<Self>
pub fn solve_matrix(&self, b: &F32MatrixView<'_>) -> Result<Self>
Solves A X = B for matrix B.