pub trait ForEachElement<T: CountElements>: AllocateZeros {
    fn foreach_m<F: FnMut(&mut T::Dtype)>(a: &mut T, f: &mut F);
    fn foreach_mr<F>(a: &mut T, b: &T, f: &mut F)
    where
        F: FnMut(&mut T::Dtype, &T::Dtype)
; fn foreach_mm<F>(a: &mut T, b: &mut T, f: &mut F)
    where
        F: FnMut(&mut T::Dtype, &mut T::Dtype)
; fn foreach_mmm<F>(a: &mut T, b: &mut T, c: &mut T, f: &mut F)
    where
        F: FnMut(&mut T::Dtype, &mut T::Dtype, &mut T::Dtype)
; fn foreach_mrr<F>(a: &mut T, b: &T, c: &T, f: &mut F)
    where
        F: FnMut(&mut T::Dtype, &T::Dtype, &T::Dtype)
; }
Expand description

Apply generic function to various forms/numbers of ndarrays.

The various versions that exist are:

Examples:

let mut a = [[0.0; 3]; 2];
let b = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
Cpu::foreach_mr(&mut a, &b, &mut |x, y| {
    *x = 2.0 * y;
});
assert_eq!(a, [[2.0, 4.0, 6.0], [8.0, 10.0, 12.0]]);

Required Methods

Mutate elements of a by applying f to all elements of a.

Mutate elements of a by applying f to all elements of (a, b). mr stands for mut ref

Mutate elements of a and b by applying f to all elements of (a, b). mm stands for mut mut

Mutate elements of a, b, and c by applying f to all elements of (a, b, c). mmm stands for mut mut mut

Mutate elements of a by applying f to all elements of (a, b, c). mrr stands for mut ref ref

Implementors