-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathtest_math.h
46 lines (38 loc) · 922 Bytes
/
test_math.h
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
// This file is part of KWIVER, and is distributed under the
// OSI-approved BSD 3-Clause License. See top-level LICENSE file or
// https://github.com/Kitware/kwiver/blob/master/LICENSE for details.
/**
* \file
* \brief test support functions involving generic math
*/
#ifndef KWIVER_TEST_MATH_H_
#define KWIVER_TEST_MATH_H_
#include <cmath>
#include <Eigen/Core>
namespace kwiver {
namespace testing {
/// Near comparison function for vectors
/**
* Drop-in compatible with TEST_NEAR. Just need to include this header.
*/
template < typename T, int M, int N >
bool
is_almost( Eigen::Matrix< T, M, N > const& a,
Eigen::Matrix< T, M, N > const& b,
double const& epsilon )
{
for ( unsigned i = 0; i < M; ++i )
{
for ( unsigned j = 0; j < N; ++j )
{
if ( fabs( a( i, j ) - b( i, j ) ) > epsilon )
{
return false;
}
}
}
return true;
}
}
}
#endif