| Crates.io | avila-math |
| lib.rs | avila-math |
| version | 0.1.0 |
| created_at | 2025-11-22 21:01:53.83098+00 |
| updated_at | 2025-11-22 21:01:53.83098+00 |
| description | Arxis Foundation: The ARX (fortress) - Mathematical kernel with quaternions, tensors, 4D geometry, Conv4D, differential operators |
| homepage | https://arxis.avilaops.com |
| repository | https://github.com/avilaops/arxis |
| max_upload_size | |
| id | 1945734 |
| size | 380,472 |
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.
Quat3D): Rotations, SLERP interpolation, axis-angleDualQuat): Rigid body transformations (rotation + translation)[dependencies]
avila-math = { git = "https://github.com/avilaops/arxis", branch = "main" }
# With serialization support
avila-math = { git = "https://github.com/avilaops/arxis", branch = "main", features = ["serde"] }
use avila_math::geometry::Quat3D;
use std::f64::consts::PI;
// Create rotation quaternion
let q = Quat3D::from_axis_angle([0.0, 0.0, 1.0], PI / 2.0);
// Rotate vector
let v = q.rotate_vector([1.0, 0.0, 0.0]);
// v β [0.0, 1.0, 0.0]
// SLERP interpolation
let q2 = Quat3D::from_axis_angle([0.0, 0.0, 1.0], PI);
let interpolated = q.slerp(&q2, 0.5);
use avila_math::linalg::{svd, eigenvalues, solve_linear_system};
use avila_math::tensor::{Matrix, Vector};
// SVD decomposition
let m = Matrix::from_data([3, 2], vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0]).unwrap();
let (u, singular_values, vt) = svd(&m).unwrap();
// Eigenvalues
let symmetric = Matrix::from_data([2, 2], vec![2.0, 1.0, 1.0, 2.0]).unwrap();
let eigenvals = eigenvalues(&symmetric).unwrap();
// Solve Ax = b
let a = Matrix::from_data([2, 2], vec![2.0, 1.0, 1.0, 3.0]).unwrap();
let b = Vector::from_slice(&[5.0, 6.0]);
let x = solve_linear_system(&a, &b).unwrap();
use avila_math::tensor::{Conv4DLayer, Conv4DConfig, Tensor6D};
// Create 4D convolutional layer
let mut layer = Conv4DLayer::new(
8, // in_channels
16, // out_channels
[3, 3, 3, 3], // kernel_size
Conv4DConfig::default()
).with_bias(16);
layer.init_xavier();
// Forward pass
let input = Tensor6D::zeros([2, 8, 16, 16, 16, 16]); // [batch, channels, d1, d2, d3, d4]
let output = layer.forward(&input).unwrap();
// Backward pass for training
let grad_output = Tensor6D::filled(output.shape, 0.1);
let (grad_input, grad_weights, grad_bias) = layer.backward(&input, &grad_output).unwrap();
use avila_math::calculus::{gradient_4d, laplacian_4d, divergence_4d};
// Scalar field: f(x,y,z,w) = xΒ² + yΒ² + zΒ² + wΒ²
let f = |p: &[f64]| p[0]*p[0] + p[1]*p[1] + p[2]*p[2] + p[3]*p[3];
// Gradient: βf = [2x, 2y, 2z, 2w]
let grad = gradient_4d(&f, &[1.0, 2.0, 3.0, 4.0], 1e-7);
// Laplacian: βΒ²f = 8
let lap = laplacian_4d(&f, &[1.0, 2.0, 3.0, 4.0], 1e-5);
// Vector field divergence
let field = |p: &[f64; 4]| [p[0], p[1], p[2], p[3]];
let div = divergence_4d(&field, &[1.0, 2.0, 3.0, 4.0], 1e-5);
use avila_math::interpolation::{BezierCurve4D, cubic_spline_4d, catmull_rom_4d};
// BΓ©zier curve
let control_points = vec![
[0.0, 0.0, 0.0, 0.0],
[1.0, 2.0, 0.0, 0.0],
[2.0, 0.0, 0.0, 0.0],
];
let curve = BezierCurve4D::new(control_points);
let point = curve.eval(0.5);
// Cubic spline
let points = vec![
[0.0, 0.0, 0.0, 0.0],
[1.0, 1.0, 1.0, 1.0],
[2.0, 0.0, 0.0, 0.0],
];
let interpolated = cubic_spline_4d(&points, 0.75);
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Run specific module
cargo test --lib tensor::
# Run all benchmarks
cargo bench
# Run specific benchmark
cargo bench tensor_ops
cargo bench conv4d
cargo bench quaternions
cargo bench fft
Optimized for Brazil/LATAM workloads with:
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
See CONTRIBUTING.md for guidelines.
Licensed under either of:
at your option.
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 π¦