Skip to main content

rill_core/math/vector/
mod.rs

1//! # Vector operations for DSP
2//!
3//! This module provides an embedded domain-specific language (eDSL) for vector
4//! operations optimised with SIMD instructions.
5//!
6//! ## Features
7//! - Basic vector types for f32 and f64 with various SIMD lane widths
8//! - Arithmetic operations (+, -, *, /, %)
9//! - Math functions (sin, cos, exp, ln, sqrt, ...)
10//! - Expression system for lazy evaluation and optimisations
11//! - Automatic CPU SIMD capability detection
12//!
13//! ## Usage
14//! ```
15//! use rill_core::vector::prelude::*;
16//!
17//! let a = ScalarVector4::splat(1.0);
18//! let b = ScalarVector4::splat(2.0);
19//! let c = a + b;
20//! assert_eq!(c, ScalarVector4::splat(3.0));
21//! ```
22//!
23//! ## Architecture
24//! - `traits` — core traits (`Vector`, `VectorOps`, `VectorMath`)
25//! - `ops` — arithmetic operator implementations
26//! - `math` — math function implementations
27//! - `simd` — SIMD backends for different architectures
28//! - `expr` — expression system and optimisations
29//! - `scalar` — scalar fallback implementations
30//!
31//! ## Supported platforms
32//! - x86/x86_64: SSE2, SSE4.1, AVX, AVX2, AVX512 (runtime detection)
33//! - ARM: NEON (AArch64)
34//! - WebAssembly: SIMD128
35//! - Scalar fallback for platforms without SIMD
36
37#![allow(unused_imports)]
38#![allow(dead_code)]
39
40/// Vector math functions (sin, cos, etc.).
41pub mod math;
42/// Arithmetic operator implementations for vectors.
43pub mod ops;
44/// Core vector traits (`Vector`, `VectorTranscendental`, etc.).
45pub mod traits;
46// pub mod expr;  // temporarily disabled due to compilation errors
47/// Vector construction macros.
48pub mod macros;
49/// Scalar fallback vector implementations.
50pub mod scalar;
51
52#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
53/// SIMD-accelerated vector implementations.
54pub mod simd;
55
56// Re-exports
57pub use math::*;
58pub use ops::*;
59pub use traits::*;
60// pub use expr::*;
61pub use macros::*;
62pub use scalar::*;
63
64/// Convenience prelude for importing all vector types and traits.
65pub mod prelude {
66    pub use crate::math::vector::math::*;
67    pub use crate::math::vector::ops::*;
68    pub use crate::math::vector::traits::*;
69    // pub use crate::math::vector::expr::*;  // temporarily disabled
70    pub use crate::math::vector::macros::*;
71    pub use crate::math::vector::scalar::*;
72
73    /// SIMD vector types (conditionally available).
74    #[cfg(feature = "simd")]
75    pub use crate::math::vector::simd::*;
76
77    /// Scalar (non-SIMD) vector types.
78    pub use crate::math::vector::scalar::{ScalarVector1, ScalarVector2, ScalarVector4, ScalarVector8};
79}