array_test5.cpp Revision to Incorporate Tolerance
Jeffrey Oldham
oldham at codesourcery.com
Wed Sep 5 20:43:38 UTC 2001
array_test5 was failing using gcc 3.0.1 on Linux because floating
point and complex numbers wre compared using ==. We revise to check
within a tolerance of 1.0e-08.
2001-09-05 Jeffrey D. Oldham <oldham at codesourcery.com>
* array_test5.cpp (floatCheck): New function that uses a
tolerance.
(main): Replace appropriate uses of check with floatCheck.
Tested on sequential Linux using gcc 3.0.1 by compiling array_test5
Approved by Stephen Smith
Applied to mainline
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: array_test5.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/src/Array/tests/array_test5.cpp,v
retrieving revision 1.12
diff -c -p -r1.12 array_test5.cpp
*** array_test5.cpp 2000/03/10 18:10:46 1.12
--- array_test5.cpp 2001/09/05 20:21:56
*************** inline void check(const T &ans, const T
*** 46,51 ****
--- 46,57 ----
tester.check(ans == correct);
}
+ template<class T>
+ inline void floatCheck(const T &ans, const T &correct, Pooma::Tester &tester)
+ {
+ tester.check(std::abs(ans - correct) < 1.0e-08);
+ }
+
int main(int argc, char *argv[])
{
Pooma::initialize(argc, argv);
*************** int main(int argc, char *argv[])
*** 61,68 ****
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! check(a(i,j), 7.0, tester);
! check(b(i,j), x, tester);
}
c = a + 2.0 * b;
--- 67,74 ----
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! floatCheck(a(i,j), 7.0, tester);
! floatCheck(b(i,j), x, tester);
}
c = a + 2.0 * b;
*************** int main(int argc, char *argv[])
*** 71,77 ****
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! check(c(i,j), complex<double>(9.0,4.0), tester);
}
complex<double> y(-3, -4);
--- 77,83 ----
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! floatCheck(c(i,j), complex<double>(9.0,4.0), tester);
}
complex<double> y(-3, -4);
*************** int main(int argc, char *argv[])
*** 81,87 ****
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! check(c(i,j), complex<double>(5.0,6.0), tester);
}
d = norm(a + y * conj(b));
--- 87,93 ----
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! floatCheck(c(i,j), complex<double>(5.0,6.0), tester);
}
d = norm(a + y * conj(b));
*************** int main(int argc, char *argv[])
*** 90,96 ****
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! check(d(i,j), 20.0, tester);
}
d = real(y * pow(b, 2));
--- 96,102 ----
for (j = 0; j < 2; j++)
for (i = 0; i < 2; i++)
{
! floatCheck(d(i,j), 20.0, tester);
}
d = real(y * pow(b, 2));
More information about the pooma-dev
mailing list