math_audio_optimisation/
mutant_rand2.rs1use ndarray::{Array1, Array2};
2use rand::Rng;
3
4use crate::distinct_indices::distinct_indices;
5
6pub(crate) fn mutant_rand2<R: Rng + ?Sized>(
7 i: usize,
8 pop: &Array2<f64>,
9 f: f64,
10 rng: &mut R,
11) -> Array1<f64> {
12 let idxs = distinct_indices(i, 5, pop.nrows(), rng);
13 let r0 = idxs[0];
14 let r1 = idxs[1];
15 let r2 = idxs[2];
16 let r3 = idxs[3];
17 let r4 = idxs[4];
18 &pop.row(r0).to_owned()
19 + &((pop.row(r1).to_owned() + pop.row(r2).to_owned()
20 - pop.row(r3).to_owned()
21 - pop.row(r4).to_owned())
22 * f)
23}