pub trait DistanceMetric: Clone + Send + Sync {
type Context: Clone + Send + Sync;
fn precompute(ts: &[f64], m: usize) -> Self::Context;
fn distance(ts: &[f64], i: usize, j: usize, m: usize, ctx: &Self::Context) -> f64;
fn distance_profile(ts: &[f64], idx: usize, m: usize, ctx: &Self::Context) -> Vec<f64> {
let n_subs = ts.len() - m + 1;
(0..n_subs)
.map(|j| Self::distance(ts, idx, j, m, ctx))
.collect()
}
fn supports_qt_optimization() -> bool {
false
}
fn qt_to_distance(_qt: f64, _i: usize, _j: usize, _m: usize, _ctx: &Self::Context) -> f64 {
unimplemented!("qt_to_distance not supported for this metric")
}
fn supports_correlation_domain() -> bool {
false
}
fn correlation_data(_ctx: &Self::Context) -> (&[f64], &[f64], bool) {
unreachable!("correlation_data not supported for this metric")
}
fn update_context(ctx: &mut Self::Context, ts: &[f64], m: usize);
fn supports_ab_join() -> bool {
false
}
fn qt_to_distance_ab(
_qt: f64,
_i: usize,
_j: usize,
_m: usize,
_ctx_a: &Self::Context,
_ctx_b: &Self::Context,
) -> f64 {
unimplemented!("qt_to_distance_ab not supported for this metric")
}
fn correlation_data_ab<'a>(
_ctx_a: &'a Self::Context,
_ctx_b: &'a Self::Context,
) -> (&'a [f64], &'a [f64], &'a [f64], &'a [f64], bool) {
unreachable!("correlation_data_ab not supported for this metric")
}
}