LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / libs / eigen / test / stddeque.cpp
blobbb4b476f313c759238d870b86802c5f51cabfc0e
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include "main.h"
12 #include <Eigen/StdDeque>
13 #include <Eigen/Geometry>
15 template<typename MatrixType>
16 void check_stddeque_matrix(const MatrixType& m)
18 typedef typename MatrixType::Index Index;
20 Index rows = m.rows();
21 Index cols = m.cols();
22 MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
23 std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y);
24 v.front() = x;
25 w.front() = w.back();
26 VERIFY_IS_APPROX(w.front(), w.back());
27 v = w;
29 typename std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> >::iterator vi = v.begin();
30 typename std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> >::iterator wi = w.begin();
31 for(int i = 0; i < 20; i++)
33 VERIFY_IS_APPROX(*vi, *wi);
34 ++vi;
35 ++wi;
38 v.resize(21);
39 v.back() = x;
40 VERIFY_IS_APPROX(v.back(), x);
41 v.resize(22,y);
42 VERIFY_IS_APPROX(v.back(), y);
43 v.push_back(x);
44 VERIFY_IS_APPROX(v.back(), x);
47 template<typename TransformType>
48 void check_stddeque_transform(const TransformType&)
50 typedef typename TransformType::MatrixType MatrixType;
51 TransformType x(MatrixType::Random()), y(MatrixType::Random());
52 std::deque<TransformType,Eigen::aligned_allocator<TransformType> > v(10), w(20, y);
53 v.front() = x;
54 w.front() = w.back();
55 VERIFY_IS_APPROX(w.front(), w.back());
56 v = w;
58 typename std::deque<TransformType,Eigen::aligned_allocator<TransformType> >::iterator vi = v.begin();
59 typename std::deque<TransformType,Eigen::aligned_allocator<TransformType> >::iterator wi = w.begin();
60 for(int i = 0; i < 20; i++)
62 VERIFY_IS_APPROX(*vi, *wi);
63 ++vi;
64 ++wi;
67 v.resize(21);
68 v.back() = x;
69 VERIFY_IS_APPROX(v.back(), x);
70 v.resize(22,y);
71 VERIFY_IS_APPROX(v.back(), y);
72 v.push_back(x);
73 VERIFY_IS_APPROX(v.back(), x);
76 template<typename QuaternionType>
77 void check_stddeque_quaternion(const QuaternionType&)
79 typedef typename QuaternionType::Coefficients Coefficients;
80 QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
81 std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10), w(20, y);
82 v.front() = x;
83 w.front() = w.back();
84 VERIFY_IS_APPROX(w.front(), w.back());
85 v = w;
87 typename std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> >::iterator vi = v.begin();
88 typename std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> >::iterator wi = w.begin();
89 for(int i = 0; i < 20; i++)
91 VERIFY_IS_APPROX(*vi, *wi);
92 ++vi;
93 ++wi;
96 v.resize(21);
97 v.back() = x;
98 VERIFY_IS_APPROX(v.back(), x);
99 v.resize(22,y);
100 VERIFY_IS_APPROX(v.back(), y);
101 v.push_back(x);
102 VERIFY_IS_APPROX(v.back(), x);
105 void test_stddeque()
107 // some non vectorizable fixed sizes
108 CALL_SUBTEST_1(check_stddeque_matrix(Vector2f()));
109 CALL_SUBTEST_1(check_stddeque_matrix(Matrix3f()));
110 CALL_SUBTEST_2(check_stddeque_matrix(Matrix3d()));
112 // some vectorizable fixed sizes
113 CALL_SUBTEST_1(check_stddeque_matrix(Matrix2f()));
114 CALL_SUBTEST_1(check_stddeque_matrix(Vector4f()));
115 CALL_SUBTEST_1(check_stddeque_matrix(Matrix4f()));
116 CALL_SUBTEST_2(check_stddeque_matrix(Matrix4d()));
118 // some dynamic sizes
119 CALL_SUBTEST_3(check_stddeque_matrix(MatrixXd(1,1)));
120 CALL_SUBTEST_3(check_stddeque_matrix(VectorXd(20)));
121 CALL_SUBTEST_3(check_stddeque_matrix(RowVectorXf(20)));
122 CALL_SUBTEST_3(check_stddeque_matrix(MatrixXcf(10,10)));
124 // some Transform
125 CALL_SUBTEST_4(check_stddeque_transform(Affine2f()));
126 CALL_SUBTEST_4(check_stddeque_transform(Affine3f()));
127 CALL_SUBTEST_4(check_stddeque_transform(Affine3d()));
129 // some Quaternion
130 CALL_SUBTEST_5(check_stddeque_quaternion(Quaternionf()));
131 CALL_SUBTEST_5(check_stddeque_quaternion(Quaterniond()));