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>)
24 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 50, 50, RowMajor>)
26 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 1, 1, ColMajor>)
27 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 2, 2, ColMajor>)
28 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 3, 3, ColMajor>)
29 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 4, 4, ColMajor>)
30 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 5, 5, ColMajor>)
31 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 6, 6, ColMajor>)
32 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 7, 7, ColMajor>)
33 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 8, 8, ColMajor>)
34 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 9, 9, ColMajor>)
35 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 50, 50, ColMajor>)
36 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 2, 1>)
37 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 3, 1>)
38 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 4, 1>)
39 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 5, 1>)
40 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 6, 1>)
41 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 7, 1>)
42 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 8, 1>)
43 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Matrix<double, 9, 1>)
49 using namespace Eigen;
54 std::vector<Quaterniond> q1s(NBT);
55 std::vector<Matrix3d> R3s(NBT);
56 for (
size_t i = 0;
i < NBT; ++
i)
58 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
59 R3s[
i] = Matrix3d::Random();
66 R3s[_smooth] = q1s[_smooth].toRotationMatrix();
69 std::cout <<
label <<
" = \t\t";
70 timer.
toc(std::cout, NBT);
77 using namespace Eigen;
82 std::vector<Quaterniond> q1s(NBT);
83 std::vector<Vector3d> v2s(NBT);
84 std::vector<Vector3d> v3s(NBT);
85 for (
size_t i = 0;
i < NBT; ++
i)
87 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
88 v2s[
i] = Vector3d::Random();
89 v3s[
i] = Vector3d::Random();
96 v3s[_smooth] = q1s[_smooth] * v2s[_smooth];
99 std::cout <<
label <<
" = \t\t";
100 timer.
toc(std::cout, NBT);
107 using namespace Eigen;
112 std::vector<Quaterniond> q1s(NBT);
113 std::vector<Quaterniond> q2s(NBT);
114 std::vector<Quaterniond> q3s(NBT);
115 for (
size_t i = 0;
i < NBT; ++
i)
117 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
118 q2s[
i] = Quaterniond(Vector4d::Random()).normalized();
119 q3s[
i] = Quaterniond(Vector4d::Random()).normalized();
126 q3s[_smooth] = q1s[_smooth] * q2s[_smooth];
129 std::cout <<
label <<
" = \t\t";
130 timer.
toc(std::cout, NBT);
137 using namespace Eigen;
142 std::vector<Quaterniond> q1s(NBT);
143 std::vector<VectorXd> v2s(NBT);
144 std::vector<VectorXd> v3s(NBT);
145 for (
size_t i = 0;
i < NBT; ++
i)
147 q1s[
i] = Quaterniond(Vector4d::Random()).normalized();
148 v2s[
i] = VectorXd::Random(3);
149 v3s[
i] = VectorXd::Random(3);
156 v3s[_smooth] = q1s[_smooth] * v2s[_smooth];
159 std::cout <<
label <<
" = \t\t";
160 timer.
toc(std::cout, NBT);
164 template<
int MSIZE,
int NBT,
int OptionM1,
int OptionM2,
int OptionM3>
167 using namespace Eigen;
172 std::vector<Matrix<double, MSIZE, MSIZE, OptionM1>> R1s(NBT);
173 std::vector<Matrix<double, MSIZE, MSIZE, OptionM2>> R2s(NBT);
174 std::vector<Matrix<double, MSIZE, MSIZE, OptionM3>> R3s(NBT);
175 for (
size_t i = 0;
i < NBT; ++
i)
177 R1s[
i] = Matrix<double, MSIZE, MSIZE, OptionM1>::Random();
178 R2s[
i] = Matrix<double, MSIZE, MSIZE, OptionM2>::Random();
179 R3s[
i] = Matrix<double, MSIZE, MSIZE, OptionM3>::Random();
186 R3s[_smooth].noalias() = R1s[_smooth] * R2s[_smooth];
189 std::cout <<
label <<
" = \t\t";
190 timer.
toc(std::cout, NBT);
194 template<
int MSIZE,
int NBT,
int OptionM1,
int OptionM2,
int OptionM3>
197 using namespace Eigen;
202 std::vector<Matrix<double, MSIZE, MSIZE, OptionM1>> R1s(NBT);
203 std::vector<Matrix<double, MSIZE, MSIZE, OptionM2>> R2s(NBT);
204 std::vector<Matrix<double, MSIZE, MSIZE, OptionM3>> R3s(NBT);
205 for (
size_t i = 0;
i < NBT; ++
i)
207 R1s[
i] = Matrix<double, MSIZE, MSIZE, OptionM1>::Random();
208 R2s[
i] = Matrix<double, MSIZE, MSIZE, OptionM2>::Random();
209 R3s[
i] = Matrix<double, MSIZE, MSIZE, OptionM3>::Random();
216 R3s[_smooth].noalias() = R1s[_smooth].transpose() * R2s[_smooth];
219 std::cout <<
label <<
" = \t\t";
220 timer.
toc(std::cout, NBT);
223 template<
int MSIZE,
int NBT>
226 using namespace Eigen;
229 std::vector<Matrix<double, MSIZE, MSIZE>> R1s(NBT);
230 std::vector<Matrix<double, MSIZE, 1>> v2s(NBT);
231 std::vector<Matrix<double, MSIZE, 1>> v3s(NBT);
232 for (
size_t i = 0;
i < NBT; ++
i)
234 R1s[
i] = Matrix<double, MSIZE, MSIZE>::Random();
235 v2s[
i] = Matrix<double, MSIZE, 1>::Random();
236 v3s[
i] = Matrix<double, MSIZE, 1>::Random();
242 v3s[_smooth] = R1s[_smooth] * v2s[_smooth];
245 std::cout <<
label <<
" = \t\t";
246 timer.
toc(std::cout, NBT);
249 template<
int NBT,
int OptionM1,
int OptionM2,
int OptionM3>
252 using namespace Eigen;
255 std::vector<Matrix<double, Dynamic, Dynamic, OptionM1>> R1s(NBT);
256 std::vector<Matrix<double, Dynamic, Dynamic, OptionM2>> R2s(NBT);
257 std::vector<Matrix<double, Dynamic, Dynamic, OptionM3>> R3s(NBT);
258 for (
size_t i = 0;
i < NBT; ++
i)
260 R1s[
i] = Matrix<double, Dynamic, Dynamic, OptionM1>::Random(MSIZE, MSIZE);
261 R2s[
i] = Matrix<double, Dynamic, Dynamic, OptionM2>::Random(MSIZE, MSIZE);
262 R3s[
i] = Matrix<double, Dynamic, Dynamic, OptionM3>::Random(MSIZE, MSIZE);
268 R3s[_smooth].noalias() = R1s[_smooth] * R2s[_smooth];
271 std::cout <<
label <<
" = \t\t";
272 timer.
toc(std::cout, NBT);
276 template<
int NBT,
int OptionM1,
int OptionM2,
int OptionM3>
279 using namespace Eigen;
282 std::vector<Matrix<double, Dynamic, Dynamic, OptionM1>> R1s(NBT);
283 std::vector<Matrix<double, Dynamic, Dynamic, OptionM2>> R2s(NBT);
284 std::vector<Matrix<double, Dynamic, Dynamic, OptionM3>> R3s(NBT);
285 for (
size_t i = 0;
i < NBT; ++
i)
287 R1s[
i] = Matrix<double, Dynamic, Dynamic, OptionM1>::Random(MSIZE, MSIZE);
288 R2s[
i] = Matrix<double, Dynamic, Dynamic, OptionM2>::Random(MSIZE, MSIZE);
289 R3s[
i] = Matrix<double, Dynamic, Dynamic, OptionM3>::Random(MSIZE, MSIZE);
295 R3s[_smooth].noalias() = R1s[_smooth].transpose() * R2s[_smooth];
298 std::cout <<
label <<
" = \t\t";
299 timer.
toc(std::cout, NBT);
305 using namespace Eigen;
308 std::vector<MatrixXd> R1s(NBT);
309 std::vector<MatrixXd> v2s(NBT);
310 std::vector<MatrixXd> v3s(NBT);
311 for (
size_t i = 0;
i < NBT; ++
i)
313 R1s[
i] = MatrixXd::Random(MSIZE, MSIZE);
314 v2s[
i] = MatrixXd::Random(MSIZE, 1);
315 v3s[
i] = MatrixXd::Random(MSIZE, 1);
321 v3s[_smooth] = R1s[_smooth] * v2s[_smooth];
324 std::cout <<
label <<
" = \t\t";
325 timer.
toc(std::cout, NBT);
332 const int NBT = 1000 * 1000;
335 std::cout <<
"(the time score in debug mode is not relevant) " << std::endl;
337 checkQuaternion<NBT>(
"quaternion-vector static ");
338 checkQuaternionD<NBT>(
"quaternion-vector dynamic");
339 checkQuaternionQuaternion<NBT>(
"quaternion-quaternion ");
340 checkQuaternionToMatrix<NBT>(
"quaternion->matrix static");
341 std::cout << std::endl;
343 using namespace Eigen;
344 checkVector<3, NBT>(
"matrix-vector static 3x3");
345 checkDVector<NBT>(3,
"matrix-vector dynamic 3x3");
346 checkMatrix<3, NBT, ColMajor, ColMajor, ColMajor>(
"colmatrix = colmatrix*colmatrix static 3x3");
347 checkMatrix<3, NBT, RowMajor, ColMajor, ColMajor>(
"colmatrix = rowmatrix*colmatrix static 3x3");
348 checkMatrix<3, NBT, ColMajor, RowMajor, ColMajor>(
"colmatrix = colmatrix*rowmatrix static 3x3");
349 checkMatrix<3, NBT, RowMajor, RowMajor, ColMajor>(
"colmatrix = rowmatrix*rowmatrix static 3x3");
350 checkMatrix<3, NBT, ColMajor, ColMajor, RowMajor>(
"rowmatrix = colmatrix*colmatrix static 3x3");
351 checkMatrix<3, NBT, RowMajor, ColMajor, RowMajor>(
"rowmatrix = rowmatrix*colmatrix static 3x3");
352 checkMatrix<3, NBT, ColMajor, RowMajor, RowMajor>(
"rowmatrix = colmatrix*rowmatrix static 3x3");
353 checkMatrix<3, NBT, RowMajor, RowMajor, RowMajor>(
"rowmatrix = rowmatrix*rowmatrix static 3x3");
355 checkDMatrix<NBT, ColMajor, ColMajor, ColMajor>(
356 3,
"colmatrix = colmatrix*colmatrix dynamic 3x3");
357 checkDMatrix<NBT, RowMajor, ColMajor, ColMajor>(
358 3,
"colmatrix = rowmatrix*colmatrix dynamic 3x3");
359 checkDMatrix<NBT, ColMajor, RowMajor, ColMajor>(
360 3,
"colmatrix = colmatrix*rowmatrix dynamic 3x3");
361 checkDMatrix<NBT, RowMajor, RowMajor, ColMajor>(
362 3,
"colmatrix = rowmatrix*rowmatrix dynamic 3x3");
363 checkDMatrix<NBT, ColMajor, ColMajor, RowMajor>(
364 3,
"rowmatrix = colmatrix*colmatrix dynamic 3x3");
365 checkDMatrix<NBT, RowMajor, ColMajor, RowMajor>(
366 3,
"rowmatrix = rowmatrix*colmatrix dynamic 3x3");
367 checkDMatrix<NBT, ColMajor, RowMajor, RowMajor>(
368 3,
"rowmatrix = colmatrix*rowmatrix dynamic 3x3");
369 checkDMatrix<NBT, RowMajor, RowMajor, RowMajor>(
370 3,
"rowmatrix = rowmatrix*rowmatrix dynamic 3x3");
372 std::cout << std::endl;
374 checkVector<4, NBT>(
"matrix-vector static 4x4");
375 checkDVector<NBT>(4,
"matrix-vector dynamic 4x4");
377 checkMatrix<4, NBT, ColMajor, ColMajor, ColMajor>(
"colmatrix = colmatrix*colmatrix static 4x4");
378 checkMatrix<4, NBT, RowMajor, ColMajor, ColMajor>(
"colmatrix = rowmatrix*colmatrix static 4x4");
379 checkMatrix<4, NBT, ColMajor, RowMajor, ColMajor>(
"colmatrix = colmatrix*rowmatrix static 4x4");
380 checkMatrix<4, NBT, RowMajor, RowMajor, ColMajor>(
"colmatrix = rowmatrix*rowmatrix static 4x4");
381 checkMatrix<4, NBT, ColMajor, ColMajor, RowMajor>(
"rowmatrix = colmatrix*colmatrix static 4x4");
382 checkMatrix<4, NBT, RowMajor, ColMajor, RowMajor>(
"rowmatrix = rowmatrix*colmatrix static 4x4");
383 checkMatrix<4, NBT, ColMajor, RowMajor, RowMajor>(
"rowmatrix = colmatrix*rowmatrix static 4x4");
384 checkMatrix<4, NBT, RowMajor, RowMajor, RowMajor>(
"rowmatrix = rowmatrix*rowmatrix static 4x4");
386 checkMatrixTMatrix<4, NBT, ColMajor, ColMajor, ColMajor>(
387 "colmatrix = colmatrix.transpose()*colmatrix static 4x4");
388 checkMatrixTMatrix<4, NBT, RowMajor, ColMajor, ColMajor>(
389 "colmatrix = rowmatrix.transpose()*colmatrix static 4x4");
390 checkMatrixTMatrix<4, NBT, ColMajor, RowMajor, ColMajor>(
391 "colmatrix = colmatrix.transpose()*rowmatrix static 4x4");
392 checkMatrixTMatrix<4, NBT, RowMajor, RowMajor, ColMajor>(
393 "colmatrix = rowmatrix.transpose()*rowmatrix static 4x4");
394 checkMatrixTMatrix<4, NBT, ColMajor, ColMajor, RowMajor>(
395 "rowmatrix = colmatrix.transpose()*colmatrix static 4x4");
396 checkMatrixTMatrix<4, NBT, RowMajor, ColMajor, RowMajor>(
397 "rowmatrix = rowmatrix.transpose()*colmatrix static 4x4");
398 checkMatrixTMatrix<4, NBT, ColMajor, RowMajor, RowMajor>(
399 "rowmatrix = colmatrix.transpose()*rowmatrix static 4x4");
400 checkMatrixTMatrix<4, NBT, RowMajor, RowMajor, RowMajor>(
401 "rowmatrix = rowmatrix.transpose()*rowmatrix static 4x4");
403 checkDMatrix<NBT, ColMajor, ColMajor, ColMajor>(
404 4,
"colmatrix = colmatrix*colmatrix dynamic 4x4");
405 checkDMatrix<NBT, RowMajor, ColMajor, ColMajor>(
406 4,
"colmatrix = rowmatrix*colmatrix dynamic 4x4");
407 checkDMatrix<NBT, ColMajor, RowMajor, ColMajor>(
408 4,
"colmatrix = colmatrix*rowmatrix dynamic 4x4");
409 checkDMatrix<NBT, RowMajor, RowMajor, ColMajor>(
410 4,
"colmatrix = rowmatrix*rowmatrix dynamic 4x4");
411 checkDMatrix<NBT, ColMajor, ColMajor, RowMajor>(
412 4,
"rowmatrix = colmatrix*colmatrix dynamic 4x4");
413 checkDMatrix<NBT, RowMajor, ColMajor, RowMajor>(
414 4,
"rowmatrix = rowmatrix*colmatrix dynamic 4x4");
415 checkDMatrix<NBT, ColMajor, RowMajor, RowMajor>(
416 4,
"rowmatrix = colmatrix*rowmatrix dynamic 4x4");
417 checkDMatrix<NBT, RowMajor, RowMajor, RowMajor>(
418 4,
"rowmatrix = rowmatrix*rowmatrix dynamic 4x4");
420 checkDMatrixTMatrix<NBT, ColMajor, ColMajor, ColMajor>(
421 4,
"colmatrix = colmatrix.transpose()*colmatrix dynamic 4x4");
422 checkDMatrixTMatrix<NBT, RowMajor, ColMajor, ColMajor>(
423 4,
"colmatrix = rowmatrix.transpose()*colmatrix dynamic 4x4");
424 checkDMatrixTMatrix<NBT, ColMajor, RowMajor, ColMajor>(
425 4,
"colmatrix = colmatrix.transpose()*rowmatrix dynamic 4x4");
426 checkDMatrixTMatrix<NBT, RowMajor, RowMajor, ColMajor>(
427 4,
"colmatrix = rowmatrix.transpose()*rowmatrix dynamic 4x4");
428 checkDMatrixTMatrix<NBT, ColMajor, ColMajor, RowMajor>(
429 4,
"rowmatrix = colmatrix.transpose()*colmatrix dynamic 4x4");
430 checkDMatrixTMatrix<NBT, RowMajor, ColMajor, RowMajor>(
431 4,
"rowmatrix = rowmatrix.transpose()*colmatrix dynamic 4x4");
432 checkDMatrixTMatrix<NBT, ColMajor, RowMajor, RowMajor>(
433 4,
"rowmatrix = colmatrix.transpose()*rowmatrix dynamic 4x4");
434 checkDMatrixTMatrix<NBT, RowMajor, RowMajor, RowMajor>(
435 4,
"rowmatrix = rowmatrix.transpose()*rowmatrix dynamic 4x4");
437 checkMatrix<50, NBT / 10, ColMajor, ColMajor, ColMajor>(
438 "colmatrix = colmatrix*colmatrix static 50x50");
439 checkMatrix<50, NBT / 10, RowMajor, ColMajor, ColMajor>(
440 "colmatrix = rowmatrix*colmatrix static 50x50");
441 checkMatrix<50, NBT / 10, ColMajor, RowMajor, ColMajor>(
442 "colmatrix = colmatrix*rowmatrix static 50x50");
443 checkMatrix<50, NBT / 10, RowMajor, RowMajor, ColMajor>(
444 "colmatrix = rowmatrix*rowmatrix static 50x50");
445 checkMatrix<50, NBT / 10, ColMajor, ColMajor, RowMajor>(
446 "rowmatrix = colmatrix*colmatrix static 50x50");
447 checkMatrix<50, NBT / 10, RowMajor, ColMajor, RowMajor>(
448 "rowmatrix = rowmatrix*colmatrix static 50x50");
449 checkMatrix<50, NBT / 10, ColMajor, RowMajor, RowMajor>(
450 "rowmatrix = colmatrix*rowmatrix static 50x50");
451 checkMatrix<50, NBT / 10, RowMajor, RowMajor, RowMajor>(
452 "rowmatrix = rowmatrix*rowmatrix static 50x50");
455 "colmatrix = colmatrix.transpose()*colmatrix static 50x50");
457 "colmatrix = rowmatrix.transpose()*colmatrix static 50x50");
459 "colmatrix = colmatrix.transpose()*rowmatrix static 50x50");
461 "colmatrix = rowmatrix.transpose()*rowmatrix static 50x50");
463 "rowmatrix = colmatrix.transpose()*colmatrix static 50x50");
465 "rowmatrix = rowmatrix.transpose()*colmatrix static 50x50");
467 "rowmatrix = colmatrix.transpose()*rowmatrix static 50x50");
469 "rowmatrix = rowmatrix.transpose()*rowmatrix static 50x50");
472 50,
"colmatrix = colmatrix*colmatrix dynamic 50x50");
474 50,
"colmatrix = rowmatrix*colmatrix dynamic 50x50");
476 50,
"colmatrix = colmatrix*rowmatrix dynamic 50x50");
478 50,
"colmatrix = rowmatrix*rowmatrix dynamic 50x50");
480 50,
"rowmatrix = colmatrix*colmatrix dynamic 50x50");
482 50,
"rowmatrix = rowmatrix*colmatrix dynamic 50x50");
484 50,
"rowmatrix = colmatrix*rowmatrix dynamic 50x50");
486 50,
"rowmatrix = rowmatrix*rowmatrix dynamic 50x50");
489 50,
"colmatrix = colmatrix.transpose()*colmatrix dynamic 50x50");
491 50,
"colmatrix = rowmatrix.transpose()*colmatrix dynamic 50x50");
493 50,
"colmatrix = colmatrix.transpose()*rowmatrix dynamic 50x50");
495 50,
"colmatrix = rowmatrix.transpose()*rowmatrix dynamic 50x50");
497 50,
"rowmatrix = colmatrix.transpose()*colmatrix dynamic 50x50");
499 50,
"rowmatrix = rowmatrix.transpose()*colmatrix dynamic 50x50");
501 50,
"rowmatrix = colmatrix.transpose()*rowmatrix dynamic 50x50");
503 50,
"rowmatrix = rowmatrix.transpose()*rowmatrix dynamic 50x50");
505 std::cout << std::endl;
507 std::cout <<
"--" << std::endl;