Skip to content

Commit a30b9d7

Browse files
committed
Replaced inline value 1e-10 with constant as suggested by copilot
1 parent d066bee commit a30b9d7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/signal_analysis/yin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ fn difference_function(f: &[f64], lag: usize) -> f64 {
9494
sum
9595
}
9696

97+
const EPSILON: f64 = 1e-10;
9798
fn cumulative_mean_normalized_difference_function(df: &[f64], max_lag: usize) -> Vec<f64> {
9899
let mut cmndf = vec![0.0; max_lag + 1];
99100
cmndf[0] = 1.0;
100101
let mut sum = 0.0;
101102
for lag in 1..=max_lag {
102103
sum += df[lag];
103-
cmndf[lag] = lag as f64 * df[lag] / if sum == 0.0 { 1e-10 } else { sum };
104+
cmndf[lag] = lag as f64 * df[lag] / if sum == 0.0 { EPSILON } else { sum };
104105
}
105106
cmndf
106107
}

0 commit comments

Comments
 (0)