turnbull: Parallelise get_sum_fail_prob
37% speeedup
This commit is contained in:
parent
18a0679476
commit
2c54c2be02
@ -24,6 +24,7 @@ use csv::{Reader, StringRecord};
|
|||||||
use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
|
||||||
use nalgebra::{Const, DMatrix, DVector, Dyn, MatrixXx2};
|
use nalgebra::{Const, DMatrix, DVector, Dyn, MatrixXx2};
|
||||||
use prettytable::{Table, format, row};
|
use prettytable::{Table, format, row};
|
||||||
|
use rayon::prelude::*;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
use crate::term::UnconditionalTermLike;
|
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> {
|
fn get_sum_fail_prob(data: &TurnbullData, s: &Vec<f64>) -> Vec<f64> {
|
||||||
return data.data_time_interval_indexes
|
return data.data_time_interval_indexes
|
||||||
.iter()
|
.par_iter()
|
||||||
.map(|(idx_left, idx_right)| s[*idx_left..(*idx_right + 1)].iter().sum())
|
.map(|(idx_left, idx_right)| s[*idx_left..(*idx_right + 1)].iter().sum())
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user