oxiblas-ndarray 0.1.0

ndarray integration for OxiBLAS
Documentation
oxiblas-ndarray-0.1.0 has been yanked.

OxiBLAS ndarray Integration

This crate provides seamless integration between OxiBLAS and the ndarray crate, allowing you to use OxiBLAS BLAS and LAPACK operations directly on ndarray types.

Features

  • Conversions: Efficient conversion between ndarray and OxiBLAS matrix types
  • BLAS Operations: Level 1-3 BLAS operations (dot, gemv, gemm, etc.)
  • LAPACK Operations: Decompositions (LU, QR, SVD, EVD, Cholesky)
  • Linear Solve: Direct and iterative solvers

Quick Start

use ndarray::{array, Array2};
use oxiblas_ndarray::prelude::*;

// Matrix multiplication
let a = Array2::from_shape_fn((2, 3), |(i, j)| (i * 3 + j + 1) as f64);
let b = Array2::from_shape_fn((3, 2), |(i, j)| (i * 2 + j + 1) as f64);
let c = matmul(&a, &b);
assert_eq!(c.dim(), (2, 2));

// Matrix-vector multiplication
let x = array![1.0f64, 2.0, 3.0];
let y = matvec(&a, &x);
assert_eq!(y.len(), 2);

// Dot product
let v1 = array![1.0f64, 2.0, 3.0];
let v2 = array![4.0f64, 5.0, 6.0];
let d = dot_ndarray(&v1, &v2);
assert!((d - 32.0).abs() < 1e-10);

LAPACK Operations

use ndarray::array;
use oxiblas_ndarray::prelude::*;

// Solve linear system
let a = array![[2.0f64, 1.0], [1.0, 3.0]];
let b = array![5.0f64, 7.0];
let x = solve_ndarray(&a, &b).unwrap();

// LU decomposition
let lu = lu_ndarray(&a).unwrap();
let det = lu.det();  // Determinant

// QR decomposition
let qr = qr_ndarray(&a).unwrap();

// SVD
let svd = svd_ndarray(&a).unwrap();

// Symmetric eigenvalue decomposition
let evd = eig_symmetric(&a).unwrap();

Memory Layout

OxiBLAS uses column-major (Fortran) order internally. This crate handles both row-major and column-major ndarray layouts:

  • Column-major arrays: Zero-copy or minimal-copy operations
  • Row-major arrays: Automatic conversion (with copy) when needed

For best performance, use column-major arrays when possible:

use ndarray::{Array2, ShapeBuilder};
use oxiblas_ndarray::prelude::*;

// Create column-major array (preferred)
let a: Array2<f64> = zeros_f(100, 100);
assert!(is_column_major(&a));

// Or convert existing row-major array
let row_major = Array2::<f64>::zeros((100, 100));
let col_major = to_column_major(&row_major);