projects/guix·blob java-team · refs

145 lines · 4.0 KiB

1Fix FTBFS on i686-linux due to rounding issue (see references).
2
3Fixes Guix bug #22049 (see below).
4
5Copied from Debian.
6
7Source:
8https://sources.debian.net/src/ilmbase/2.2.0-11/debian/patches/testBoxAlgo.patch/
9https://sources.debian.net/src/ilmbase/2.2.0-11/debian/patches/testBox.patch/
10
11References:
12https://lists.nongnu.org/archive/html/openexr-devel/2015-12/msg00001.html
13https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22049
14https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815712
15https://anonscm.debian.org/cgit/pkg-phototools/ilmbase.git/commit/?id=ab28bb45cdad8adc32e345b777ab8e692b1d9a9c
16
17---
18
19Subject: testBoxAlgo: allow fuzzy match of b12 == b2
20From: Steven Chamberlain <[email protected]>
21Date: Wed, 24 Feb 2016 01:04:11 +0000
22
23Also fix a pre-existing typo.
24
25--- a/IlmBase/ImathTest/testBoxAlgo.cpp
26+++ b/IlmBase/ImathTest/testBoxAlgo.cpp
27@@ -886,10 +886,11 @@ boxMatrixTransform ()
28
29 assert (approximatelyEqual (b2.min, b4.min, e));
30 assert (approximatelyEqual (b2.max, b4.max, e));
31- assert (approximatelyEqual (b3.max, b4.max, e));
32+ assert (approximatelyEqual (b3.min, b4.min, e));
33 assert (approximatelyEqual (b3.max, b4.max, e));
34
35- assert (b21 == b2);
36+ assert (approximatelyEqual (b2.min, b21.min, e));
37+ assert (approximatelyEqual (b2.max, b21.max, e));
38 assert (b31 == b3);
39
40 M[0][3] = 1;
41
42---
43
44Subject: testBox: allow fuzzy comparison of floats, doubles
45From: Steven Chamberlain <[email protected]>
46Date: Wed, 24 Feb 2016 01:10:11 +0000
47
48Allow for inexact values, as long as the error is smaller than the
49epsilon of the data type.
50
51On 32-bit x86, allow even greater discrepency at double
52precision, due to possible double-rounding. See
53https://lists.nongnu.org/archive/html/openexr-devel/2015-12/msg00001.html
54
55--- a/IlmBase/ImathTest/testBox.cpp
56+++ b/IlmBase/ImathTest/testBox.cpp
57@@ -47,6 +47,58 @@ using namespace IMATH_INTERNAL_NAMESPACE
58
59 namespace {
60
61+template <class T>
62+bool
63+approximatelyEqual (const T &p1, const T &p2)
64+{
65+ /* int and short should be exact */
66+ return (p1 == p2);
67+}
68+
69+bool
70+approximatelyEqual (const Vec2<float> &p1, const Vec2<float> &p2)
71+{
72+ float e = limits<float>::epsilon();
73+ float m = 0;
74+
75+ for (int i = 0; i < 2; ++i)
76+ {
77+ m = max (m, abs (p1[i]));
78+ m = max (m, abs (p2[i]));
79+ }
80+
81+ for (int i = 0; i < 2; ++i)
82+ if (!equalWithAbsError (p1[i], p2[i], m * e))
83+ return false;
84+
85+ return true;
86+}
87+
88+bool
89+approximatelyEqual (const Vec2<double> &p1, const Vec2<double> &p2)
90+{
91+#if defined(__i386__) || defined(_M_IX86)
92+ /* double-rounding on 32-bit x86 may cause larger error:
93+ use epsilon of float rather than double */
94+ double e = limits<float>::epsilon();
95+#else
96+ double e = limits<double>::epsilon();
97+#endif
98+ double m = 0;
99+
100+ for (int i = 0; i < 2; ++i)
101+ {
102+ m = max (m, abs (p1[i]));
103+ m = max (m, abs (p2[i]));
104+ }
105+
106+ for (int i = 0; i < 2; ++i)
107+ if (!equalWithAbsError (p1[i], p2[i], m * e))
108+ return false;
109+
110+ return true;
111+}
112+
113 //
114 // Test case generation utility - create a vector of IMATH_INTERNAL_NAMESPACE::Vec{2,3,4}
115 // with all permutations of integers 1..T::dimensions().
116@@ -250,7 +302,8 @@ testExtendByPoint(const char *type)
117
118 IMATH_INTERNAL_NAMESPACE::Box<T> b;
119 b.extendBy(p);
120- assert(b.min == p && b.max == p);
121+ assert (approximatelyEqual (b.min, p));
122+ assert (approximatelyEqual (b.max, p));
123 }
124
125 //
126@@ -283,7 +336,8 @@ testExtendByPoint(const char *type)
127
128 b.extendBy(p);
129
130- assert(b.min == min && b.max == max);
131+ assert (approximatelyEqual (b.min, min));
132+ assert (approximatelyEqual (b.max, max));
133 }
134 }
135 }
136@@ -358,7 +412,8 @@ testExtendByBox(const char *type)
137 }
138 b.extendBy(IMATH_INTERNAL_NAMESPACE::Box<T>(p0, p1));
139
140- assert(b.min == min && b.max == max);
141+ assert (approximatelyEqual (b.min, min));
142+ assert (approximatelyEqual (b.max, max));
143 }
144 }
145 }