A linear algebra library developed in Rust, focusing on providing a clean and intuitive API for common mathematical operations.
Haje is a small, unopinionated library you can embed into your Rust app. It provides:
- Complex Numbers: Full implementation of complex number arithmetic.
- Vectors: Generic
Vec2,Vec3, andVec4types with standard operations. - Matrices: Support for arbitrary dimensions using const generics:
Matrix<T, ROWS, COLS>. - Physics & Grids: Wave packet generation and discrete Laplacian operator.
- Quantum Computing: Qubit state containers and tensor-product helpers.
Quick links
- Security policy: SECURITY.md
- Contributing guide: CONTRIBUTING.md
- Code of Conduct: CODE_OF_CONDUCT.md
- Support: SUPPORT.md
- License: MIT (LICENSE)
- Repository: GitHub
- Language: Rust (2024 edition)
- Build System: Cargo
- Minimum Rust: 1.80+ (for const generics support used in the library)
- Frameworks: Standard library,
num-traits(planned) - Distribution: Crates.io
src/: The core library source code.complex.rs: Complex number arithmetic.matrix.rs: Generic matrix implementation.quantum/: Qubit and quantum gate logic.vec/: Vector implementations (Vec2,Vec3,Vec4).
tests/: Comprehensive test suite for all modules.
- Rust 1.80+
- Cargo
Add the dependency to your Cargo.toml:
[dependencies]
haje = "0.2.0"Create a minimal application using complex numbers and vectors:
use haje::complex::Complex;
use haje::vec::Vec3;
fn main() {
// Complex number arithmetic
let a = Complex::new(1.0, 2.0);
let b = Complex::new(3.0, 4.0);
let c = a + b;
println!("Sum: {:?}", c);
// Vector operations
let v1 = Vec3 { x: 1.0, y: 0.0, z: 0.0 };
let v2 = Vec3 { x: 0.0, y: 1.0, z: 0.0 };
let v3 = v1.cross(v2);
println!("Cross product: {:?}", v3);
}The project uses Cargo for all common tasks:
cargo build: Build the project.cargo test: Run all tests.cargo run: Run the example/main entry point.cargo fmt: Format the codebase.cargo clippy: Run linting checks.
Haje is designed to be a pure library and doesn't rely on specific environment variables by default.
Haje doesn’t force a particular math backend or architecture. It provides building blocks for your mathematical simulations.
Leverages Rust's zero-cost abstractions and const generics to provide compile-time optimizations for fixed-size matrices and vectors.
Every module comes with a dedicated test suite in the tests/ directory, ensuring reliability and correctness of mathematical operations.
Core entry points:
haje::complex::Complex— Complex number operations.haje::matrix::Matrix<T, R, C>— Fixed-size matrix operations.haje::vec::Vec3— 3D vector operations.haje::quantum::Qubit— Quantum state representation.
The test suite is authoritative and aims for high coverage.
- Run tests:
cargo test
We welcome contributions! Please see CONTRIBUTING.md and CODE_OF_CONDUCT.md.
MIT — © 2025 Jadiefication