avila-math
ποΈ The Foundation of Arxis
Mathematical kernel - The solid bedrock upon which Arxis (ARX + AXIS) is built
avila-math is the mathematical citadel - providing unshakeable foundations for the entire Avila ecosystem (vision, engine, arxis).
Like the ARX (Latin: fortress), this crate provides the solid mathematical primitives that protect the integrity of all computations.
β¨ Features
π― Geometry
- 3D Quaternions (
Quat3D): Rotations, SLERP interpolation, axis-angle - Dual Quaternions (
DualQuat): Rigid body transformations (rotation + translation) - SO(4) Rotations: 4D rotations using SΒ³ Γ SΒ³ representation
- 4D Geometry: Tesseract, 24-cell, simplex, projections (4Dβ3D)
- AABB: Axis-aligned bounding boxes for collision detection
π Tensors & Linear Algebra
- Vectors: 2D, 3D, 4D with dot product, cross product, normalization
- Matrices: 3Γ3, 4Γ4 with multiplication, determinant, inverse, transpose
- N-D Tensors: Generalized tensor operations (convolution, pooling, etc.)
- Conv4D: 4D convolutional neural networks with forward/backward pass
- SIMD Optimizations: AVX2 accelerated operations
- In-place Operations: Zero-copy tensor manipulations
π¬ Advanced Linear Algebra
- SVD: Singular Value Decomposition
- Eigenvalues/Eigenvectors: Symmetric and general matrices
- QR Decomposition: Orthogonal factorization
- LU Decomposition: Lower-upper factorization
- Linear System Solvers: Direct and least-squares methods
- Matrix Rank & Condition Number: Numerical analysis tools
π Signal Processing
- FFT: 1D, 2D, 3D, 4D Fast Fourier Transform
- Spectral Analysis: Power spectral density, spectrograms
- Wavelets: CWT, DWT for gravitational wave detection (LISA)
- Window Functions: Hann, Hamming, Blackman, Kaiser
- Cross-correlation: Signal comparison and alignment
β Calculus & Differential Operators (4D)
- Gradient: βf in 4D space
- Divergence: βΒ·F for vector fields
- Curl: Generalized 4D curl (bivector)
- Laplacian: βΒ²f for scalar fields
- D'Alembertian: Wave operator β‘ for relativity
- Hessian: Second-order derivatives
- Jacobian: Function vector derivatives
- Directional Derivatives: Rates along vectors
π¨ Interpolation (4D)
- Linear: lerp, bilinear, trilinear, quadrilinear
- BΓ©zier Curves: Quadratic, cubic, arbitrary degree
- Cubic Splines: Natural and Catmull-Rom
- B-splines: Uniform basis splines
- Hermite Interpolation: Tangent-aware curves
π§ Additional Features
- Serde Support: Serialize/deserialize tensors (feature flag)
- Benchmarks: Criterion-based performance testing
- Pure Rust: 100% native implementation
- Parallel Computing: Rayon for Conv4D operations
π¦ Installation
[]
= { = "https://github.com/avilaops/arxis", = "main" }
# With serialization support
= { = "https://github.com/avilaops/arxis", = "main", = ["serde"] }
π Usage Examples
Quaternions & Rotations
use Quat3D;
use PI;
// Create rotation quaternion
let q = from_axis_angle;
// Rotate vector
let v = q.rotate_vector;
// v β [0.0, 1.0, 0.0]
// SLERP interpolation
let q2 = from_axis_angle;
let interpolated = q.slerp;
Linear Algebra
use ;
use ;
// SVD decomposition
let m = from_data.unwrap;
let = svd.unwrap;
// Eigenvalues
let symmetric = from_data.unwrap;
let eigenvals = eigenvalues.unwrap;
// Solve Ax = b
let a = from_data.unwrap;
let b = from_slice;
let x = solve_linear_system.unwrap;
Conv4D Neural Networks
use ;
// Create 4D convolutional layer
let mut layer = new.with_bias;
layer.init_xavier;
// Forward pass
let input = zeros; // [batch, channels, d1, d2, d3, d4]
let output = layer.forward.unwrap;
// Backward pass for training
let grad_output = filled;
let = layer.backward.unwrap;
Differential Calculus (4D)
use ;
// Scalar field: f(x,y,z,w) = xΒ² + yΒ² + zΒ² + wΒ²
let f = ;
// Gradient: βf = [2x, 2y, 2z, 2w]
let grad = gradient_4d;
// Laplacian: βΒ²f = 8
let lap = laplacian_4d;
// Vector field divergence
let field = ;
let div = divergence_4d;
Interpolation & Curves
use ;
// BΓ©zier curve
let control_points = vec!;
let curve = new;
let point = curve.eval;
// Cubic spline
let points = vec!;
let interpolated = cubic_spline_4d;
π§ͺ Testing
# Run all tests
# Run with output
# Run specific module
β‘ Benchmarks
# Run all benchmarks
# Run specific benchmark
π Performance
Optimized for Brazil/LATAM workloads with:
- AVX2 SIMD: 4x speedup on compatible CPUs
- Rayon Parallelism: Multi-core Conv4D operations
- Zero-copy: In-place tensor operations
- LTO Optimization: Link-time optimization in release builds
ποΈ Project Structure
avila-math/
βββ src/
β βββ geometry/ # Quaternions, 4D geometry
β βββ tensor/ # N-D tensors, Conv4D
β βββ signal/ # FFT, wavelets, spectral analysis
β βββ linalg/ # SVD, eigenvalues, solvers
β βββ calculus/ # Differential operators
β βββ interpolation/ # Curves and splines
βββ benches/ # Criterion benchmarks
βββ .github/workflows/ # CI/CD automation
π€ Contributing
See CONTRIBUTING.md for guidelines.
π License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
ποΈ Part of Arxis
avila-math is the foundation stone of Arxis - the mathematical citadel.
ARX (fortress) + AXIS (engine) = ARXIS
Built with β€οΈ by Avila
136 tests passing β | 4 benchmarks β‘ | Pure Rust π¦