octonion
Minimal, dependency-free, no_std octonion algebra for Rust.
This crate provides Octonion (an 8D hypercomplex number over f64) with
basic arithmetic, conjugation, norms, and inversion.
Quick start
use Octonion;
let x = new;
// Basis elements square to -1.
assert_eq!;
// Non-commutativity.
assert_eq!;
assert_eq!;
// Conjugation, norm, inverse.
let _conj = x.conj;
let _norm_sq = x.norm_sqr;
let _inv = x.try_inverse.unwrap;
Notes
- Octonion multiplication is non-associative. If you need explicit grouping,
enable
alloc(on by default) and useParenorOctoExpr. - If an octonion lies in the quaternion subalgebra (its
e₄..e₇coefficients are exactly zero), you can callOctonion::as_quaternionto get aQuaternionViewthat supports associative multiplication.
SIMD helpers
The octonion::simd module includes a direct coefficient expansion
simd::mul_direct (often easier for the compiler to auto-vectorize than the
default implementation).
On x86_64 with avx, simd::mul_simd_avx is available (currently a thin
wrapper around mul_direct).
Features
alloc(default): enables [Paren], [OctoExpr], andsimd::mul_batch.alloc(default): enablesParen,OctoExpr, andsimd::mul_batch.e8: enablesoctonion::e8::IntegralOctonion(Cayley integers / E8 lattice).
To use this crate without allocation support:
= { = "0.1", = false }
Examples and benches
- Colorized display demo:
cargo run --example display_demo - Benchmarks:
cargo bench