autoeq_optim/loss/drivers/
driver_measurement.rs1use ndarray::Array1;
2
3#[derive(Debug, Clone)]
5pub struct DriverMeasurement {
6 pub freq: Array1<f64>,
8 pub spl: Array1<f64>,
10 pub phase: Option<Array1<f64>>,
12}
13
14impl DriverMeasurement {
15 pub fn new(freq: Array1<f64>, spl: Array1<f64>, phase: Option<Array1<f64>>) -> Self {
17 assert_eq!(freq.len(), spl.len(), "freq and spl must have same length");
18 if let Some(ref p) = phase {
19 assert_eq!(freq.len(), p.len(), "freq and phase must have same length");
20 }
21 Self { freq, spl, phase }
22 }
23
24 pub fn freq_range(&self) -> (f64, f64) {
26 let min_freq = self.freq.iter().copied().fold(f64::INFINITY, f64::min);
27 let max_freq = self.freq.iter().copied().fold(f64::NEG_INFINITY, f64::max);
28 (min_freq, max_freq)
29 }
30
31 pub fn mean_freq(&self) -> f64 {
33 let (min_freq, max_freq) = self.freq_range();
34 (min_freq * max_freq).sqrt()
35 }
36}