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
use fmt;
/// Compares two floating point numbers for equality, with margin for error
/// Are two objects approximately equal? The two objects could be floating
/// point numbers, or risk reports. Returns true if the objects are sufficiently
/// close or false if they are not. The meaning of the tolerance parameters means
/// different things to different objects. For a floating point number it means
/// the largest acceptable difference, when scaled to the size of the largest
/// number in the calculation. For example, if we are comparing (a - b) with c,
/// the largest acceptable difference is max(a, b, c) * tol. This means
/// that gamma calculations have a tolerance much greater than tol * gamma.
/*
* I cannot get this to work, I think because of the lifetime qualifier required on
* ApproxEq for the underlying type. For now, we implement it specifically for
* BoxReport, which is the only place that needs it.
impl<'v, T, V> ApproxEq<T, &'v [V]> for &'v [V]
where
V: ApproxEq<T, &'v V>
{
fn validate(self, other: &'v [V], tol: &T,
msg: &str, diffs: &mut fmt::Formatter) -> fmt::Result {
if self.len() != other.len() {
write!(diffs, "Slice: length {} != {}", self.len(), other.len())?;
}
for (self_item, other_item) in self.iter().zip(other.iter()) {
self_item.validate(other_item, tol, msg, diffs)?;
}
Ok(())
}
}
*/