special_numbers.cpp File Reference
#include "main.h"

Functions

template<typename Scalar >
void special_numbers ()
 
 EIGEN_DECLARE_TEST (special_numbers)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( special_numbers  )
49  {
50  for (int i = 0; i < 10 * g_repeat; i++) {
51  CALL_SUBTEST_1(special_numbers<float>());
52  CALL_SUBTEST_1(special_numbers<double>());
53  }
54 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
static int g_repeat
Definition: main.h:191
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4

References CALL_SUBTEST_1, Eigen::g_repeat, and i.

◆ special_numbers()

template<typename Scalar >
void special_numbers ( )
13  {
14  typedef Matrix<Scalar, Dynamic, Dynamic> MatType;
15  int rows = internal::random<int>(1, 300);
16  int cols = internal::random<int>(1, 300);
17 
18  Scalar nan = std::numeric_limits<Scalar>::quiet_NaN();
19  Scalar inf = std::numeric_limits<Scalar>::infinity();
20  Scalar s1 = internal::random<Scalar>();
21 
22  MatType m1 = MatType::Random(rows, cols), mnan = MatType::Random(rows, cols), minf = MatType::Random(rows, cols),
23  mboth = MatType::Random(rows, cols);
24 
25  int n = internal::random<int>(1, 10);
26  for (int k = 0; k < n; ++k) {
27  mnan(internal::random<int>(0, rows - 1), internal::random<int>(0, cols - 1)) = nan;
28  minf(internal::random<int>(0, rows - 1), internal::random<int>(0, cols - 1)) = inf;
29  }
30  mboth = mnan + minf;
31 
32  VERIFY(!m1.hasNaN());
33  VERIFY(m1.allFinite());
34 
35  VERIFY(mnan.hasNaN());
36  VERIFY((s1 * mnan).hasNaN());
37  VERIFY(!minf.hasNaN());
38  VERIFY(!(2 * minf).hasNaN());
39  VERIFY(mboth.hasNaN());
40  VERIFY(mboth.array().hasNaN());
41 
42  VERIFY(!mnan.allFinite());
43  VERIFY(!minf.allFinite());
44  VERIFY(!(minf - mboth).allFinite());
45  VERIFY(!mboth.allFinite());
46  VERIFY(!mboth.array().allFinite());
47 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Matrix3d m1
Definition: IOFormat.cpp:2
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
char char char int int * k
Definition: level2_impl.h:374
#define VERIFY(a)
Definition: main.h:362
const Mdouble inf
Definition: GeneralDefine.h:23

References cols, constants::inf, k, m1, n, rows, and VERIFY.