Skip to content

Commit

Permalink
Fix panic-error thanks to clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kkafar committed Apr 12, 2024
1 parent 43d1775 commit e0c68b0
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions src/test_functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,9 @@ pub fn de_jong_n5(x: &[f64]) -> f64 {
for i in (-32..33).step_by(16) {
b.append(&mut vec![i as f64; 5]);
}
let a = vec![a1, b];
let a = [a1, b];
for i in 1..26 {
sum += 1_f64 / i as f64 + f64::powi(x1 - a[1][i], 6) + f64::powi(x2 - a[2][i], 6);
sum += 1_f64 / i as f64 + f64::powi(x1 - a[0][i], 6) + f64::powi(x2 - a[1][i], 6);
}
f64::powf(0.002 + sum, -1_f64)
}
Expand Down Expand Up @@ -1253,18 +1253,14 @@ pub fn hartmann_3d(x: &[f64]) -> f64 {
"Hartmann 3-dimensional function takes only a three dimensional vector as a parameter."
);
let alfa = [1.0, 1.2, 3.0, 3.2];
let a = vec![
vec![3.0, 10.0, 30.0],
let a = [vec![3.0, 10.0, 30.0],
vec![0.1, 10.0, 35.0],
vec![3.0, 10.0, 30.0],
vec![0.1, 10.0, 35.0],
];
let p = vec![
vec![3.689, 1.17, 2.673],
vec![0.1, 10.0, 35.0]];
let p = [vec![3.689, 1.17, 2.673],
vec![4.699, 4.387, 7.47],
vec![1.091, 8.732, 5.547],
vec![0.381, 5.743, 8.828],
];
vec![0.381, 5.743, 8.828]];
let mut res = 0_f64;
for i in 1..5 {
let mut sum = 0_f64;
Expand All @@ -1286,18 +1282,14 @@ pub fn hartmann_4d(x: &[f64]) -> f64 {
"Hartmann 4-dimensional function takes only a three dimensional vector as a parameter."
);
let alfa = [1.0, 1.2, 3.0, 3.2];
let a = vec![
vec![10.0, 3.0, 17.0, 3.5, 1.7, 8.0],
let a = [vec![10.0, 3.0, 17.0, 3.5, 1.7, 8.0],
vec![0.05, 10.0, 17.0, 0.1, 8.0, 14.0],
vec![3.0, 3.5, 1.7, 10.0, 17.0, 8.0],
vec![17.0, 8.0, 0.05, 10.0, 0.1, 14.0],
];
let p = vec![
vec![1.312, 1.696, 5.569, 1.24, 8.283, 5.886],
vec![17.0, 8.0, 0.05, 10.0, 0.1, 14.0]];
let p = [vec![1.312, 1.696, 5.569, 1.24, 8.283, 5.886],
vec![2.329, 4.135, 8.307, 3.736, 1.004, 9.991],
vec![2.348, 1.451, 3.522, 2.883, 3.047, 6.650],
vec![4.047, 8.828, 8.732, 5.743, 1.091, 3.81],
];
vec![4.047, 8.828, 8.732, 5.743, 1.091, 3.81]];
let mut sum = 0_f64;
for i in 1..5 {
let mut inner_sum = 0_f64;
Expand All @@ -1321,18 +1313,14 @@ pub fn hartmann_6d(x: &[f64]) -> f64 {
"Hartmann 6-dimensional function takes only a six dimensional vector as a parameter."
);
let alfa = [1.0, 1.2, 3.0, 3.2];
let a = vec![
vec![10.0, 3.0, 17.0, 3.5, 1.7, 8.0],
let a = [vec![10.0, 3.0, 17.0, 3.5, 1.7, 8.0],
vec![0.05, 10.0, 17.0, 0.1, 8.0, 14.0],
vec![3.0, 3.5, 1.7, 10.0, 17.0, 8.0],
vec![17.0, 8.0, 0.05, 10.0, 0.1, 14.0],
];
let p = vec![
vec![1.312, 1.696, 5.569, 1.24, 8.283, 5.886],
vec![17.0, 8.0, 0.05, 10.0, 0.1, 14.0]];
let p = [vec![1.312, 1.696, 5.569, 1.24, 8.283, 5.886],
vec![2.329, 4.135, 8.307, 3.736, 1.004, 9.991],
vec![2.348, 1.451, 0.522, 2.883, 3.047, 6.650],
vec![4.047, 8.828, 8.732, 5.743, 1.091, 3.81],
];
vec![4.047, 8.828, 8.732, 5.743, 1.091, 3.81]];
let mut sum = 0_f64;
for i in 1..5 {
let mut inner_sum = 0_f64;
Expand Down Expand Up @@ -2377,12 +2365,10 @@ pub fn shekel_default(x: &[f64]) -> f64 {
let mut res = 0.0;
let raw = vec![1.0, 2.0, 2.0, 4.0, 4.0, 6.0, 3.0, 7.0, 5.0, 5.0];
let beta = raw.into_iter().map(|x| 0.1 * x).collect::<Vec<_>>();
let c = vec![
vec![4.0, 1.0, 8.0, 6.0, 3.0, 2.0, 5.0, 8.0, 6.0, 7.0],
let c = [vec![4.0, 1.0, 8.0, 6.0, 3.0, 2.0, 5.0, 8.0, 6.0, 7.0],
vec![4.0, 1.0, 8.0, 6.0, 7.0, 9.0, 3.0, 1.0, 2.0, 3.6],
vec![4.0, 1.0, 8.0, 6.0, 3.0, 2.0, 5.0, 8.0, 6.0, 7.0],
vec![4.0, 1.0, 8.0, 6.0, 7.0, 9.0, 3.0, 1.0, 2.0, 3.6],
];
vec![4.0, 1.0, 8.0, 6.0, 7.0, 9.0, 3.0, 1.0, 2.0, 3.6]];
for i in 1..11 {
let mut sum = 0_f64;
for j in 1..5 {
Expand Down

0 comments on commit e0c68b0

Please sign in to comment.