stddeque_overload.cpp File Reference
#include "main.h"
#include <Eigen/StdDeque>
#include <Eigen/Geometry>

Functions

template<typename MatrixType >
void check_stddeque_matrix (const MatrixType &m)
 
template<typename TransformType >
void check_stddeque_transform (const TransformType &)
 
template<typename QuaternionType >
void check_stddeque_quaternion (const QuaternionType &)
 
 EIGEN_DECLARE_TEST (stddeque_overload)
 

Function Documentation

◆ check_stddeque_matrix()

template<typename MatrixType >
void check_stddeque_matrix ( const MatrixType m)
29  {
30  Index rows = m.rows();
31  Index cols = m.cols();
32  MatrixType x = MatrixType::Random(rows, cols), y = MatrixType::Random(rows, cols);
33  std::deque<MatrixType> v(10, MatrixType::Zero(rows, cols)), w(20, y);
34  v[5] = x;
35  w[6] = v[5];
36  VERIFY_IS_APPROX(w[6], v[5]);
37  v = w;
38  for (int i = 0; i < 20; i++) {
39  VERIFY_IS_APPROX(w[i], v[i]);
40  }
41 
42  v.resize(21);
43  v[20] = x;
44  VERIFY_IS_APPROX(v[20], x);
45  v.resize(22, y);
46  VERIFY_IS_APPROX(v[21], y);
47  v.push_back(x);
48  VERIFY_IS_APPROX(v[22], x);
49 
50  // do a lot of push_back such that the deque gets internally resized
51  // (with memory reallocation)
52  MatrixType* ref = &w[0];
53  for (int i = 0; i < 30 || ((ref == &w[0]) && i < 300); ++i) v.push_back(w[i % w.size()]);
54  for (unsigned int i = 23; i < v.size(); ++i) {
55  VERIFY(v[i] == w[(i - 23) % w.size()]);
56  }
57 }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
RowVector3d w
Definition: Matrix_resize_int.cpp:3
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
Scalar * y
Definition: level1_cplx_impl.h:128
int * m
Definition: level2_cplx_impl.h:294
#define VERIFY(a)
Definition: main.h:362
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
double Zero
Definition: pseudosolid_node_update_elements.cc:35
list x
Definition: plotDoE.py:28

References cols, i, m, rows, v, VERIFY, VERIFY_IS_APPROX, w, plotDoE::x, y, and oomph::PseudoSolidHelper::Zero.

Referenced by EIGEN_DECLARE_TEST().

◆ check_stddeque_quaternion()

template<typename QuaternionType >
void check_stddeque_quaternion ( const QuaternionType &  )
90  {
91  typedef typename QuaternionType::Coefficients Coefficients;
92  QuaternionType x(Coefficients::Random()), y(Coefficients::Random()), qi = QuaternionType::Identity();
93  std::deque<QuaternionType> v(10, qi), w(20, y);
94  v[5] = x;
95  w[6] = v[5];
96  VERIFY_IS_APPROX(w[6], v[5]);
97  v = w;
98  for (int i = 0; i < 20; i++) {
99  VERIFY_IS_APPROX(w[i], v[i]);
100  }
101 
102  v.resize(21, qi);
103  v[20] = x;
104  VERIFY_IS_APPROX(v[20], x);
105  v.resize(22, y);
106  VERIFY_IS_APPROX(v[21], y);
107  v.push_back(x);
108  VERIFY_IS_APPROX(v[22], x);
109 
110  // do a lot of push_back such that the deque gets internally resized
111  // (with memory reallocation)
112  QuaternionType* ref = &w[0];
113  for (int i = 0; i < 30 || ((ref == &w[0]) && i < 300); ++i) v.push_back(w[i % w.size()]);
114  for (unsigned int i = 23; i < v.size(); ++i) {
115  VERIFY(v[i].coeffs() == w[(i - 23) % w.size()].coeffs());
116  }
117 }

References i, v, VERIFY, VERIFY_IS_APPROX, w, plotDoE::x, and y.

Referenced by EIGEN_DECLARE_TEST().

◆ check_stddeque_transform()

template<typename TransformType >
void check_stddeque_transform ( const TransformType &  )
60  {
61  typedef typename TransformType::MatrixType MatrixType;
62  TransformType x(MatrixType::Random()), y(MatrixType::Random()), ti = TransformType::Identity();
63  std::deque<TransformType> v(10, ti), w(20, y);
64  v[5] = x;
65  w[6] = v[5];
66  VERIFY_IS_APPROX(w[6], v[5]);
67  v = w;
68  for (int i = 0; i < 20; i++) {
69  VERIFY_IS_APPROX(w[i], v[i]);
70  }
71 
72  v.resize(21, ti);
73  v[20] = x;
74  VERIFY_IS_APPROX(v[20], x);
75  v.resize(22, y);
76  VERIFY_IS_APPROX(v[21], y);
77  v.push_back(x);
78  VERIFY_IS_APPROX(v[22], x);
79 
80  // do a lot of push_back such that the deque gets internally resized
81  // (with memory reallocation)
82  TransformType* ref = &w[0];
83  for (int i = 0; i < 30 || ((ref == &w[0]) && i < 300); ++i) v.push_back(w[i % w.size()]);
84  for (unsigned int i = 23; i < v.size(); ++i) {
85  VERIFY(v[i].matrix() == w[(i - 23) % w.size()].matrix());
86  }
87 }
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85

References i, matrix(), v, VERIFY, VERIFY_IS_APPROX, w, plotDoE::x, and y.

Referenced by EIGEN_DECLARE_TEST().

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( stddeque_overload  )
119  {
120  // some non vectorizable fixed sizes
124 
125  // some vectorizable fixed sizes
130 
131  // some dynamic sizes
132  CALL_SUBTEST_3(check_stddeque_matrix(MatrixXd(1, 1)));
133  CALL_SUBTEST_3(check_stddeque_matrix(VectorXd(20)));
134  CALL_SUBTEST_3(check_stddeque_matrix(RowVectorXf(20)));
135  CALL_SUBTEST_3(check_stddeque_matrix(MatrixXcf(10, 10)));
136 
137  // some Transform
138  CALL_SUBTEST_4(check_stddeque_transform(Affine2f())); // does not need the specialization (2+1)^2 = 9
141 
142  // some Quaternion
145 }
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:686
Quaternion< double > Quaterniond
Definition: Eigen/Eigen/src/Geometry/Quaternion.h:387
Quaternion< float > Quaternionf
Definition: Eigen/Eigen/src/Geometry/Quaternion.h:384
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:682
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:680
#define CALL_SUBTEST_3(FUNC)
Definition: split_test_helper.h:16
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
#define CALL_SUBTEST_5(FUNC)
Definition: split_test_helper.h:28
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22
void check_stddeque_quaternion(const QuaternionType &)
Definition: stddeque_overload.cpp:90
void check_stddeque_matrix(const MatrixType &m)
Definition: stddeque_overload.cpp:29
void check_stddeque_transform(const TransformType &)
Definition: stddeque_overload.cpp:60

References CALL_SUBTEST_1, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, CALL_SUBTEST_5, check_stddeque_matrix(), check_stddeque_quaternion(), and check_stddeque_transform().