humoto
eigentools.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @author Jan Michalczyk
5  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
6  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 
12 /**
13  * @page EigenTools EigenTools
14  *
15  * @anchor eigentools_casting_hack
16  *
17  * @note Since an attempt to write to a temporary object may result in a
18  * compilation error, it is not possible to use the result of matrix.block() as
19  * an output parameter of a function. However, there is a workaround: the
20  * parameter can be declared as const and then casted to non-const as suggested
21  * in Eigen's documentation:
22  * https://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html.
23  * This hack is useful when it is necessary to handle matrix blocks and
24  * matrices identically.
25  */
26 
27 
28 #pragma once
29 
30 /**
31  * @defgroup EigenTools EigenTools
32  * @brief Utility functions based on Eigen.
33  */
34 
35 /// @ingroup EigenTools
36 namespace etools
37 {
38  typedef double DefaultScalar;
39  //#define EIGENTOOLS_ENABLE_EIGENTYPE_DETECTION
40 
41 
42  typedef Eigen::Matrix<etools::DefaultScalar, Eigen::Dynamic, Eigen::Dynamic> DefaultDynamicMatrix;
43 
44 
45  /// @attention Won't work if 'Scalar' contains commas.
46  #define EIGENTOOLS_DYNAMIC_MATRIX(Scalar) Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
47 
48  /// @attention Won't work if 'Scalar' contains commas.
49  #define EIGENTOOLS_DYNAMIC_VECTOR(Scalar) Eigen::Matrix<Scalar, Eigen::Dynamic, 1>
50 
51 
52  #ifdef EIGENTOOLS_DISABLE_ALIGNMENT_OF_STATIC_MATRICES
53  #define EIGENTOOLS_CONSTANT_SIZE_ALIGN_TYPE Eigen::DontAlign
54  #else
55  #define EIGENTOOLS_CONSTANT_SIZE_ALIGN_TYPE Eigen::AutoAlign
56  #endif
57 
58  #define EIGENTOOLS_CONSTANT_SIZE_VECTOR(rows) Eigen::Matrix<etools::DefaultScalar, rows, 1, EIGENTOOLS_CONSTANT_SIZE_ALIGN_TYPE>
59  #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
60  // This may not work
61  #define EIGENTOOLS_CONSTANT_SIZE_MATRIX(rows, cols) Eigen::Matrix<etools::DefaultScalar, rows, cols, EIGENTOOLS_CONSTANT_SIZE_ALIGN_TYPE>
62  #else
63  #define EIGENTOOLS_CONSTANT_SIZE_MATRIX(rows, cols) Eigen::Matrix<etools::DefaultScalar, rows, cols, EIGENTOOLS_CONSTANT_SIZE_ALIGN_TYPE | ((rows==1) ? (Eigen::RowMajor) : (Eigen::ColMajor))>
64  #endif
65 
66  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(2) Vector2;
67  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(3) Vector3;
68  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(4) Vector4;
69  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(5) Vector5;
70  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(6) Vector6;
71  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(7) Vector7;
72  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(8) Vector8;
73  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(9) Vector9;
74  typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(10) Vector10;
75 
77  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 3) Matrix3;
78  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 4) Matrix4;
79  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 5) Matrix5;
80  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 6) Matrix6;
81  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 7) Matrix7;
82  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 8) Matrix8;
83  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 9) Matrix9;
84  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 10) Matrix10;
85 
86  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 1) Matrix1x2;
87  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 3) Matrix1x3;
88  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 4) Matrix1x4;
89  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 5) Matrix1x5;
90  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 6) Matrix1x6;
91  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 7) Matrix1x7;
92  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 8) Matrix1x8;
93  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 9) Matrix1x9;
94  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(1, 10) Matrix1x10;
95  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 3) Matrix2x3;
96  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 4) Matrix2x4;
97  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 5) Matrix2x5;
98  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 6) Matrix2x6;
99  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 7) Matrix2x7;
100  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 8) Matrix2x8;
101  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 9) Matrix2x9;
102  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(2, 10) Matrix2x10;
103  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 2) Matrix3x2;
104  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 4) Matrix3x4;
105  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 5) Matrix3x5;
106  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 6) Matrix3x6;
107  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 7) Matrix3x7;
108  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 8) Matrix3x8;
109  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 9) Matrix3x9;
110  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(3, 10) Matrix3x10;
111  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 2) Matrix4x2;
112  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 3) Matrix4x3;
113  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 5) Matrix4x5;
114  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 6) Matrix4x6;
115  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 7) Matrix4x7;
116  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 8) Matrix4x8;
117  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 9) Matrix4x9;
118  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(4, 10) Matrix4x10;
119  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 2) Matrix5x2;
120  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 3) Matrix5x3;
121  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 4) Matrix5x4;
122  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 6) Matrix5x6;
123  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 7) Matrix5x7;
124  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 8) Matrix5x8;
125  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 9) Matrix5x9;
126  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(5, 10) Matrix5x10;
127  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 2) Matrix6x2;
128  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 3) Matrix6x3;
129  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 4) Matrix6x4;
130  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 5) Matrix6x5;
131  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 7) Matrix6x7;
132  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 8) Matrix6x8;
133  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 9) Matrix6x9;
134  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(6, 10) Matrix6x10;
135  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 2) Matrix7x2;
136  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 3) Matrix7x3;
137  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 4) Matrix7x4;
138  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 5) Matrix7x5;
139  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 6) Matrix7x6;
140  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 8) Matrix7x8;
141  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 9) Matrix7x9;
142  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(7, 10) Matrix7x10;
143  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 2) Matrix8x2;
144  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 3) Matrix8x3;
145  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 4) Matrix8x4;
146  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 5) Matrix8x5;
147  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 6) Matrix8x6;
148  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 7) Matrix8x7;
149  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 9) Matrix8x9;
150  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(8, 10) Matrix8x10;
151  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 2) Matrix9x2;
152  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 3) Matrix9x3;
153  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 4) Matrix9x4;
154  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 5) Matrix9x5;
155  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 6) Matrix9x6;
156  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 7) Matrix9x7;
157  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 8) Matrix9x8;
158  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(9, 10) Matrix9x10;
159  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 2) Matrix10x2;
160  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 3) Matrix10x3;
161  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 4) Matrix10x4;
162  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 5) Matrix10x5;
163  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 6) Matrix10x6;
164  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 7) Matrix10x7;
165  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 8) Matrix10x8;
166  typedef EIGENTOOLS_CONSTANT_SIZE_MATRIX(10, 9) Matrix10x9;
167 
168 
169 
170  /**
171  * @brief Unset matrix (initialize to NaN)
172  *
173  * @tparam t_Derived matrix data type
174  *
175  * @param[in,out] matrix
176  */
177  template <typename t_Derived>
178  void unsetMatrix (Eigen::DenseBase< t_Derived > &matrix)
179  {
180  if (std::numeric_limits<etools::DefaultScalar>::has_quiet_NaN)
181  {
182  matrix.setConstant(std::numeric_limits<etools::DefaultScalar>::quiet_NaN());
183  }
184  else
185  {
186  matrix.setZero();
187  }
188  }
189 
190 
191  /**
192  * @brief result = A^T * A
193  *
194  * @tparam t_DerivedOutput Eigen parameter
195  * @tparam t_DerivedInput Eigen parameter
196  *
197  * @param[out] result
198  * @param[in] A
199  *
200  * @attention Only the left lower triangular part of the result is initialized.
201  */
202  template<class t_DerivedOutput, class t_DerivedInput>
204  getATA( Eigen::PlainObjectBase<t_DerivedOutput> &result,
205  const Eigen::DenseBase<t_DerivedInput> &A)
206  {
207  std::ptrdiff_t num_el = A.cols();
208  result.resize(num_el,num_el);
209  for (std::ptrdiff_t i = 0; i < num_el; ++i)
210  {
211  result.block(i, i, num_el-i, 1).noalias() = A.transpose().bottomRows(num_el-i) * A.col(i);
212  }
213  }
214 
215 
216  /**
217  * @brief result.diagonalBlock() = A^T * A
218  *
219  * @tparam t_DerivedOutput Eigen parameter
220  * @tparam t_DerivedInput Eigen parameter
221  *
222  * @param[out] result
223  * @param[in] A
224  * @param[in] offset offset of A in result
225  * @param[in] num_el size of result
226  *
227  * @attention Only the left lower triangular part of the result is initialized.
228  */
229  template<class t_DerivedOutput, class t_DerivedInput>
231  getATA( Eigen::PlainObjectBase<t_DerivedOutput> &result,
232  const Eigen::DenseBase<t_DerivedInput> &A,
233  const std::ptrdiff_t offset,
234  const std::ptrdiff_t num_el)
235  {
236  std::ptrdiff_t A_num_col = A.cols();
237  result.resize(num_el, num_el);
238  result.template triangularView<Eigen::Lower>().setZero();
239  for (std::ptrdiff_t i = 0; i < A_num_col; ++i)
240  {
241  result.block( offset,
242  offset,
243  A_num_col,
244  A_num_col).block(i, i, A_num_col-i, 1).noalias() = A.transpose().bottomRows(A_num_col-i) * A.col(i);
245  }
246  }
247 
248 
249  /**
250  * @brief result += A^T * A
251  *
252  * @tparam t_DerivedOutput Eigen parameter
253  * @tparam t_DerivedInput Eigen parameter
254  *
255  * @param[in,out] result
256  * @param[in] A
257  *
258  * @attention Only the left lower triangular part of the result is initialized.
259  */
260  template<class t_DerivedOutput, class t_DerivedInput>
262  addATA( Eigen::DenseBase<t_DerivedOutput> &result,
263  const Eigen::DenseBase<t_DerivedInput> &A)
264  {
265  std::ptrdiff_t num_el = A.cols();
266  for (std::ptrdiff_t i = 0; i < num_el; ++i)
267  {
268  result.block(i, i, num_el-i, 1).noalias() += A.transpose().bottomRows(num_el-i) * A.col(i);
269  }
270  }
271 
272 
273  /**
274  * @brief result.diagonalBlock() += A^T * A
275  *
276  * @tparam t_DerivedOutput Eigen parameter
277  * @tparam t_DerivedInput Eigen parameter
278  *
279  * @param[in,out] result
280  * @param[in] A
281  * @param[in] offset offset of A in result
282  *
283  * @attention Only the left lower triangular part of the result is initialized.
284  */
285  template<class t_DerivedOutput, class t_DerivedInput>
287  addATA( Eigen::DenseBase<t_DerivedOutput> &result,
288  const Eigen::DenseBase<t_DerivedInput> &A,
289  const std::ptrdiff_t offset)
290  {
291  std::ptrdiff_t A_num_col = A.cols();
292  for (std::ptrdiff_t i = 0; i < A_num_col; ++i)
293  {
294  result.block( offset,
295  offset,
296  A_num_col,
297  A_num_col).block(i, i, A_num_col-i, 1).noalias() += A.transpose().bottomRows(A_num_col-i) * A.col(i);
298  }
299  }
300 
301 
302 
303  /**
304  * @brief Converts left lower triangular matrix to a symmetric matrix.
305  *
306  * @tparam t_Derived Eigen parameter
307  *
308  * @param[in,out] matrix
309  */
310  template<class t_Derived>
312  convertLLTtoSymmetric(Eigen::PlainObjectBase<t_Derived> &matrix)
313  {
314  std::ptrdiff_t num_el = matrix.cols();
315  for (std::ptrdiff_t i = 0; i < num_el-1; ++i)
316  {
317  matrix.block(i, i+1, 1, num_el-i-1) = matrix.transpose().block(i, i+1, 1, num_el-i-1);
318  }
319  }
320 
321 
322  /**
323  * @brief Transform the input positions given as a concatenated set of 2d/3d
324  * vectors, given M = [v1, v2, ...], returns M_new = [R*v1 + t, R*v2 + t, ...]
325  *
326  * @tparam t_DerivedMatrix Eigen parameter
327  * @tparam t_DerivedRotation Eigen parameter
328  * @tparam t_DerivedTranslation Eigen parameter
329  *
330  * @param[in] matrix matrix containing vectors (M)
331  * @param[in] rotation rotation matrix (R)
332  * @param[in] translation translation vector (t)
333  *
334  * @return matrix of transformed vectors
335  */
336  template <class t_DerivedMatrix, class t_DerivedRotation, class t_DerivedTranslation>
337  inline Eigen::Matrix< typename Eigen::MatrixBase<t_DerivedMatrix>::Scalar,
338  Eigen::MatrixBase<t_DerivedMatrix>::RowsAtCompileTime,
339  Eigen::MatrixBase<t_DerivedMatrix>::ColsAtCompileTime>
341  transform( const Eigen::MatrixBase<t_DerivedMatrix> &matrix,
342  const Eigen::MatrixBase<t_DerivedRotation> &rotation,
343  const Eigen::MatrixBase<t_DerivedTranslation> &translation)
344  {
345  return ((rotation*matrix).colwise() + translation);
346  }
347 
348 
349 
350  /**
351  * @brief Create a diagonal matrix consisting of the input matrices
352  *
353  * @tparam t_Scalar Eigen parameter (input)
354  * @tparam t_rows Eigen parameter (input)
355  * @tparam t_cols Eigen parameter (input)
356  * @tparam t_flags Eigen parameter (input)
357  *
358  * @param[in] input_matrices vector of smaller matrices to be placed into a large block diagonal matrix
359  *
360  * @return matrix with each input element as a block in the diagonal
361  */
362  template< typename t_Scalar,
363  int t_rows,
364  int t_cols,
365  int t_flags>
366  EIGENTOOLS_DYNAMIC_MATRIX(t_Scalar)
368  makeBlockDiagonal(const std::vector<Eigen::Matrix<t_Scalar, t_rows, t_cols, t_flags> > &input_matrices)
369  {
370  switch (input_matrices.size())
371  {
372  case 0:
373  return (EIGENTOOLS_DYNAMIC_MATRIX(t_Scalar)());
374 
375  case 1:
376  return (input_matrices[0]);
377 
378  default:
379  // Initialize the output diagonal matrix
380  std::ptrdiff_t row_size = 0;
381  std::ptrdiff_t col_size = 0;
382 
383  for(std::size_t i = 0; i < input_matrices.size(); ++i)
384  {
385  row_size += input_matrices[i].rows();
386  col_size += input_matrices[i].cols();
387  }
388  EIGENTOOLS_DYNAMIC_MATRIX(t_Scalar) output;
389  output.setZero(row_size, col_size);
390 
391  // Add in the input matrices
392  std::ptrdiff_t cumulative_row = 0;
393  std::ptrdiff_t cumulative_col = 0;
394 
395  for(std::size_t i = 0; i < input_matrices.size(); ++i)
396  {
397  int current_num_rows = input_matrices[i].rows();
398  int current_num_cols = input_matrices[i].cols();
399 
400  output.block(cumulative_row, cumulative_col, current_num_rows, current_num_cols) = input_matrices[i];
401 
402  cumulative_row += current_num_rows;
403  cumulative_col += current_num_cols;
404  }
405  return output;
406  }
407  }
408 
409 
410 
411  /**
412  * @brief Create a diagonal matrix replicating the input matrix
413  *
414  * @tparam t_DerivedInput Eigen parameter (input)
415  *
416  * @param[in] input_matrix matrix to be replicated into block diagonal
417  * @param[in] num_copies determines the output size
418  *
419  * @return matrix with each input element as a block in the diagonal
420  */
421  template<class t_DerivedInput>
422  EIGENTOOLS_DYNAMIC_MATRIX(typename Eigen::DenseBase<t_DerivedInput>::Scalar)
424  makeBlockDiagonal( const Eigen::DenseBase<t_DerivedInput> &input_matrix,
425  const std::ptrdiff_t num_copies)
426  {
427  switch (num_copies)
428  {
429  case 0:
430  return (EIGENTOOLS_DYNAMIC_MATRIX(typename Eigen::DenseBase<t_DerivedInput>::Scalar)());
431 
432  case 1:
433  return (input_matrix);
434 
435  default:
436  // Initialize the output diagonal matrix
437  EIGENTOOLS_DYNAMIC_MATRIX(typename Eigen::DenseBase<t_DerivedInput>::Scalar) output;
438 
439  output.setZero(num_copies * input_matrix.rows(),
440  num_copies * input_matrix.cols());
441 
442  // Replicate the input matrix into block diagonal form
443  for(std::ptrdiff_t i = 0; i < num_copies; ++i)
444  {
445  output.block(i*input_matrix.rows(), i*input_matrix.cols(),
446  input_matrix.rows(), input_matrix.cols()) = input_matrix;
447  }
448  return (output);
449  }
450  }
451 
452 
453 
454  /**
455  * @brief Concatenate matrices vertically, [A;B;C; ...]
456  *
457  * @tparam t_DerivedOutput Eigen parameter
458  * @tparam t_Scalar Eigen parameter (input)
459  * @tparam t_rows Eigen parameter (input)
460  * @tparam t_cols Eigen parameter (input)
461  * @tparam t_flags Eigen parameter (input)
462  *
463  * @param[out] result result of concatenation
464  * @param[in] matrices matrices
465  */
466  template< class t_DerivedOutput,
467  typename t_Scalar,
468  int t_rows,
469  int t_cols,
470  int t_flags>
472  concatenateMatricesVertically( Eigen::PlainObjectBase<t_DerivedOutput> &result,
473  const std::vector<Eigen::Matrix<t_Scalar, t_rows, t_cols, t_flags> > &matrices)
474  {
475  std::vector< Eigen::Matrix<t_Scalar, t_rows, t_cols, t_flags> > nonempty_matrices = matrices;
476  std::size_t number_of_matrices = nonempty_matrices.size();
477 
478  if (number_of_matrices > 0)
479  {
480  std::ptrdiff_t total_number_of_rows = 0;
481  std::ptrdiff_t number_of_cols = 0;
482 
483  for(std::size_t i = 0; i < number_of_matrices; ++i)
484  {
485  if(!nonempty_matrices[i].size())
486  {
487  nonempty_matrices.erase(nonempty_matrices.begin() + i);
488  --number_of_matrices;
489  }
490  }
491 
492  if(!number_of_matrices)
493  {
494  result.resize(0, 0);
495  return;
496  }
497 
498  number_of_cols = nonempty_matrices[0].cols();
499  for (std::size_t i = 0; i < number_of_matrices; ++i)
500  {
501  EIGENTOOLS_ASSERT(number_of_cols == nonempty_matrices[i].cols(), "Inconsistent size of input matrices.");
502  total_number_of_rows += nonempty_matrices[i].rows();
503  }
504 
505  result.resize(total_number_of_rows, number_of_cols);
506 
507  std::ptrdiff_t row_index = 0;
508  for (std::size_t i = 0; i < number_of_matrices; ++i)
509  {
510  result.block(row_index, 0, nonempty_matrices[i].rows(), number_of_cols) = nonempty_matrices[i];
511  row_index += nonempty_matrices[i].rows();
512  }
513  }
514  else
515  {
516  result.resize(0, 0);
517  }
518  }
519 
520 
521  /**
522  * @brief Concatenate matrices horizontally, [A B C ...]
523  *
524  * @tparam t_DerivedOutput Eigen parameter
525  * @tparam t_DerivedInput1 Eigen parameter
526  * @tparam t_DerivedInput2 Eigen parameter
527  *
528  * @param[out] result result of concatenation
529  * @param[in] matrix1
530  * @param[in] matrix2
531  */
532  template< class t_DerivedOutput,
533  class t_DerivedInput1,
534  class t_DerivedInput2>
537  Eigen::PlainObjectBase<t_DerivedOutput> &result,
538  const Eigen::DenseBase<t_DerivedInput1> &matrix1,
539  const Eigen::DenseBase<t_DerivedInput2> &matrix2)
540  {
541  if (matrix1.rows() == 0)
542  {
543  result = matrix2;
544  }
545  else
546  {
547  if (matrix2.rows() == 0)
548  {
549  result = matrix1;
550  }
551  else
552  {
553  std::ptrdiff_t number_of_rows = matrix1.rows();
554  std::ptrdiff_t number_of_cols = matrix1.cols() + matrix2.cols();
555 
556  EIGENTOOLS_ASSERT(number_of_rows == matrix2.rows(), "Inconsistent size of input matrices.");
557 
558  result.resize(number_of_rows, number_of_cols);
559  result << matrix1, matrix2;
560  }
561  }
562  }
563 
564 
565 
566  /**
567  * @brief Concatenate matrices horizontally, [A B C ...]
568  *
569  * @tparam t_DerivedOutput Eigen parameter
570  * @tparam t_DerivedInput1 Eigen parameter
571  * @tparam t_DerivedInput2 Eigen parameter
572  * @tparam t_DerivedInput3 Eigen parameter
573  *
574  * @param[out] result result of concatenation
575  * @param[in] matrix1
576  * @param[in] matrix2
577  * @param[in] matrix3
578  */
579  template< class t_DerivedOutput,
580  class t_DerivedInput1,
581  class t_DerivedInput2,
582  class t_DerivedInput3>
585  Eigen::PlainObjectBase<t_DerivedOutput> &result,
586  const Eigen::DenseBase<t_DerivedInput1> &matrix1,
587  const Eigen::DenseBase<t_DerivedInput2> &matrix2,
588  const Eigen::DenseBase<t_DerivedInput3> &matrix3)
589  {
590  if (matrix1.rows() == 0)
591  {
592  concatenateMatricesHorizontally(result, matrix2, matrix3);
593  }
594  else
595  {
596  if (matrix2.rows() == 0)
597  {
598  concatenateMatricesHorizontally(result, matrix1, matrix3);
599  }
600  else
601  {
602  if (matrix3.rows() == 0)
603  {
604  concatenateMatricesHorizontally(result, matrix1, matrix2);
605  }
606  else
607  {
608  std::ptrdiff_t number_of_rows = matrix1.rows();
609  std::ptrdiff_t number_of_cols = matrix1.cols() + matrix2.cols() + matrix3.cols();
610 
611  EIGENTOOLS_ASSERT( (number_of_rows == matrix2.rows())
612  && (number_of_rows == matrix3.rows()),
613  "Inconsistent size of input matrices.");
614 
615  result.resize(number_of_rows, number_of_cols);
616  result << matrix1, matrix2, matrix3;
617  }
618  }
619  }
620  }
621 
622 
623 
624  /**
625  * @brief Remove a row with the specified index.
626  *
627  * @tparam t_Derived Eigen parameter
628  *
629  * @param[in,out] matrix matrix
630  * @param[in] row_to_remove index of a row
631  *
632  * Based on
633  * http://stackoverflow.com/questions/13290395/how-to-remove-a-certain-row-or-column-while-using-eigen-library-c
634  */
635  template<class t_Derived>
637  removeRow( Eigen::PlainObjectBase<t_Derived> & matrix,
638  const std::ptrdiff_t row_to_remove)
639  {
640  EIGENTOOLS_ASSERT(row_to_remove <= matrix.rows(), "The index of a removed row is greater than the size of the matrix.");
641 
642  std::ptrdiff_t number_of_rows = matrix.rows()-1;
643  std::ptrdiff_t number_of_cols = matrix.cols();
644 
645  if( row_to_remove < number_of_rows )
646  {
647  matrix.block(row_to_remove, 0, number_of_rows - row_to_remove, number_of_cols) =
648  matrix.block(row_to_remove + 1, 0 , number_of_rows - row_to_remove, number_of_cols);
649  }
650 
651  matrix.conservativeResize(number_of_rows, number_of_cols);
652  }
653 
654 
655 
656  /**
657  * @brief Remove a column with the specified index.
658  *
659  * @tparam t_Derived Eigen parameter
660  *
661  * @param[in,out] matrix matrix
662  * @param[in] column_to_remove index of a column
663  *
664  * Based on
665  * http://stackoverflow.com/questions/13290395/how-to-remove-a-certain-row-or-column-while-using-eigen-library-c
666  */
667  template<class t_Derived>
669  removeColumn( Eigen::PlainObjectBase<t_Derived> & matrix,
670  const std::ptrdiff_t column_to_remove)
671  {
672  EIGENTOOLS_ASSERT(column_to_remove <= matrix.rows(), "The index of a removed column is greater than the size of the matrix.");
673 
674  std::ptrdiff_t number_of_rows = matrix.rows();
675  std::ptrdiff_t number_of_cols = matrix.cols()-1;
676 
677  if( column_to_remove < number_of_cols )
678  {
679  matrix.block(0, column_to_remove, number_of_rows, number_of_cols - column_to_remove) =
680  matrix.block(0, column_to_remove + 1 ,number_of_rows, number_of_cols - column_to_remove);
681  }
682 
683  matrix.conservativeResize(number_of_rows, number_of_cols);
684  }
685 
686 
687  /**
688  * @brief Custom Kronecker product: blocks of the input matrix are treated as
689  * single elements.
690  *
691  * @tparam t_Derived Eigen parameter
692  *
693  * @param[in] input input matrix
694  * @param[in] input_block_rows rows in a block
695  * @param[in] input_block_cols cols in a block
696  * @param[in] identity_size size of the identity matrix used in the product
697  *
698  * @return result of the product
699  */
700  template<class t_Derived>
701  EIGENTOOLS_DYNAMIC_MATRIX(typename Eigen::DenseBase<t_Derived>::Scalar)
703  multiplyBlockKroneckerIdentity (const Eigen::DenseBase<t_Derived> & input,
704  const std::size_t input_block_rows,
705  const std::size_t input_block_cols,
706  const std::size_t identity_size)
707  {
708  EIGENTOOLS_ASSERT(input.rows() % input_block_rows == 0, "Wrong block size.");
709  EIGENTOOLS_ASSERT(input.cols() % input_block_cols == 0, "Wrong block size.");
710 
711  EIGENTOOLS_DYNAMIC_MATRIX(typename Eigen::DenseBase<t_Derived>::Scalar) output;
712 
713  std::size_t num_blocks_vert = input.rows() / input_block_rows;
714  std::size_t num_blocks_hor = input.cols() / input_block_cols;
715 
716  std::size_t output_block_rows = identity_size*input_block_rows;
717  std::size_t output_block_cols = identity_size*input_block_cols;
718 
719  output.setZero(identity_size * input.rows(),
720  identity_size * input.cols());
721 
722  for (std::size_t i = 0; i < num_blocks_vert; ++i)
723  {
724  for (std::size_t j = 0; j < num_blocks_hor; ++j)
725  {
726  for(std::size_t k = 0; k < identity_size; ++k)
727  {
728  output.block( i*output_block_rows + k*input_block_rows,
729  j*output_block_cols + k*input_block_cols,
730  input_block_rows,
731  input_block_cols)
732  = input.block(i*input_block_rows, j*input_block_cols, input_block_rows, input_block_cols);
733  }
734  }
735  }
736 
737  return(output);
738  }
739 
740 
741  // ===========================================================================
742  // Selections
743  // ===========================================================================
744 
745 
746  /**
747  * @brief Select rows from a matrix, in Matlab notation the result is
748  * M(first:step:end, :).
749  *
750  * @tparam t_Derived Eigen parameter
751  *
752  * @param[in] matrix input matrix
753  * @param[in] row_step each 'row_step' is selected from the input matrix
754  * @param[in] first_row starting from 'first_row'
755  *
756  * @return Matrix consisting of selected rows.
757  */
758  template<class t_Derived>
759  inline Eigen::Map< const EIGENTOOLS_DYNAMIC_MATRIX(typename Eigen::PlainObjectBase<t_Derived>::Scalar),
760  Eigen::Unaligned,
761  Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> >
763  selectRows( const Eigen::PlainObjectBase<t_Derived> &matrix,
764  const std::size_t row_step,
765  const std::size_t first_row = 0)
766  {
767  return (EIGENTOOLS_DYNAMIC_MATRIX(typename Eigen::PlainObjectBase<t_Derived>::Scalar)::Map(
768  matrix.data() + first_row,
769  ceil( static_cast<double> (matrix.rows() - first_row)/row_step),
770  matrix.cols(),
771  Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>(matrix.rows(), row_step)));
772  }
773 
774 
775  /**
776  * @brief Selection matrix
777  */
779  {
780  template<class t_Derived>
781  friend Eigen::Map< const EIGENTOOLS_DYNAMIC_MATRIX( typename Eigen::PlainObjectBase<t_Derived>::Scalar ),
782  Eigen::Unaligned,
783  Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> >
784  operator*( const SelectionMatrix &,
785  const Eigen::PlainObjectBase<t_Derived> &);
786 
787 
788  private:
789  std::size_t step_size_;
790  std::size_t first_index_;
791 
792  public:
793  /**
794  * @brief Constructore
795  *
796  * @param[in] step_size step size of selection: 3 -- each third element
797  * @param[in] first_index index of the first element for selection
798  */
799  SelectionMatrix( const std::size_t step_size,
800  const std::size_t first_index)
801  {
802  step_size_ = step_size;
803  first_index_ = first_index;
804  }
805  };
806 
807 
808  /**
809  * @brief Multiply selection matrix by a generic Eigen matrix (select rows)
810  *
811  * @tparam t_Derived Eigen parameter
812  *
813  * @param[in] selector
814  * @param[in] matrix
815  *
816  * @return selected rows
817  */
818  template<class t_Derived>
819  inline Eigen::Map< const EIGENTOOLS_DYNAMIC_MATRIX( typename Eigen::PlainObjectBase<t_Derived>::Scalar ),
820  Eigen::Unaligned,
821  Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> >
823  operator*( const SelectionMatrix & selector,
824  const Eigen::PlainObjectBase<t_Derived> & matrix)
825  {
826  return(selectRows(matrix, selector.step_size_, selector.first_index_));
827  }
828 
829 
830  #ifdef EIGENTOOLS_ENABLE_EIGENTYPE_DETECTION
831  #include <boost/utility/enable_if.hpp>
832  #include <boost/mpl/has_xxx.hpp>
833  #include <boost/mpl/and.hpp>
834 
835  namespace detail
836  {
837  BOOST_MPL_HAS_XXX_TRAIT_DEF(Scalar)
838  BOOST_MPL_HAS_XXX_TRAIT_DEF(Index)
839  BOOST_MPL_HAS_XXX_TRAIT_DEF(StorageKind)
840  }
841 
842 
843  /**
844  * Traits for checking if T is indeed an Eigen Type
845  * @tparam T any Type
846  *
847  * Example Usage:
848  * is_eigen_type<int>::value // evaluates to false
849  * is_eigen_type<int>::type // evaluates to false_type
850  * is_eigen_type<Eigen::Vector2d>::value // evaluates to true
851  * is_eigen_type<Eigen::Vector2d>::type // true_type
852  *
853  * @see https://forum.kde.org/viewtopic.php?f=74&t=121280
854  */
855  template<typename T>
856  struct is_eigen_type : boost::mpl::and_<detail::has_Scalar<T>,
857  detail::has_Index<T>,
858  detail::has_StorageKind<T> >
859  {
860  };
861 
862  #define EIGENTOOLS_EIGENTYPE_ENABLER_TYPE(DataType) \
863  const typename boost::enable_if_c< etools::is_eigen_type<DataType>::value >::type
864  #define EIGENTOOLS_EIGENTYPE_DISABLER_TYPE(DataType) \
865  const typename boost::enable_if_c< !(etools::is_eigen_type<DataType>::value) >::type
866  #endif
867 } // etools
Eigen::Matrix< typename Eigen::MatrixBase< t_DerivedMatrix >::Scalar, Eigen::MatrixBase< t_DerivedMatrix >::RowsAtCompileTime, Eigen::MatrixBase< t_DerivedMatrix >::ColsAtCompileTime > EIGENTOOLS_VISIBILITY_ATTRIBUTE transform(const Eigen::MatrixBase< t_DerivedMatrix > &matrix, const Eigen::MatrixBase< t_DerivedRotation > &rotation, const Eigen::MatrixBase< t_DerivedTranslation > &translation)
Transform the input positions given as a concatenated set of 2d/3d vectors, given M = [v1...
Definition: eigentools.h:341
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x6
Definition: eigentools.h:98
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x6
Definition: eigentools.h:139
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x8
Definition: eigentools.h:124
Eigen::Matrix< etools::DefaultScalar, Eigen::Dynamic, Eigen::Dynamic > DefaultDynamicMatrix
Definition: eigentools.h:42
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x9
Definition: eigentools.h:101
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x5
Definition: eigentools.h:130
std::size_t step_size_
Definition: eigentools.h:789
std::size_t first_index_
Definition: eigentools.h:790
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x6
Definition: eigentools.h:114
void EIGENTOOLS_VISIBILITY_ATTRIBUTE removeColumn(Eigen::PlainObjectBase< t_Derived > &matrix, const std::ptrdiff_t column_to_remove)
Remove a column with the specified index.
Definition: eigentools.h:669
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x5
Definition: eigentools.h:154
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x2
Definition: eigentools.h:103
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x10
Definition: eigentools.h:126
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10
Definition: eigentools.h:84
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x7
Definition: eigentools.h:148
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x3
Definition: eigentools.h:160
void EIGENTOOLS_VISIBILITY_ATTRIBUTE addATA(Eigen::DenseBase< t_DerivedOutput > &result, const Eigen::DenseBase< t_DerivedInput > &A)
result += A^T * A
Definition: eigentools.h:262
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x4
Definition: eigentools.h:161
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x4
Definition: eigentools.h:104
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x5
Definition: eigentools.h:138
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x4
Definition: eigentools.h:153
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x2
Definition: eigentools.h:151
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4
Definition: eigentools.h:78
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x5
Definition: eigentools.h:146
#define EIGENTOOLS_CONSTANT_SIZE_MATRIX(rows, cols)
Definition: eigentools.h:63
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x5
Definition: eigentools.h:113
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9
Definition: eigentools.h:83
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x3
Definition: eigentools.h:152
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5
Definition: eigentools.h:79
#define EIGENTOOLS_VISIBILITY_ATTRIBUTE
Definition: eigentools.h:21
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6
Definition: eigentools.h:80
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x6
Definition: eigentools.h:122
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x10
Definition: eigentools.h:150
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x3
Definition: eigentools.h:120
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x7
Definition: eigentools.h:131
Eigen::Map< const Eigen::Matrix< typename Eigen::PlainObjectBase< t_Derived >::Scalar, Eigen::Dynamic, Eigen::Dynamic >, Eigen::Unaligned, Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > > EIGENTOOLS_VISIBILITY_ATTRIBUTE selectRows(const Eigen::PlainObjectBase< t_Derived > &matrix, const std::size_t row_step, const std::size_t first_row=0)
Select rows from a matrix, in Matlab notation the result is M(first:step:end, :). ...
Definition: eigentools.h:763
double DefaultScalar
Definition: eigentools.h:38
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x10
Definition: eigentools.h:110
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x9
Definition: eigentools.h:125
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x7
Definition: eigentools.h:164
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x3
Definition: eigentools.h:128
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x8
Definition: eigentools.h:108
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x10
Definition: eigentools.h:142
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x6
Definition: eigentools.h:106
SelectionMatrix(const std::size_t step_size, const std::size_t first_index)
Constructore.
Definition: eigentools.h:799
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x9
Definition: eigentools.h:109
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x5
Definition: eigentools.h:89
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x2
Definition: eigentools.h:111
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x8
Definition: eigentools.h:100
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x9
Definition: eigentools.h:117
void EIGENTOOLS_VISIBILITY_ATTRIBUTE convertLLTtoSymmetric(Eigen::PlainObjectBase< t_Derived > &matrix)
Converts left lower triangular matrix to a symmetric matrix.
Definition: eigentools.h:312
void EIGENTOOLS_VISIBILITY_ATTRIBUTE concatenateMatricesHorizontally(Eigen::PlainObjectBase< t_DerivedOutput > &result, const Eigen::DenseBase< t_DerivedInput1 > &matrix1, const Eigen::DenseBase< t_DerivedInput2 > &matrix2)
Concatenate matrices horizontally, [A B C ...].
Definition: eigentools.h:536
void unsetMatrix(Eigen::DenseBase< t_Derived > &matrix)
Unset matrix (initialize to NaN)
Definition: eigentools.h:178
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x5
Definition: eigentools.h:97
void EIGENTOOLS_VISIBILITY_ATTRIBUTE concatenateMatricesVertically(Eigen::PlainObjectBase< t_DerivedOutput > &result, const std::vector< Eigen::Matrix< t_Scalar, t_rows, t_cols, t_flags > > &matrices)
Concatenate matrices vertically, [A;B;C; ...].
Definition: eigentools.h:472
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x8
Definition: eigentools.h:140
#define EIGENTOOLS_DYNAMIC_MATRIX(Scalar)
Definition: eigentools.h:46
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x8
Definition: eigentools.h:92
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x2
Definition: eigentools.h:159
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x4
Definition: eigentools.h:145
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x8
Definition: eigentools.h:116
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x7
Definition: eigentools.h:156
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x4
Definition: eigentools.h:129
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x6
Definition: eigentools.h:163
#define EIGENTOOLS_ASSERT(condition, message)
Definition: eigentools.h:20
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x3
Definition: eigentools.h:112
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x6
Definition: eigentools.h:147
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x10
Definition: eigentools.h:102
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x7
Definition: eigentools.h:115
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x6
Definition: eigentools.h:155
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x10
Definition: eigentools.h:158
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x2
Definition: eigentools.h:119
Selection matrix.
Definition: eigentools.h:778
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x5
Definition: eigentools.h:162
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x9
Definition: eigentools.h:93
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x4
Definition: eigentools.h:96
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x9
Definition: eigentools.h:166
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7
Definition: eigentools.h:81
typedef EIGENTOOLS_CONSTANT_SIZE_VECTOR(2) Vector2
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x4
Definition: eigentools.h:88
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x9
Definition: eigentools.h:141
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x10
Definition: eigentools.h:94
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x2
Definition: eigentools.h:135
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x4
Definition: eigentools.h:137
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x3
Definition: eigentools.h:87
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x8
Definition: eigentools.h:132
This namespace contains various functions operating on Eigen matrices and vectors.
Definition: blockmatrix.h:19
void EIGENTOOLS_VISIBILITY_ATTRIBUTE getATA(Eigen::PlainObjectBase< t_DerivedOutput > &result, const Eigen::DenseBase< t_DerivedInput > &A)
result = A^T * A
Definition: eigentools.h:204
Eigen::Matrix< t_Scalar, Eigen::Dynamic, Eigen::Dynamic > EIGENTOOLS_VISIBILITY_ATTRIBUTE makeBlockDiagonal(const std::vector< Eigen::Matrix< t_Scalar, t_rows, t_cols, t_flags > > &input_matrices)
Create a diagonal matrix consisting of the input matrices.
Definition: eigentools.h:368
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x3
Definition: eigentools.h:95
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x7
Definition: eigentools.h:107
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x7
Definition: eigentools.h:91
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x7
Definition: eigentools.h:123
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x2
Definition: eigentools.h:86
void EIGENTOOLS_VISIBILITY_ATTRIBUTE removeRow(Eigen::PlainObjectBase< t_Derived > &matrix, const std::ptrdiff_t row_to_remove)
Remove a row with the specified index.
Definition: eigentools.h:637
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x9
Definition: eigentools.h:133
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8
Definition: eigentools.h:82
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x2
Definition: eigentools.h:143
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x9
Definition: eigentools.h:149
Eigen::Matrix< typename Eigen::DenseBase< t_Derived >::Scalar, Eigen::Dynamic, Eigen::Dynamic > EIGENTOOLS_VISIBILITY_ATTRIBUTE multiplyBlockKroneckerIdentity(const Eigen::DenseBase< t_Derived > &input, const std::size_t input_block_rows, const std::size_t input_block_cols, const std::size_t identity_size)
Custom Kronecker product: blocks of the input matrix are treated as single elements.
Definition: eigentools.h:703
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3x5
Definition: eigentools.h:105
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x10
Definition: eigentools.h:134
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix5x4
Definition: eigentools.h:121
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix8x3
Definition: eigentools.h:144
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix7x3
Definition: eigentools.h:136
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x2
Definition: eigentools.h:127
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix4x10
Definition: eigentools.h:118
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x7
Definition: eigentools.h:99
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2
Definition: eigentools.h:76
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3
Definition: eigentools.h:77
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x6
Definition: eigentools.h:90
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix10x8
Definition: eigentools.h:165
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix9x8
Definition: eigentools.h:157