Expand description
Arithmetic operator implementations for vectors.
§Arithmetic operations for vectors
Implementation of basic arithmetic operations for vector types.
§Types
| Type | Purpose |
|---|---|
add_slices / sub_slices / … | Low-level element-wise ops (write to pre-allocated buffer) |
SliceMut | Mutable slice wrapper — supports +=, -=, *=, /= operator syntax |
SlicePair | Two-slice pair — supports .add_into() / .sub_into() / .mul_into() / .div_into() |
§Usage
use rill_core::math::vector::ops::{SliceMut, SlicePair};
use rill_core::prelude::ScalarVector4;
let a = [1.0f32, 2.0, 3.0, 4.0];
let b = [5.0f32, 6.0, 7.0, 8.0];
let mut out = [0.0f32; 4];
// Pair ops: compute a + b → out
SlicePair::new(&a, &b).add_into::<4, ScalarVector4<f32>>(&mut out);
// Accumulation: out += a (element-wise via += operator)
let mut out_mut = SliceMut::new(&mut out);
out_mut += &a as &[f32];
// Scalar broadcast: out *= 2.0
out_mut *= 2.0;Structs§
- Slice
Mut - A mutable slice that supports element-wise
+=,-=,*=,/=with another slice or scalar broadcast. - Slice
Pair - A pair of immutable slices, providing SIMD-accelerated element-wise binary operations that write the result into a pre-allocated output buffer.
Functions§
- add_
scalar_ slice - Add a scalar to a slice
- add_
slices - Element-wise addition of two slices, storing the result in a third
- div_
slices - Element-wise division of two slices
- mul_
scalar_ slice - Multiply a slice by a scalar
- mul_
slices - Element-wise multiplication of two slices
- sub_
slices - Element-wise subtraction of two slices