stddeque.cpp
Go to the documentation of this file.
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/.
10 
11 #include "main.h"
12 #include <Eigen/StdDeque>
13 #include <Eigen/Geometry>
14 
15 template<typename MatrixType>
17 {
18  Index rows = m.rows();
19  Index cols = m.cols();
20  MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
21  std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType::Zero(rows,cols)), w(20, y);
22  v.front() = x;
23  w.front() = w.back();
24  VERIFY_IS_APPROX(w.front(), w.back());
25  v = w;
26 
27  typename std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> >::iterator vi = v.begin();
28  typename std::deque<MatrixType,Eigen::aligned_allocator<MatrixType> >::iterator wi = w.begin();
29  for(int i = 0; i < 20; i++)
30  {
31  VERIFY_IS_APPROX(*vi, *wi);
32  ++vi;
33  ++wi;
34  }
35 
36  v.resize(21,MatrixType::Zero(rows,cols));
37  v.back() = x;
38  VERIFY_IS_APPROX(v.back(), x);
39  v.resize(22,y);
40  VERIFY_IS_APPROX(v.back(), y);
41  v.push_back(x);
42  VERIFY_IS_APPROX(v.back(), x);
43 }
44 
45 template<typename TransformType>
46 void check_stddeque_transform(const TransformType&)
47 {
48  typedef typename TransformType::MatrixType MatrixType;
49  TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti=TransformType::Identity();
50  std::deque<TransformType,Eigen::aligned_allocator<TransformType> > v(10,ti), w(20, y);
51  v.front() = x;
52  w.front() = w.back();
53  VERIFY_IS_APPROX(w.front(), w.back());
54  v = w;
55 
56  typename std::deque<TransformType,Eigen::aligned_allocator<TransformType> >::iterator vi = v.begin();
57  typename std::deque<TransformType,Eigen::aligned_allocator<TransformType> >::iterator wi = w.begin();
58  for(int i = 0; i < 20; i++)
59  {
60  VERIFY_IS_APPROX(*vi, *wi);
61  ++vi;
62  ++wi;
63  }
64 
65  v.resize(21,ti);
66  v.back() = x;
67  VERIFY_IS_APPROX(v.back(), x);
68  v.resize(22,y);
69  VERIFY_IS_APPROX(v.back(), y);
70  v.push_back(x);
71  VERIFY_IS_APPROX(v.back(), x);
72 }
73 
74 template<typename QuaternionType>
75 void check_stddeque_quaternion(const QuaternionType&)
76 {
77  typedef typename QuaternionType::Coefficients Coefficients;
78  QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi=QuaternionType::Identity();
79  std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> > v(10,qi), w(20, y);
80  v.front() = x;
81  w.front() = w.back();
82  VERIFY_IS_APPROX(w.front(), w.back());
83  v = w;
84 
85  typename std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> >::iterator vi = v.begin();
86  typename std::deque<QuaternionType,Eigen::aligned_allocator<QuaternionType> >::iterator wi = w.begin();
87  for(int i = 0; i < 20; i++)
88  {
89  VERIFY_IS_APPROX(*vi, *wi);
90  ++vi;
91  ++wi;
92  }
93 
94  v.resize(21,qi);
95  v.back() = x;
96  VERIFY_IS_APPROX(v.back(), x);
97  v.resize(22,y);
98  VERIFY_IS_APPROX(v.back(), y);
99  v.push_back(x);
100  VERIFY_IS_APPROX(v.back(), x);
101 }
102 
104 {
105  // some non vectorizable fixed sizes
109 
110  // some vectorizable fixed sizes
115 
116  // some dynamic sizes
117  CALL_SUBTEST_3(check_stddeque_matrix(MatrixXd(1,1)));
118  CALL_SUBTEST_3(check_stddeque_matrix(VectorXd(20)));
119  CALL_SUBTEST_3(check_stddeque_matrix(RowVectorXf(20)));
120  CALL_SUBTEST_3(check_stddeque_matrix(MatrixXcf(10,10)));
121 
122  // some Transform
126 
127  // some Quaternion
130 }
w
RowVector3d w
Definition: Matrix_resize_int.cpp:3
Eigen::Affine2f
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:704
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
check_stddeque_matrix
void check_stddeque_matrix(const MatrixType &m)
Definition: stddeque.cpp:16
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(stddeque)
Definition: stddeque.cpp:103
iterator
Definition: pytypes.h:1460
rows
int rows
Definition: Tutorial_commainit_02.cpp:1
Eigen::Affine3f
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:706
check_stddeque_transform
void check_stddeque_transform(const TransformType &)
Definition: stddeque.cpp:46
CALL_SUBTEST_4
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22
CALL_SUBTEST_3
#define CALL_SUBTEST_3(FUNC)
Definition: split_test_helper.h:16
CALL_SUBTEST_1
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
Eigen::Quaternionf
Quaternion< float > Quaternionf
Definition: 3rdparty/Eigen/Eigen/src/Geometry/Quaternion.h:363
CALL_SUBTEST_5
#define CALL_SUBTEST_5(FUNC)
Definition: split_test_helper.h:28
Eigen::Quaterniond
Quaternion< double > Quaterniond
Definition: 3rdparty/Eigen/Eigen/src/Geometry/Quaternion.h:366
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
CALL_SUBTEST_2
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
check_stddeque_quaternion
void check_stddeque_quaternion(const QuaternionType &)
Definition: stddeque.cpp:75
y
Scalar * y
Definition: level1_cplx_impl.h:124
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:15
main.h
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
cols
int cols
Definition: Tutorial_commainit_02.cpp:1
Eigen::Affine3d
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:710
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:05:00