Function lattice_qcd_rs::statistics::mean_par_iter_val
source · pub fn mean_par_iter_val<It, T>(data: It) -> Twhere
T: Clone + Div<f64, Output = T> + Sum<T> + Sum<It::Item> + Send,
It: IndexedParallelIterator<Item = T>,
Expand description
Compute the mean from a [rayon::iter::IndexedParallelIterator
]. If you want
to use reference use mean_par_iter
.
It uses the power of the parallel iterator to do the computation and is
particularly useful in combination of a map.
Example
use lattice_qcd_rs::statistics::mean_par_iter_val;
use rayon::prelude::*;
fn expensive_computation(input: &f64) -> f64 {
input + 1_f64
}
let vec = vec![1_f64, 2_f64, 3_f64, 4_f64];
let mean = mean_par_iter_val(vec.par_iter().map(|input| expensive_computation(input)));