Peano 4
Loading...
Searching...
No Matches
ScalarTest.cpp
Go to the documentation of this file.
2
4
6
7
8
10 TestCase("tarch::la::ScalarTest") {
11}
12
13
15 testMethod (testComparison);
16 testMethod (testAbs);
17}
18
20{
21 double a = 1.0;
22 double b = 2.0;
23 double eps = 1e-14;
24
25 validate (greater(b, a, eps));
26 validate (! greater(a, a - eps, eps));
27 validate (greater(a, a - 10.0 * eps, eps));
28
29 validate (! greaterEquals(a, b, eps));
30 validate (greaterEquals(b, a, eps));
31 validate (greaterEquals(a, a, eps));
32 validate (greaterEquals(a, a + 0.1*eps, eps));
33 validate (! greaterEquals(a, a + 10*eps, eps));
34
35 validate (smaller(a, b, eps));
36 validate (! smaller(a, a + eps, eps));
37 validate (smaller(a, a + 10.0 * eps, eps));
38
39 validate (smallerEquals(a, b, eps));
40 validate (smallerEquals(a, a + eps, eps));
41 validate (smallerEquals(a + eps, a, eps));
42 validate (smallerEquals(a, a + 10.0 * eps, eps));
43
44 validate (! equals(a, b, eps));
45 validate (equals(a, a, eps));
46 validate (equals(a, a + eps, eps));
47 validate (! equals(a, a + 10.0 * eps, eps));
48 validate (equals(a, a + 10.0 * eps, 10.0 * eps));
49}
50
52{
53 double a = -1.0;
54 int b = -1;
55
56 validateEquals (abs(a), 1.0);
57 validateEquals (abs(b), 1);
58}
59
#define validate(booleanExpr)
Definition TestMacros.h:37
#define testMethod(name)
Run a test method and check for errors.
Definition TestMacros.h:24
#define validateEquals(actualValue, validValue)
Definition TestMacros.h:299
virtual void run()
Runs all tests.
static bool smaller(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE) InlineMethod
Smaller operator for floating point values.
bool greater(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
bool greaterEquals(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
double abs(double value)
Returns the absolute value of a type by redirecting to std::abs.
bool smallerEquals(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
bool equals(const Matrix< Rows, Cols, Scalar > &lhs, const Matrix< Rows, Cols, Scalar > &rhs, const Scalar &tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares to matrices on equality by means of a numerical accuracy.