summaryrefslogtreecommitdiff
path: root/test/correctness
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2017-02-26 10:19:53 +0100
committerCedric Nugteren <web@cedricnugteren.nl>2017-02-26 10:19:53 +0100
commit70d8c4bad7911b3688ac4514fedc44e5e0f1f2d8 (patch)
treec3d2e96cd4ff318debb180b99a5dda9f5bd856b3 /test/correctness
parenta433987441e09684fb7b6f6c75962fd128cbfdbd (diff)
Improved the correctness tests for complex numbers in case either real or imag is much larger than the other
Diffstat (limited to 'test/correctness')
-rw-r--r--test/correctness/tester.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/correctness/tester.cpp b/test/correctness/tester.cpp
index dd2f3f99..eb79008d 100644
--- a/test/correctness/tester.cpp
+++ b/test/correctness/tester.cpp
@@ -473,15 +473,21 @@ template bool TestSimilarity<double>(const double, const double);
// Specialisations for non-standard data-types
template <>
bool TestSimilarity(const float2 val1, const float2 val2) {
- auto real = TestSimilarity(val1.real(), val2.real());
- auto imag = TestSimilarity(val1.imag(), val2.imag());
- return (real && imag);
+ const auto real = TestSimilarity(val1.real(), val2.real());
+ const auto imag = TestSimilarity(val1.imag(), val2.imag());
+ if (real && imag) { return true; }
+ // also OK if one is good and the combined is good (indicates a big diff between real & imag)
+ if (real || imag) { return TestSimilarity(val1.real() + val1.imag(), val2.real() + val2.imag()); }
+ return false; // neither real nor imag is good, return false
}
template <>
bool TestSimilarity(const double2 val1, const double2 val2) {
- auto real = TestSimilarity(val1.real(), val2.real());
- auto imag = TestSimilarity(val1.imag(), val2.imag());
- return (real && imag);
+ const auto real = TestSimilarity(val1.real(), val2.real());
+ const auto imag = TestSimilarity(val1.imag(), val2.imag());
+ if (real && imag) { return true; }
+ // also OK if one is good and the combined is good (indicates a big diff between real & imag)
+ if (real || imag) { return TestSimilarity(val1.real() + val1.imag(), val2.real() + val2.imag()); }
+ return false; // neither real nor imag is good, return false
}
template <>
bool TestSimilarity(const half val1, const half val2) {