Macro ndarray_parallel::par_azip
[−]
[src]
macro_rules! par_azip { (@parse [index => $a:expr, $($aa:expr,)*] $t1:tt in $t2:tt) => { ... }; (@parse [$a:expr, $($aa:expr,)*] $t1:tt in $t2:tt) => { ... }; (@finish ($z:expr) [$($aa:expr,)*] [$($p:pat,)+] in { $($t:tt)*}) => { ... }; (@parse [] [] index $i:pat, $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] mut $x:ident ($e:expr) $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] mut $x:ident $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] , $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] ref $x:ident ($e:expr) $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] ref $x:ident $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] $x:ident ($e:expr) $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] $x:ident $($t:tt)*) => { ... }; (@parse [$($exprs:tt)*] [$($pats:tt)*] $($t:tt)*) => { ... }; ($($t:tt)*) => { ... }; }
Parallel version of the azip!
macro.
See the azip!
documentation for more details.
This example:
⚠Be careful when using this code, it's not being tested!
par_azip!(mut a, b, c in { *a = b + c })
Is equivalent to:
⚠Be careful when using this code, it's not being tested!
Zip::from(&mut a).and(&b).and(&c).par_apply(|a, &b, &c| { *a = b + c; });
Panics if any of the arrays are not of the same shape.
Examples
extern crate ndarray; #[macro_use(par_azip)] extern crate ndarray_parallel; use ndarray::Array2; type M = Array2<f32>; fn main() { let mut a = M::zeros((16, 16)); let b = M::from_elem(a.dim(), 1.); let c = M::from_elem(a.dim(), 2.); // Compute a simple ternary operation: // elementwise addition of b and c, stored in a par_azip!(mut a, b, c in { *a = b + c }); assert_eq!(a, &b + &c); }