math_audio_test_functions/functions/schwefel2.rs
1//! Schwefel2 test function
2
3use ndarray::Array1;
4
5/// Schwefel function variant (different from the main schwefel)
6pub fn schwefel2(x: &Array1<f64>) -> f64 {
7 let n = x.len();
8 let sum: f64 = x
9 .iter()
10 .enumerate()
11 .map(|(i, &xi)| {
12 let inner_sum: f64 = x.iter().take(i + 1).copied().sum();
13 inner_sum.powi(2)
14 })
15 .sum();
16 sum
17}