Skip to content

Commit

Permalink
Buffered basic element-wise ops (eg. add_into)
Browse files Browse the repository at this point in the history
  • Loading branch information
unic0rn9k committed May 9, 2022
1 parent 3caa448 commit 4331ccd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Empty file added dirty
Empty file.
15 changes: 14 additions & 1 deletion src/backends/rust.rs
Expand Up @@ -83,14 +83,27 @@ macro_rules! impl_basic_op {
}
}

paste!{
impl<'a, const LEN: usize> StaticVecUnion<'a, $t, LEN> {
/// Basic element-wise vector operations (buffered), implemented automatically with macro.
#[inline(always)]
pub fn [<$fn _into>]<'b>(&self, other: &Self, buffer: MutStaticVecRef<'b, $t, LEN>){
$op::$fn(&Rust, self, other, buffer);
}
}
}

paste!{
#[test]
fn [< basic_ $fn _ $t >](){
let a = moo![$t: 1..13];
let b = a.$fn(&a);
let mut c = [0.; 12];
a.[<$fn _into>](&a, c.mut_moo_ref());

for n in 0..12{
assert_eq!(a[n] $float_op a[n], b[n])
assert_eq!(a[n] $float_op a[n], b[n]);
assert_eq!(a[n] $float_op a[n], c[n]);
}
}
}
Expand Down

0 comments on commit 4331ccd

Please sign in to comment.