6 #include "pinocchio/utils/timer.hpp" 8 #include <Eigen/Geometry> 9 #include <Eigen/StdVector> 11 using namespace Eigen;
13 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Quaternion<double>)
15 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,1,1,RowMajor>)
16 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,2,2,RowMajor>)
17 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,3,3,RowMajor>)
18 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,4,4,RowMajor>)
19 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,5,5,RowMajor>)
20 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,6,6,RowMajor>)
21 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,7,7,RowMajor>)
22 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,8,8,RowMajor>)
23 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,9,9,RowMajor>)
25 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,1,1,ColMajor>)
26 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,2,2,ColMajor>)
27 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,3,3,ColMajor>)
28 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,4,4,ColMajor>)
29 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,5,5,ColMajor>)
30 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,6,6,ColMajor>)
31 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,7,7,ColMajor>)
32 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,8,8,ColMajor>)
33 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,9,9,ColMajor>)
35 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,2,1>)
36 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,3,1>)
37 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,4,1>)
38 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,5,1>)
39 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,6,1>)
40 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,7,1>)
41 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,8,1>)
42 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<
double,9,1>)
48 using namespace Eigen;
53 std::vector< Quaterniond > q1s (NBT);
54 std::vector< Matrix3d > R3s (NBT);
55 for(
size_t i=0;
i<NBT;++
i)
57 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
58 R3s[
i] = Matrix3d::Random();
65 R3s[_smooth] = q1s[_smooth].toRotationMatrix();
68 std::cout << label <<
" = \t\t" ; timer.
toc(std::cout,NBT);
75 using namespace Eigen;
80 std::vector< Quaterniond > q1s (NBT);
81 std::vector< Vector3d > v2s (NBT);
82 std::vector< Vector3d > v3s (NBT);
83 for(
size_t i=0;
i<NBT;++
i)
85 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
86 v2s[
i] = Vector3d::Random();
87 v3s[
i] = Vector3d::Random();
94 v3s[_smooth] = q1s[_smooth]*v2s[_smooth];
97 std::cout << label <<
" = \t\t" ; timer.
toc(std::cout,NBT);
104 using namespace Eigen;
109 std::vector< Quaterniond > q1s (NBT);
110 std::vector< Quaterniond > q2s (NBT);
111 std::vector< Quaterniond > q3s (NBT);
112 for(
size_t i=0;
i<NBT;++
i)
114 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
115 q2s[
i] = Quaterniond(Vector4d::Random()).normalized();
116 q3s[
i] = Quaterniond(Vector4d::Random()).normalized();
123 q3s[_smooth] = q1s[_smooth]*q2s[_smooth];
126 std::cout << label <<
" = \t\t" ; timer.
toc(std::cout,NBT);
133 using namespace Eigen;
138 std::vector< Quaterniond > q1s (NBT);
139 std::vector< VectorXd > v2s (NBT);
140 std::vector< VectorXd > v3s (NBT);
141 for(
size_t i=0;
i<NBT;++
i)
143 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
144 v2s[
i] = VectorXd::Random(3);
145 v3s[
i] = VectorXd::Random(3);
152 v3s[_smooth] = q1s[_smooth]*v2s[_smooth];
155 std::cout << label <<
" = \t\t" ; timer.
toc(std::cout,NBT);
158 template<
int MSIZE,
int NBT>
166 using namespace Eigen;
171 std::vector< Matrix<double,MSIZE,MSIZE,RC1> > R1s (NBT);
172 std::vector< Matrix<double,MSIZE,MSIZE,RC2> > R2s (NBT);
173 std::vector< Matrix<double,MSIZE,MSIZE,RC3> > R3s (NBT);
174 for(
size_t i=0;
i<NBT;++
i)
176 R1s[
i] = Matrix<double,MSIZE,MSIZE,RC1>::Random();
177 R2s[
i] = Matrix<double,MSIZE,MSIZE,RC2>::Random();
178 R3s[
i] = Matrix<double,MSIZE,MSIZE,RC3>::Random();
185 R3s[_smooth] = R1s[_smooth]*R2s[_smooth];
188 std::cout << label <<
" = \t\t" ; timer.
toc(std::cout,NBT);
191 template<
int MSIZE,
int NBT>
194 using namespace Eigen;
197 std::vector< Matrix<double,MSIZE,MSIZE> > R1s (NBT);
198 std::vector< Matrix<double,MSIZE,1> > v2s (NBT);
199 std::vector< Matrix<double,MSIZE,1> > v3s (NBT);
200 for(
size_t i=0;
i<NBT;++
i)
202 R1s[
i] = Matrix<double,MSIZE,MSIZE>::Random();
203 v2s[
i] = Matrix<double,MSIZE,1>::Random();
204 v3s[
i] = Matrix<double,MSIZE,1>::Random();
210 v3s[_smooth] = R1s[_smooth]*v2s[_smooth];
213 std::cout << label <<
" = \t\t"; timer.
toc(std::cout,NBT);
219 using namespace Eigen;
222 std::vector< MatrixXd > R1s (NBT);
223 std::vector< MatrixXd > R2s (NBT);
224 std::vector< MatrixXd > R3s (NBT);
225 for(
size_t i=0;
i<NBT;++
i)
227 R1s[
i] = MatrixXd::Random(MSIZE,MSIZE);
228 R2s[
i] = MatrixXd::Random(MSIZE,MSIZE);
229 R3s[
i] = MatrixXd::Random(MSIZE,MSIZE);
235 R3s[_smooth] = R1s[_smooth]*R2s[_smooth];
238 std::cout << label <<
" = \t\t"; timer.
toc(std::cout,NBT);
244 using namespace Eigen;
247 std::vector< MatrixXd > R1s (NBT);
248 std::vector< MatrixXd > v2s (NBT);
249 std::vector< MatrixXd > v3s (NBT);
250 for(
size_t i=0;
i<NBT;++
i)
252 R1s[
i] = MatrixXd::Random(MSIZE,MSIZE);
253 v2s[
i] = MatrixXd::Random(MSIZE,1);
254 v3s[
i] = MatrixXd::Random(MSIZE,1);
260 v3s[_smooth] = R1s[_smooth]*v2s[_smooth];
263 std::cout << label <<
" = \t\t"; timer.
toc(std::cout,NBT);
271 const int NBT = 1000*1000;
274 std::cout <<
"(the time score in debug mode is not relevant) " << std::endl;
276 checkQuaternion<NBT>(
"quaternion-vector static ");
277 checkQuaternionD<NBT>(
"quaternion-vector dynamic");
278 checkQuaternionQuaternion<NBT>(
"quaternion-quaternion ");
279 checkQuaternionToMatrix<NBT>(
"quaternion->matrix static");
280 std::cout << std::endl;
282 checkVector<3,NBT> (
"matrix-vector static 3x3");
283 checkDVector<NBT> (3,
"matrix-vector dynamic 3x3");
284 checkMatrix<3,NBT> (
"matrix-matrix static 3x3");
285 checkDMatrix<NBT> (3,
"matrix-matrix dynamic 3x3");
286 std::cout << std::endl;
288 checkVector<4,NBT> (
"matrix-vector static 4x4");
289 checkDVector<NBT> (4,
"matrix-vector dynamic 4x4");
290 checkMatrix<4,NBT> (
"matrix-matrix static 4x4");
291 checkDMatrix<NBT> (4,
"matrix-matrix dynamic 4x4");
292 std::cout << std::endl;
294 std::cout <<
"--" << std::endl;
void checkMatrix(std::string label)
void checkVector(std::string label)
void checkQuaternionQuaternion(std::string label)
void checkDMatrix(int MSIZE, std::string label)
void checkQuaternionToMatrix(std::string label)
void checkQuaternionD(std::string label)
void checkQuaternion(std::string label)
void checkDVector(int MSIZE, std::string label)