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//! - Automatic CPU SIMD capability detection
11//!
12//! ## Usage
13//! ```
14//! use rill_core::vector::prelude::*;
15//!
16//! let a = ScalarVector4::splat(1.0);
17//! let b = ScalarVector4::splat(2.0);
18//! let c = a + b;
19//! assert_eq!(c, ScalarVector4::splat(3.0));
20//! ```
21//!
22//! ## Architecture
23//! - `traits` — core traits (`Vector`, `VectorOps`, `VectorMath`)
24//! - `ops` — arithmetic operator implementations
25//! - `math` — math function implementations
26//! - `simd` — SIMD backends for different architectures
27//! - `scalar` — scalar fallback implementations
28//!
29//! ## Supported platforms
30//! - x86/x86_64: SSE2, SSE4.1, AVX, AVX2, AVX512 (runtime detection)
31//! - ARM: NEON (AArch64)
32//! - WebAssembly: SIMD128
33//! - Scalar fallback for platforms without SIMD
34
35#![allow(unused_imports)]
36#![allow(dead_code)]
37
38/// Vector construction macros.
39pub mod macros;
40/// Vector math functions (sin, cos, etc.).
41pub mod math;
42/// Arithmetic operator implementations for vectors.
43pub mod ops;
44/// Scalar fallback vector implementations.
45pub mod scalar;
46/// Core vector traits (`Vector`, `VectorTranscendental`, etc.).
47pub mod traits;
48
49#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
50/// SIMD-accelerated vector implementations.
51pub mod simd;
52
53// Re-exports
54pub use macros::*;
55pub use math::*;
56pub use ops::*;
57pub use scalar::*;
58pub use traits::*;
59
60/// Convenience prelude for importing all vector types and traits.
61pub mod prelude {
62    pub use crate::math::vector::macros::*;
63    pub use crate::math::vector::math::*;
64    pub use crate::math::vector::ops::*;
65    pub use crate::math::vector::scalar::*;
66    pub use crate::math::vector::traits::*;
67
68    /// SIMD vector types (conditionally available).
69    #[cfg(feature = "simd")]
70    pub use crate::math::vector::simd::*;
71
72    /// Scalar (non-SIMD) vector types.
73    pub use crate::math::vector::scalar::{
74        ScalarVector1, ScalarVector2, ScalarVector4, ScalarVector8,
75    };
76}