Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "main.h"
00027 #include <Eigen/StdDeque>
00028 #include <Eigen/Geometry>
00029
00030 template<typename MatrixType>
00031 void check_stddeque_matrix(const MatrixType& m)
00032 {
00033 typedef typename MatrixType::Index Index;
00034
00035 Index rows = m.rows();
00036 Index cols = m.cols();
00037 MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
00038 std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y);
00039 v.front() = x;
00040 w.front() = w.back();
00041 VERIFY_IS_APPROX(w.front(), w.back());
00042 v = w;
00043
00044 typename std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> >::iterator vi = v.begin();
00045 typename std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> >::iterator wi = w.begin();
00046 for(int i = 0; i < 20; i++)
00047 {
00048 VERIFY_IS_APPROX(*vi, *wi);
00049 ++vi;
00050 ++wi;
00051 }
00052
00053 v.resize(21);
00054 v.back() = x;
00055 VERIFY_IS_APPROX(v.back(), x);
00056 v.resize(22,y);
00057 VERIFY_IS_APPROX(v.back(), y);
00058 v.push_back(x);
00059 VERIFY_IS_APPROX(v.back(), x);
00060 }
00061
00062 template<typename TransformType>
00063 void check_stddeque_transform(const TransformType&)
00064 {
00065 typedef typename TransformType::MatrixType MatrixType;
00066 TransformType x(MatrixType::Random()), y(MatrixType::Random());
00067 std::deque<TransformType,Eigen::aligned_allocator<TransformType> > v(10), w(20, y);
00068 v.front() = x;
00069 w.front() = w.back();
00070 VERIFY_IS_APPROX(w.front(), w.back());
00071 v = w;
00072
00073 typename std::deque<TransformType,Eigen::aligned_allocator<TransformType> >::iterator vi = v.begin();
00074 typename std::deque<TransformType,Eigen::aligned_allocator<TransformType> >::iterator wi = w.begin();
00075 for(int i = 0; i < 20; i++)
00076 {
00077 VERIFY_IS_APPROX(*vi, *wi);
00078 ++vi;
00079 ++wi;
00080 }
00081
00082 v.resize(21);
00083 v.back() = x;
00084 VERIFY_IS_APPROX(v.back(), x);
00085 v.resize(22,y);
00086 VERIFY_IS_APPROX(v.back(), y);
00087 v.push_back(x);
00088 VERIFY_IS_APPROX(v.back(), x);
00089 }
00090
00091 template<typename QuaternionType>
00092 void check_stddeque_quaternion(const QuaternionType&)
00093 {
00094 typedef typename QuaternionType::Coefficients Coefficients;
00095 QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
00096 std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10), w(20, y);
00097 v.front() = x;
00098 w.front() = w.back();
00099 VERIFY_IS_APPROX(w.front(), w.back());
00100 v = w;
00101
00102 typename std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> >::iterator vi = v.begin();
00103 typename std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> >::iterator wi = w.begin();
00104 for(int i = 0; i < 20; i++)
00105 {
00106 VERIFY_IS_APPROX(*vi, *wi);
00107 ++vi;
00108 ++wi;
00109 }
00110
00111 v.resize(21);
00112 v.back() = x;
00113 VERIFY_IS_APPROX(v.back(), x);
00114 v.resize(22,y);
00115 VERIFY_IS_APPROX(v.back(), y);
00116 v.push_back(x);
00117 VERIFY_IS_APPROX(v.back(), x);
00118 }
00119
00120 void test_stddeque()
00121 {
00122
00123 CALL_SUBTEST_1(check_stddeque_matrix(Vector2f()));
00124 CALL_SUBTEST_1(check_stddeque_matrix(Matrix3f()));
00125 CALL_SUBTEST_2(check_stddeque_matrix(Matrix3d()));
00126
00127
00128 CALL_SUBTEST_1(check_stddeque_matrix(Matrix2f()));
00129 CALL_SUBTEST_1(check_stddeque_matrix(Vector4f()));
00130 CALL_SUBTEST_1(check_stddeque_matrix(Matrix4f()));
00131 CALL_SUBTEST_2(check_stddeque_matrix(Matrix4d()));
00132
00133
00134 CALL_SUBTEST_3(check_stddeque_matrix(MatrixXd(1,1)));
00135 CALL_SUBTEST_3(check_stddeque_matrix(VectorXd(20)));
00136 CALL_SUBTEST_3(check_stddeque_matrix(RowVectorXf(20)));
00137 CALL_SUBTEST_3(check_stddeque_matrix(MatrixXcf(10,10)));
00138
00139
00140 CALL_SUBTEST_4(check_stddeque_transform(Affine2f()));
00141 CALL_SUBTEST_4(check_stddeque_transform(Affine3f()));
00142 CALL_SUBTEST_4(check_stddeque_transform(Affine3d()));
00143
00144
00145 CALL_SUBTEST_5(check_stddeque_quaternion(Quaternionf()));
00146 CALL_SUBTEST_5(check_stddeque_quaternion(Quaterniond()));
00147 }