[][src]Function rulinalg::utils::in_place_vec_bin_op

pub fn in_place_vec_bin_op<F, T>(u: &mut [T], v: &[T], f: F) where
    F: FnMut(&mut T, &T),
    T: Copy

Vectorized binary operation applied to two slices. The first argument should be a mutable slice which will be modified in place to prevent new memory allocation.

Examples

use rulinalg::utils;

let mut a = vec![2.0; 10];
let b = vec![3.0; 10];

utils::in_place_vec_bin_op(&mut a, &b, |x, &y| { *x = 1f64 + *x * y });

// Will print a vector of `7`s.
println!("{:?}", a);