oxiblas-matrix 0.1.0

Matrix types and views for OxiBLAS
Documentation

OxiBLAS Matrix - Matrix types and views for OxiBLAS.

This crate provides the core matrix types for OxiBLAS:

  • [Mat<T>]: Owned, heap-allocated matrix with column-major storage
  • [CowMat<T>]: Copy-on-Write matrix for efficient sharing
  • [MatRef<'a, T>]: Immutable view into a matrix
  • [MatMut<'a, T>]: Mutable view with reborrow semantics

Specialized Matrix Types

  • [packed::PackedMat<T>]: Packed triangular/symmetric storage
  • [banded::BandedMat<T>]: Banded matrix storage
  • [triangular::TriangularMat<T>]: Triangular matrix with packed storage
  • [symmetric::SymmetricMat<T>]: Symmetric matrix with packed storage
  • [symmetric::HermitianMat<T>]: Hermitian matrix with packed storage

Memory Layout

All matrices use column-major (Fortran) storage order. This means elements within a column are contiguous in memory. The storage is aligned for efficient SIMD operations.

Views and Reborrows

The view types (MatRef, MatMut) do not own their data. They can represent submatrices, transposed views, or any strided data.

MatMut uses the reborrow pattern to prevent aliasing:

  • rb() creates an immutable reborrow
  • rb_mut() creates a mutable reborrow with a shorter lifetime

Example

use oxiblas_matrix::{Mat, MatRef, MatMut};

// Create a matrix
let mut m: Mat<f64> = Mat::zeros(4, 4);

// Modify through a mutable view
{
    let mut view = m.as_mut();
    view[(0, 0)] = 1.0;
    view[(1, 1)] = 2.0;
    view[(2, 2)] = 3.0;
    view[(3, 3)] = 4.0;
}

// Read through an immutable view
let view = m.as_ref();
assert_eq!(view.diagonal()[2], 3.0);