math-test-functions 0.5.2

A collection of non linear functions for testing optimisation algorithms
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Schwefel2 test function

use ndarray::Array1;

/// Schwefel function variant (different from the main schwefel)
pub fn schwefel2(x: &Array1<f64>) -> f64 {
    let n = x.len();
    let sum: f64 = x
        .iter()
        .enumerate()
        .map(|(i, &xi)| {
            let inner_sum: f64 = x.iter().take(i + 1).copied().sum();
            inner_sum.powi(2)
        })
        .sum();
    sum
}