LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / eigen / test / special_numbers.cpp
blob2f1b704be9c72f91db8726710192089a64c7ad5c
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2013 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "main.h"
12 template<typename Scalar> void special_numbers()
14 typedef Matrix<Scalar, Dynamic,Dynamic> MatType;
15 int rows = internal::random<int>(1,300);
16 int cols = internal::random<int>(1,300);
18 Scalar nan = std::numeric_limits<Scalar>::quiet_NaN();
19 Scalar inf = std::numeric_limits<Scalar>::infinity();
20 Scalar s1 = internal::random<Scalar>();
22 MatType m1 = MatType::Random(rows,cols),
23 mnan = MatType::Random(rows,cols),
24 minf = MatType::Random(rows,cols),
25 mboth = MatType::Random(rows,cols);
27 int n = internal::random<int>(1,10);
28 for(int k=0; k<n; ++k)
30 mnan(internal::random<int>(0,rows-1), internal::random<int>(0,cols-1)) = nan;
31 minf(internal::random<int>(0,rows-1), internal::random<int>(0,cols-1)) = inf;
33 mboth = mnan + minf;
35 VERIFY(!m1.hasNaN());
36 VERIFY(m1.allFinite());
38 VERIFY(mnan.hasNaN());
39 VERIFY((s1*mnan).hasNaN());
40 VERIFY(!minf.hasNaN());
41 VERIFY(!(2*minf).hasNaN());
42 VERIFY(mboth.hasNaN());
43 VERIFY(mboth.array().hasNaN());
45 VERIFY(!mnan.allFinite());
46 VERIFY(!minf.allFinite());
47 VERIFY(!(minf-mboth).allFinite());
48 VERIFY(!mboth.allFinite());
49 VERIFY(!mboth.array().allFinite());
52 void test_special_numbers()
54 for(int i = 0; i < 10*g_repeat; i++) {
55 CALL_SUBTEST_1( special_numbers<float>() );
56 CALL_SUBTEST_1( special_numbers<double>() );