Skip to main content

Module macros

Module macros 

Source
Expand description

Vector construction macros. Macros for convenient construction of vector expressions.

This module provides macros that simplify working with the vector eDSL, allowing expressions in natural mathematical notation.

§Examples

use rill_core::vector::prelude::*;
use rill_core::vector::macros::*;

let a = ScalarVector4::splat(1.0);
let b = ScalarVector4::splat(2.0);
let c = a + b; // regular vector operation
assert_eq!(c, ScalarVector4::splat(3.0));

// Apply expression to the entire slice
let input = [1.0f32, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
let mut output = [0.0f32; 8];
vec_map!(&input, &mut output, |x| x * 2.0 + 1.0);
// output = [3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0]

§Available macros

  • vec_map! – applies a vector expression to the entire slice.

Macros§

vec_map
Map over SIMD vector chunks of size 4, applying a closure to each chunk.