LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / eigen / test / zerosized.cpp
blobda7dd0481439bd2f0781954b1d676e05aad64724
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
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"
13 template<typename MatrixType> void zeroReduction(const MatrixType& m) {
14 // Reductions that must hold for zero sized objects
15 VERIFY(m.all());
16 VERIFY(!m.any());
17 VERIFY(m.prod()==1);
18 VERIFY(m.sum()==0);
19 VERIFY(m.count()==0);
20 VERIFY(m.allFinite());
21 VERIFY(!m.hasNaN());
25 template<typename MatrixType> void zeroSizedMatrix()
27 MatrixType t1;
29 if (MatrixType::SizeAtCompileTime == Dynamic || MatrixType::SizeAtCompileTime == 0)
31 zeroReduction(t1);
32 if (MatrixType::RowsAtCompileTime == Dynamic)
33 VERIFY(t1.rows() == 0);
34 if (MatrixType::ColsAtCompileTime == Dynamic)
35 VERIFY(t1.cols() == 0);
37 if (MatrixType::RowsAtCompileTime == Dynamic && MatrixType::ColsAtCompileTime == Dynamic)
40 MatrixType t2(0, 0);
41 VERIFY(t2.rows() == 0);
42 VERIFY(t2.cols() == 0);
44 zeroReduction(t2);
45 VERIFY(t1==t2);
50 template<typename VectorType> void zeroSizedVector()
52 VectorType t1;
54 if (VectorType::SizeAtCompileTime == Dynamic || VectorType::SizeAtCompileTime==0)
56 zeroReduction(t1);
57 VERIFY(t1.size() == 0);
58 VectorType t2(DenseIndex(0)); // DenseIndex disambiguates with 0-the-null-pointer (error with gcc 4.4 and MSVC8)
59 VERIFY(t2.size() == 0);
60 zeroReduction(t2);
62 VERIFY(t1==t2);
66 void test_zerosized()
68 zeroSizedMatrix<Matrix2d>();
69 zeroSizedMatrix<Matrix3i>();
70 zeroSizedMatrix<Matrix<float, 2, Dynamic> >();
71 zeroSizedMatrix<MatrixXf>();
72 zeroSizedMatrix<Matrix<float, 0, 0> >();
73 zeroSizedMatrix<Matrix<float, Dynamic, 0, 0, 0, 0> >();
74 zeroSizedMatrix<Matrix<float, 0, Dynamic, 0, 0, 0> >();
75 zeroSizedMatrix<Matrix<float, Dynamic, Dynamic, 0, 0, 0> >();
76 zeroSizedMatrix<Matrix<float, 0, 4> >();
77 zeroSizedMatrix<Matrix<float, 4, 0> >();
79 zeroSizedVector<Vector2d>();
80 zeroSizedVector<Vector3i>();
81 zeroSizedVector<VectorXf>();
82 zeroSizedVector<Matrix<float, 0, 1> >();
83 zeroSizedVector<Matrix<float, 1, 0> >();