diff --git a/src/history.rs b/src/history.rs index 920469c..6d4439c 100644 --- a/src/history.rs +++ b/src/history.rs @@ -332,10 +332,23 @@ impl, O: Observer, K: Eq + Hash + Clone> History f64 { - self.time_slices - .iter() - .map(|ts| ts.log_evidence(self.online, targets, forward, &self.agents)) - .sum() + #[cfg(feature = "rayon")] + { + use rayon::prelude::*; + let per_slice: Vec = self + .time_slices + .par_iter() + .map(|ts| ts.log_evidence(self.online, targets, forward, &self.agents)) + .collect(); + per_slice.into_iter().sum() + } + #[cfg(not(feature = "rayon"))] + { + self.time_slices + .iter() + .map(|ts| ts.log_evidence(self.online, targets, forward, &self.agents)) + .sum() + } } /// Total log-evidence across the history.