Avoid unnecessary Vec reallocations when computing time_points
This commit is contained in:
parent
8aad020521
commit
1c08116f10
@ -191,8 +191,8 @@ pub fn fit_interval_censored_cox(data_times: Matrix2xX<f64>, mut data_indep: DMa
|
|||||||
|
|
||||||
// Get time points (t_0 = 0, t_1, ..., t_m)
|
// Get time points (t_0 = 0, t_1, ..., t_m)
|
||||||
// TODO: Reimplement Turnbull intervals
|
// TODO: Reimplement Turnbull intervals
|
||||||
let mut time_points: Vec<f64>;
|
let mut time_points: Vec<f64> = Vec::with_capacity(data_times.len() + 1);
|
||||||
time_points = data_times.iter().copied().collect();
|
time_points.extend(data_times.iter());
|
||||||
time_points.push(0.0); // Ensure 0 is in the list
|
time_points.push(0.0); // Ensure 0 is in the list
|
||||||
//time_points.push(f64::INFINITY); // Ensure infinity is on the list
|
//time_points.push(f64::INFINITY); // Ensure infinity is on the list
|
||||||
time_points.sort_by(|a, b| a.partial_cmp(b).unwrap()); // Cannot use .sort() as f64 does not implement Ord
|
time_points.sort_by(|a, b| a.partial_cmp(b).unwrap()); // Cannot use .sort() as f64 does not implement Ord
|
||||||
|
Loading…
Reference in New Issue
Block a user