Skip to main content

Module ops

Module ops 

Source
Expand description

Arithmetic operator implementations for vectors.

§Arithmetic operations for vectors

Implementation of basic arithmetic operations for vector types.

§Types

TypePurpose
add_slices / sub_slices / …Low-level element-wise ops (write to pre-allocated buffer)
SliceMutMutable slice wrapper — supports +=, -=, *=, /= operator syntax
SlicePairTwo-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§

SliceMut
A mutable slice that supports element-wise +=, -=, *=, /= with another slice or scalar broadcast.
SlicePair
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