1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use std::marker::PhantomData;
use crate::core::{DatasetMetric, Measure, Metric, SensitivityMetric};
pub type IntDistance = u32;
#[derive(Clone)]
pub struct MaxDivergence<Q>(PhantomData<Q>);
impl<Q> Default for MaxDivergence<Q> {
fn default() -> Self { MaxDivergence(PhantomData) }
}
impl<Q> PartialEq for MaxDivergence<Q> {
fn eq(&self, _other: &Self) -> bool { true }
}
impl<Q: Clone> Measure for MaxDivergence<Q> {
type Distance = Q;
}
#[derive(Clone)]
pub struct SmoothedMaxDivergence<Q>(PhantomData<Q>);
impl<Q> Default for SmoothedMaxDivergence<Q> {
fn default() -> Self { SmoothedMaxDivergence(PhantomData) }
}
impl<Q> PartialEq for SmoothedMaxDivergence<Q> {
fn eq(&self, _other: &Self) -> bool { true }
}
impl<Q: Clone> Measure for SmoothedMaxDivergence<Q> {
type Distance = (Q, Q);
}
#[derive(Clone)]
pub struct SymmetricDistance;
impl Default for SymmetricDistance {
fn default() -> Self { SymmetricDistance }
}
impl PartialEq for SymmetricDistance {
fn eq(&self, _other: &Self) -> bool { true }
}
impl Metric for SymmetricDistance {
type Distance = IntDistance;
}
impl DatasetMetric for SymmetricDistance {}
#[derive(Clone)]
pub struct SubstituteDistance;
impl Default for SubstituteDistance {
fn default() -> Self { SubstituteDistance }
}
impl PartialEq for SubstituteDistance {
fn eq(&self, _other: &Self) -> bool { true }
}
impl Metric for SubstituteDistance {
type Distance = IntDistance;
}
impl DatasetMetric for SubstituteDistance {}
pub struct LpDistance<Q, const P: usize>(PhantomData<Q>);
impl<Q, const P: usize> Default for LpDistance<Q, P> {
fn default() -> Self { LpDistance(PhantomData) }
}
impl<Q, const P: usize> Clone for LpDistance<Q, P> {
fn clone(&self) -> Self { Self::default() }
}
impl<Q, const P: usize> PartialEq for LpDistance<Q, P> {
fn eq(&self, _other: &Self) -> bool { true }
}
impl<Q, const P: usize> Metric for LpDistance<Q, P> {
type Distance = Q;
}
impl<Q, const P: usize> SensitivityMetric for LpDistance<Q, P> {}
pub type L1Distance<Q> = LpDistance<Q, 1>;
pub type L2Distance<Q> = LpDistance<Q, 2>;
pub struct AbsoluteDistance<Q>(PhantomData<Q>);
impl<Q> Default for AbsoluteDistance<Q> {
fn default() -> Self { AbsoluteDistance(PhantomData) }
}
impl<Q> Clone for AbsoluteDistance<Q> {
fn clone(&self) -> Self { Self::default() }
}
impl<Q> PartialEq for AbsoluteDistance<Q> {
fn eq(&self, _other: &Self) -> bool { true }
}
impl<Q> Metric for AbsoluteDistance<Q> {
type Distance = Q;
}
impl<Q> SensitivityMetric for AbsoluteDistance<Q> {}