oxiblas
Unified API for OxiBLAS - Pure Rust BLAS/LAPACK implementation
Overview
oxiblas is the meta-crate that re-exports all OxiBLAS functionality through a unified, convenient API. This is the recommended way to use OxiBLAS for most users.
Features
- Complete BLAS - Level 1, 2, 3 operations
- Extensive LAPACK - LU, QR, SVD, Cholesky, EVD, and more
- Sparse matrices - 9 formats with iterative solvers
- Tensor operations - Einstein summation, batched operations
- Extended precision - f16, f128 support
- High performance - Competitive with OpenBLAS for typical workloads; see oxiblas-benchmarks for reproducible numbers on your own hardware
- Pure Rust - No C dependencies, easy cross-compilation
Quick Start
[]
= "0.2"
# With all features
= { = "0.2", = ["full"] }
Usage
Matrix Operations
use *;
// Create matrices
let a = from_rows;
let b = from_rows;
// Matrix multiplication
let mut c = zeros;
gemm;
// c = [[58, 64], [139, 154]]
Linear Algebra
use *;
let a = from_rows;
// LU decomposition
let lu = compute?;
let det = lu.determinant;
let inv = lu.inverse?;
// QR decomposition
let qr = compute?;
let q = qr.q;
let r = qr.r;
// SVD
let svd = compute?;
let singular_values = svd.singular_values;
// Solve Ax = b (b is an n x 1 matrix, i.e. a column vector)
let b = from_rows;
let x = lu.solve?;
Sparse Matrices
use *;
// Create sparse matrix
let mut coo = new_empty;
coo.push;
coo.push;
// ... add more elements
let csr = coo.to_csr;
// Solve sparse system with GMRES
let b = vec!;
let x0 = vec!; // initial guess
let result = gmres?;
let x = result.x;
Tensor Operations
// Tensor operations live in `oxiblas-blas`'s `tensor` module and are not
// part of `oxiblas::prelude` - import them from `oxiblas::blas::tensor`.
use ;
// Einstein summation: matrix multiplication (A: 2x3, B: 3x2)
let a = vec!;
let b = vec!;
let c = einsum?;
// Batched matrix multiplication
let = ;
let data_a = vec!;
let data_b = vec!;
let a_batch = from_data;
let b_batch = from_data;
let c_batch = batched_matmul?;
Module Structure
The oxiblas crate re-exports from these sub-crates:
| Module | Re-exported from | Description |
|---|---|---|
oxiblas::core |
oxiblas-core |
Core traits, SIMD, scalar types |
oxiblas::matrix |
oxiblas-matrix |
Matrix types and views |
oxiblas::blas |
oxiblas-blas |
BLAS operations |
oxiblas::lapack |
oxiblas-lapack |
LAPACK decompositions |
oxiblas::sparse |
oxiblas-sparse |
Sparse matrices and solvers |
oxiblas::ndarray |
oxiblas-ndarray |
ndarray integration (optional) |
oxiblas-ffi |
RETIRED (v0.2.0) - C FFI bindings |
Prelude
The oxiblas::prelude module provides convenient imports:
use *;
// Now you have access to:
// - Mat, MatRef, MatMut (matrix types)
// - gemm, gemv, dot, axpy, etc. (BLAS operations)
// - Lu, Qr, Svd, Cholesky, etc. (LAPACK decompositions)
// - CsrMatrix, CooMatrix, etc. (sparse matrices)
// - gmres, cg, bicgstab, etc. (sparse solvers)
Feature Flags
| Feature | Description | Default |
|---|---|---|
default |
Core functionality (f32, f64, complex) | ✓ |
parallel |
Rayon-based parallelization | |
f16 |
Half-precision (16-bit) floating point | |
f128 |
Quad-precision (~31 digits) | |
sparse |
Sparse matrix operations | ✓ |
ndarray |
ndarray integration | |
serde |
Serialization support for matrix types | |
mmap |
Memory-mapped matrices for large datasets | |
nalgebra |
nalgebra type conversions | |
full |
All features enabled | |
force-scalar |
Disable all SIMD optimizations (scalar only) | |
max-simd-128 |
Limit SIMD to 128-bit registers (SSE/NEON) | |
max-simd-256 |
Limit SIMD to 256-bit registers (AVX2) |
Note:
oxiblas-ffi(C FFI bindings) was retired in v0.2.0 and is no longer a feature of this crate - see the Module Structure table above.
Examples
# Minimal (dense matrices only)
= "0.2"
# With parallelization
= { = "0.2", = ["parallel"] }
# With extended precision
= { = "0.2", = ["f16", "f128"] }
# With ndarray support
= { = "0.2", = ["ndarray"] }
# All features
= { = "0.2", = ["full"] }
Examples
The repository includes comprehensive examples:
# Basic BLAS operations
# LAPACK decompositions
# Extended precision
# Tensor operations
# Sparse matrices
Performance
OxiBLAS is competitive with OpenBLAS for typical workloads (dense GEMM, BLAS Level 1-3, LAPACK decompositions), thanks to BLIS-style blocked algorithms and hand-tuned SIMD micro-kernels. Actual performance depends heavily on operation, matrix size, and hardware (SIMD width, cache hierarchy, core count), so no single ratio is representative.
Run the benchmark suite yourself for numbers reproducible on your own hardware:
# OxiBLAS-only benchmarks
# Direct comparison against OpenBLAS (requires OpenBLAS installed)
See the oxiblas-benchmarks README for details on the available benchmark suites.
Documentation
- Main README - Project overview and features
- API Documentation - Complete API reference
- Examples - Usage examples
- Benchmarks README - Performance benchmarking guide
Sub-Crate Documentation
For more detailed documentation on specific components:
- oxiblas-core - Core traits and SIMD
- oxiblas-matrix - Matrix types
- oxiblas-blas - BLAS operations
- oxiblas-lapack - LAPACK decompositions
- oxiblas-sparse - Sparse matrices
- oxiblas-ndarray - ndarray integration
- oxiblas-benchmarks - Benchmarking suite
Ecosystem
OxiBLAS is part of the SciRS2 scientific computing ecosystem:
- SciRS2 - Scientific computing library
- NumRS2 - Numerical computing
- SkleaRS - Machine learning
- ToRSh - Tensor operations
- TrustformeRS - Transformers
- QuantRS2 - Quantum computing framework
- OxiRS - Semantic Web platform
Requirements
- Rust: 1.85+ (Edition 2024)
- No external C dependencies
- Supported platforms: x86_64, AArch64 (Linux, macOS, Windows)
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Citation
If you use OxiBLAS in your research, please cite: