turnbull: Parallelise get_sum_fail_prob

37% speeedup
This commit is contained in:
RunasSudo 2023-10-27 23:11:29 +11:00
parent 18a0679476
commit 2c54c2be02
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -24,6 +24,7 @@ use csv::{Reader, StringRecord};
use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
use nalgebra::{Const, DMatrix, DVector, Dyn, MatrixXx2};
use prettytable::{Table, format, row};
use rayon::prelude::*;
use serde::{Serialize, Deserialize};
use crate::term::UnconditionalTermLike;
@ -321,7 +322,7 @@ fn fit_turnbull_estimator(data: &mut TurnbullData, progress_bar: ProgressBar, ma
fn get_sum_fail_prob(data: &TurnbullData, s: &Vec<f64>) -> Vec<f64> {
return data.data_time_interval_indexes
.iter()
.par_iter()
.map(|(idx_left, idx_right)| s[*idx_left..(*idx_right + 1)].iter().sum())
.collect();
}