1 // This file is part of Eigen, a lightweight C++ template library
4 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>
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/.
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
);
26 VERIFY_IS_APPROX(w
.front(), w
.back());
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
);
40 VERIFY_IS_APPROX(v
.back(), x
);
42 VERIFY_IS_APPROX(v
.back(), y
);
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
);
55 VERIFY_IS_APPROX(w
.front(), w
.back());
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
);
69 VERIFY_IS_APPROX(v
.back(), x
);
71 VERIFY_IS_APPROX(v
.back(), y
);
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
);
84 VERIFY_IS_APPROX(w
.front(), w
.back());
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
);
98 VERIFY_IS_APPROX(v
.back(), x
);
100 VERIFY_IS_APPROX(v
.back(), y
);
102 VERIFY_IS_APPROX(v
.back(), x
);
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)));
125 CALL_SUBTEST_4(check_stddeque_transform(Affine2f()));
126 CALL_SUBTEST_4(check_stddeque_transform(Affine3f()));
127 CALL_SUBTEST_4(check_stddeque_transform(Affine3d()));
130 CALL_SUBTEST_5(check_stddeque_quaternion(Quaternionf()));
131 CALL_SUBTEST_5(check_stddeque_quaternion(Quaterniond()));