humoto
blockmatrix_base.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @copyright 2014-2017 INRIA. Licensed under the Apache License, Version 2.0.
5  (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
6 
7  @brief
8 */
9 
10 #pragma once
11 
12 namespace etools
13 {
14  /**
15  * @brief Type modifier (drop reference &)
16  *
17  * @tparam T input type
18  */
19  template<class T> struct TypeWithoutReference
20  {
21  typedef T Type;
22  };
23 
24  /**
25  * @brief Type modifier (drop reference &)
26  *
27  * @tparam T input type
28  */
29  template<class T> struct TypeWithoutReference<T&>
30  {
31  typedef T Type;
32  };
33 
34 
35  /**
36  * @brief Type modifier (drop reference 'const')
37  *
38  * @tparam T input type
39  */
40  template<class T> struct TypeWithoutConst
41  {
42  typedef T Type;
43  };
44 
45  /**
46  * @brief Type modifier (drop 'const')
47  *
48  * @tparam T input type
49  */
50  template<class T> struct TypeWithoutConst<const T>
51  {
52  typedef T Type;
53  };
54 
55 
56  /**
57  * @brief Type modifier (drop reference and 'const')
58  *
59  * @tparam T input type
60  */
61  template<class T> struct TypeDecayed
62  {
64  };
65 
66 
67 
68  /**
69  * @brief Matrix block size type
70  */
72  {
73  public:
74  enum Type
75  {
76  UNDEFINED = 0,
77  DYNAMIC = -1
78  };
79  };
80 
81 #define EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM ((t_block_rows_num > 0) ? t_block_rows_num : block_rows_num_)
82 #define EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM ((t_block_cols_num > 0) ? t_block_cols_num : block_cols_num_)
83 
84 #define EIGENTOOLS_DEFINE_BLOCK_MATRIX_CONSTRUCTORS(class_name) \
85  class_name (const std::ptrdiff_t block_rows_num = MatrixBlockSizeType::UNDEFINED,\
86  const std::ptrdiff_t block_cols_num = MatrixBlockSizeType::UNDEFINED)\
87  : EIGENTOOLS_PARENT_CLASS_SHORTHAND(block_rows_num, block_cols_num) {};\
88  class_name (const DecayedRawMatrix & matrix,\
89  const std::ptrdiff_t block_rows_num = MatrixBlockSizeType::UNDEFINED,\
90  const std::ptrdiff_t block_cols_num = MatrixBlockSizeType::UNDEFINED)\
91  : EIGENTOOLS_PARENT_CLASS_SHORTHAND(matrix, block_rows_num, block_cols_num) {};\
92  class_name (DecayedRawMatrix & matrix,\
93  const std::ptrdiff_t block_rows_num = MatrixBlockSizeType::UNDEFINED,\
94  const std::ptrdiff_t block_cols_num = MatrixBlockSizeType::UNDEFINED)\
95  : EIGENTOOLS_PARENT_CLASS_SHORTHAND(matrix, block_rows_num, block_cols_num) {};
96 
97  /**
98  * @brief Block matrix basic functions
99  *
100  * @tparam t_MatrixType type of raw matrix
101  * @tparam t_block_rows_num number of rows in one block
102  * @tparam t_block_cols_num number of columns in one block
103  */
104  template< typename t_MatrixType,
105  int t_block_rows_num,
106  int t_block_cols_num>
108  {
109  public:
110  /// Raw matrix without 'const' and '&'
112 
113  /// Scalar type of raw matrix (from Eigen)
114  typedef typename DecayedRawMatrix::Scalar Scalar;
115 
116  /// Shorthand for Eigen block
117  typedef Eigen::Block< EIGENTOOLS_DYNAMIC_MATRIX( Scalar ) > DynamicMatrixBlock;
118 
119  /// Shorthand for Eigen block
120  typedef const Eigen::Block< const EIGENTOOLS_DYNAMIC_MATRIX( Scalar ) > ConstDynamicMatrixBlock;
121 
122 
123  public:
124  /**
125  * @brief Get number of blocks (horizontal/vertical)
126  *
127  * @return number of blocks
128  */
129  std::ptrdiff_t getNumberOfBlocksVertical() const
130  {
131  return(num_blocks_vert_);
132  }
133 
134 
135  /// @copydoc getNumberOfBlocksVertical()
136  std::ptrdiff_t getNumberOfBlocksHorizontal() const
137  {
138  return(num_blocks_hor_);
139  }
140 
141 
142 
143  /**
144  * @brief Get total number of rows / columns
145  *
146  * @return number of rows / columns
147  */
148  std::ptrdiff_t getNumberOfRows() const
149  {
150  return(EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM * num_blocks_vert_);
151  }
152 
153 
154  /// @copydoc getNumberOfRows()
155  std::ptrdiff_t getNumberOfColumns() const
156  {
157  return(EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM * num_blocks_hor_);
158  }
159 
160 
161  /**
162  * @brief Set raw matrix
163  *
164  * @tparam t_Derived Eigen parameter
165  *
166  * @param[in] matrix
167  */
168  template <class t_Derived>
169  void set (const Eigen::DenseBase<t_Derived> &matrix)
170  {
171  matrix_ = matrix;
172  finalize();
173  }
174 
175 
176  /**
177  * @brief Resize matrix
178  *
179  * @param[in] num_blocks_vert
180  * @param[in] num_blocks_hor
181  */
182  void resize( const std::ptrdiff_t num_blocks_vert,
183  const std::ptrdiff_t num_blocks_hor)
184  {
185  matrix_.resize( num_blocks_vert*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
187  finalize();
188  }
189 
190 
191  /**
192  * @brief Resize matrix and initialize it with zeros
193  *
194  * @param[in] num_blocks_vert
195  * @param[in] num_blocks_hor
196  */
197  void setZero( const std::ptrdiff_t num_blocks_vert,
198  const std::ptrdiff_t num_blocks_hor)
199  {
200  matrix_.setZero(num_blocks_vert*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
202  finalize();
203  }
204 
205 
206  /**
207  * @brief Resize square matrix
208  *
209  * @param[in] num_blocks number of diagonal blocks
210  */
211  void resize(const std::ptrdiff_t num_blocks)
212  {
213  resize(num_blocks, num_blocks);
214  }
215 
216 
217  /**
218  * @brief Resize square matrix and set it to zero
219  *
220  * @param[in] num_blocks number of diagonal blocks
221  */
222  void setZero(const std::ptrdiff_t num_blocks)
223  {
224  setZero(num_blocks, num_blocks);
225  }
226 
227 
228 
229  /**
230  * @brief Access column of a matrix
231  *
232  * @param[in] index_col index of the column
233  * @param[in] index_row_first segment of the column starts at this row
234  * @param[in] index_num_rows number of blocks
235  *
236  * @return column or a part of it
237  */
238  DynamicMatrixBlock column( const std::ptrdiff_t index_col,
239  const std::ptrdiff_t index_row_first,
240  const std::ptrdiff_t index_num_rows)
241  {
242  return (DynamicMatrixBlock (matrix_.derived(),
243  index_row_first * EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
245  index_num_rows * EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
247  }
248 
249 
250  /**
251  * @brief Access column of a matrix
252  *
253  * @param[in] index_col index of the column
254  * @param[in] index_row_first segment of the column starts at this row
255  * if #index_row_first is not specified =>
256  * return the whole column
257  *
258  * @return column or a part of it
259  */
260  DynamicMatrixBlock column( const std::ptrdiff_t index_col,
261  const std::ptrdiff_t index_row_first = 0)
262  {
263  return (column(index_col, index_row_first, num_blocks_vert_ - index_row_first));
264  }
265 
266 
267  /// @copydoc column(const std::ptrdiff_t, const std::ptrdiff_t, const std::ptrdiff_t)
268  ConstDynamicMatrixBlock column( const std::ptrdiff_t index_col,
269  const std::ptrdiff_t index_row_first,
270  const std::ptrdiff_t index_num_rows) const
271  {
272  return (ConstDynamicMatrixBlock ( matrix_.derived(),
273  index_row_first * EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
275  index_num_rows * EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
277  }
278 
279 
280  /// @copydoc column(const std::ptrdiff_t, const std::ptrdiff_t)
281  ConstDynamicMatrixBlock column( const std::ptrdiff_t index_col,
282  const std::ptrdiff_t index_row_first = 0) const
283  {
284  return (column(index_col, index_row_first, num_blocks_vert_ - index_row_first));
285  }
286 
287 
288  /**
289  * @brief Access row of a matrix
290  *
291  * @param[in] index_row index of the row
292  * @param[in] index_col_first segment of the row starts at this column
293  * @param[in] index_num_cols number of blocks
294  *
295  * @return row or a part of it
296  */
297  DynamicMatrixBlock row( const std::ptrdiff_t index_row,
298  const std::ptrdiff_t index_col_first,
299  const std::ptrdiff_t index_num_cols)
300  {
301  return (DynamicMatrixBlock( matrix_.derived(),
303  index_col_first * EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM,
305  index_num_cols * EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM));
306  }
307 
308 
309  /**
310  * @brief Access row of a matrix
311  *
312  * @param[in] index_row index of the row
313  * @param[in] index_col_first segment of the row starts at this column
314  * if #index_col_first is not specified =>
315  * return the whole row
316  *
317  * @return row or a part of it
318  */
319  DynamicMatrixBlock row( const std::ptrdiff_t index_row,
320  const std::ptrdiff_t index_col_first = 0)
321  {
322  return (row(index_row, index_col_first, num_blocks_hor_ - index_col_first));
323  }
324 
325 
326  /// @copydoc row(const std::ptrdiff_t, const std::ptrdiff_t, const std::ptrdiff_t)
327  ConstDynamicMatrixBlock row(const std::ptrdiff_t index_row,
328  const std::ptrdiff_t index_col_first,
329  const std::ptrdiff_t index_num_cols) const
330  {
331  return (ConstDynamicMatrixBlock(matrix_.derived(),
333  index_col_first * EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM,
335  index_num_cols * EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM));
336  }
337 
338 
339  /// @copydoc row(const std::ptrdiff_t, const std::ptrdiff_t)
340  ConstDynamicMatrixBlock row(const std::ptrdiff_t index_row,
341  const std::ptrdiff_t index_col_first = 0) const
342  {
343  return (row(index_row, index_col_first, num_blocks_hor_ - index_col_first));
344  }
345 
346 
347 
348  /**
349  * @brief Get raw matrix
350  *
351  * @return matrix
352  */
353  const DecayedRawMatrix & getRaw() const
354  {
355  return (matrix_);
356  }
357 
358 
359  /**
360  * @brief Selects rows from the matrix
361  *
362  * @param[in] row_in_a_block row number in a block
363  *
364  * @return selected rows
365  */
366  DecayedRawMatrix selectRowInBlocksAsMatrix(const std::ptrdiff_t row_in_a_block)
367  {
368  return(selectRows(matrix_, EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, row_in_a_block));
369  }
370 
371 
372  /**
373  * @brief Returns dimension of the matrix block.
374  *
375  * @return number of rows / columns
376  */
377  std::ptrdiff_t getBlockRowsNum() const
378  {
380  }
381 
382 
383  /// @copydoc getBlockRowsNum
384  std::ptrdiff_t getBlockColsNum() const
385  {
387  }
388 
389 
390  /**
391  * @brief Returns dimension of the matrix block.
392  *
393  * @return number of rows / columns
394  */
395  void setBlockSize( const std::ptrdiff_t block_rows_num,
396  const std::ptrdiff_t block_cols_num)
397  {
398  EIGENTOOLS_ASSERT( (MatrixBlockSizeType::DYNAMIC != t_block_rows_num) || (block_rows_num > 0),
399  "Block dimension must be strictly positive.");
400  EIGENTOOLS_ASSERT( (MatrixBlockSizeType::DYNAMIC != t_block_cols_num) || (block_cols_num > 0),
401  "Block dimension must be strictly positive.");
402  initializeBlockSize(block_rows_num, block_cols_num);
403  finalize();
404  }
405 
406 
407  protected:
408  t_MatrixType matrix_;
409 
410  std::ptrdiff_t num_blocks_vert_;
411  std::ptrdiff_t num_blocks_hor_;
412 
413  std::ptrdiff_t block_rows_num_;
414  std::ptrdiff_t block_cols_num_;
415 
416 
417  protected:
418  /**
419  * @brief Protected destructor: prevent destruction of the child
420  * classes through a base pointer.
421  */
423 
424 
425  /**
426  * @brief Default constructor
427  */
428  BlockMatrixAccessBase( const std::ptrdiff_t block_rows_num = MatrixBlockSizeType::UNDEFINED,
429  const std::ptrdiff_t block_cols_num = MatrixBlockSizeType::UNDEFINED)
430  {
431  initializeBlockSize(block_rows_num, block_cols_num);
432  finalize();
433  }
434 
435 
436  /**
437  * @brief Constructor with matrix initialization.
438  *
439  * @param[in] matrix matrix
440  * @param[in] block_rows_num number of rows in a block if t_block_rows_num = MatrixBlockSizeType::DYNAMIC
441  * @param[in] block_cols_num number of cols in a block if t_block_cols_num = MatrixBlockSizeType::DYNAMIC
442  */
443  BlockMatrixAccessBase( const DecayedRawMatrix & matrix,
444  const std::ptrdiff_t block_rows_num = MatrixBlockSizeType::UNDEFINED,
445  const std::ptrdiff_t block_cols_num = MatrixBlockSizeType::UNDEFINED)
446  : matrix_(matrix)
447  {
448  initializeBlockSize(block_rows_num, block_cols_num);
449  finalize();
450  }
451 
452 
453  /**
454  * @brief Constructor with matrix initialization.
455  *
456  * @param[in] matrix matrix
457  * @param[in] block_rows_num number of rows in a block if t_block_rows_num = MatrixBlockSizeType::DYNAMIC
458  * @param[in] block_cols_num number of cols in a block if t_block_cols_num = MatrixBlockSizeType::DYNAMIC
459  */
460  BlockMatrixAccessBase( DecayedRawMatrix & matrix,
461  const std::ptrdiff_t block_rows_num = MatrixBlockSizeType::UNDEFINED,
462  const std::ptrdiff_t block_cols_num = MatrixBlockSizeType::UNDEFINED)
463  : matrix_(matrix)
464  {
465  initializeBlockSize(block_rows_num, block_cols_num);
466  finalize();
467  }
468 
469 
470 
471  /**
472  * @brief Compute humber of blocks in matrix and check size consistency.
473  */
474  void initializeBlockSize( const std::ptrdiff_t block_rows_num,
475  const std::ptrdiff_t block_cols_num)
476  {
477  if (MatrixBlockSizeType::DYNAMIC == t_block_rows_num)
478  {
479  block_rows_num_ = block_rows_num;
480  }
481  else
482  {
484  "Matrix block is static, but nonzero dimension size is passed to the constructor.");
485  block_rows_num_ = t_block_rows_num;
486  }
487 
488  if (MatrixBlockSizeType::DYNAMIC == t_block_cols_num)
489  {
490  block_cols_num_ = block_cols_num;
491  }
492  else
493  {
495  "Matrix block is static, but nonzero dimension size is passed to the constructor.");
496  block_cols_num_ = t_block_cols_num;
497  }
498  }
499 
500 
501  /**
502  * @brief Compute humber of blocks in matrix and check size consistency.
503  */
504  void finalize()
505  {
506  if ( (t_block_rows_num != MatrixBlockSizeType::DYNAMIC)
507  || (block_rows_num_ != MatrixBlockSizeType::UNDEFINED))
508  {
510  "Wrong number of rows.");
511 
513  "Vertical dimension of the matrix is not a multiple of the corresponding block dimension.");
514 
515  num_blocks_vert_ = matrix_.rows() / EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM;
516  }
517 
518  if ( (t_block_cols_num != MatrixBlockSizeType::DYNAMIC)
519  || (block_cols_num_ != MatrixBlockSizeType::UNDEFINED))
520  {
522  "Wrong number of cols.");
523 
525  "Horizontal dimension of the matrix is not a multiple of the corresponding block dimension.");
526 
527  num_blocks_hor_ = matrix_.cols() / EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM;
528  }
529  }
530  };
531 
532 
533 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase<t_MatrixType, t_block_rows_num, t_block_cols_num>
534  /**
535  * @brief Extra layer for handling of specific sizes of blocks using partial
536  * template specialization
537  *
538  * @tparam t_MatrixType type of raw matrix
539  * @tparam t_block_rows_num number of rows in one block
540  * @tparam t_block_cols_num number of columns in one block
541  */
542  template< typename t_MatrixType,
543  int t_block_rows_num,
544  int t_block_cols_num>
546  {
547  public:
548  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DecayedRawMatrix DecayedRawMatrix;
549  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::Scalar Scalar;
550 
551 
552  /// Shorthand for Eigen block
553  typedef Eigen::Block< EIGENTOOLS_DYNAMIC_MATRIX( Scalar ),
554  t_block_rows_num,
555  t_block_cols_num> StaticMatrixBlock;
556 
557  /// Shorthand for Eigen block
558  typedef const Eigen::Block< const EIGENTOOLS_DYNAMIC_MATRIX( Scalar ),
559  t_block_rows_num,
560  t_block_cols_num> ConstStaticMatrixBlock;
561 
562  /**
563  * @brief Block access operator
564  *
565  * @param[in] index_row
566  * @param[in] index_col
567  *
568  * @return matrix block
569  */
570  StaticMatrixBlock operator()( const std::ptrdiff_t index_row,
571  const std::ptrdiff_t index_col)
572  {
573  return (StaticMatrixBlock( matrix_.derived(),
574  index_row * t_block_rows_num,
575  index_col * t_block_cols_num));
576  }
577 
578 
579  /// @copydoc operator()(const std::ptrdiff_t, const std::ptrdiff_t)
580  ConstStaticMatrixBlock operator()( const std::ptrdiff_t index_row,
581  const std::ptrdiff_t index_col) const
582  {
583  return (ConstStaticMatrixBlock( matrix_.derived(),
584  index_row * t_block_rows_num,
585  index_col * t_block_cols_num));
586  }
587 
588 
589  /**
590  * @brief Block access operator for diagonal blocks
591  *
592  * @param[in] index row and column index
593  *
594  * @return matrix block
595  */
596  StaticMatrixBlock operator()(const std::ptrdiff_t index)
597  {
598  return ((*this)(index,index));
599  }
600 
601 
602  /// @copydoc operator()(const std::ptrdiff_t)
603  ConstStaticMatrixBlock operator()(const std::ptrdiff_t index) const
604  {
605  return ((*this)(index,index));
606  }
607 
608 
609  protected:
610  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
611 
612 
613  /**
614  * @brief Protected destructor: prevent destruction of the child
615  * classes through a base pointer.
616  */
618 
620  };
621 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
622 
623 
624 #define EIGENTOOLS_CODE_GENERATOR\
625  public:\
626  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DecayedRawMatrix DecayedRawMatrix;\
627  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DynamicMatrixBlock DynamicMatrixBlock;\
628  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::ConstDynamicMatrixBlock ConstDynamicMatrixBlock;\
629  DynamicMatrixBlock operator()( const std::ptrdiff_t index_row,\
630  const std::ptrdiff_t index_col)\
631  {\
632  return (DynamicMatrixBlock( matrix_.derived(),\
633  index_row * block_rows_num_,\
634  index_col * block_cols_num_,\
635  block_rows_num_,\
636  block_cols_num_));\
637  }\
638  ConstDynamicMatrixBlock operator()( const std::ptrdiff_t index_row,\
639  const std::ptrdiff_t index_col) const\
640  {\
641  return (ConstDynamicMatrixBlock(matrix_.derived(),\
642  index_row * block_rows_num_,\
643  index_col * block_cols_num_,\
644  block_rows_num_,\
645  block_cols_num_));\
646  }\
647  DynamicMatrixBlock\
648  operator()(const std::ptrdiff_t index)\
649  {\
650  return ((*this)(index,index));\
651  }\
652  ConstDynamicMatrixBlock\
653  operator()(const std::ptrdiff_t index) const\
654  {\
655  return ((*this)(index,index));\
656  }\
657  protected:\
658  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;\
659  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;\
660  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;\
661  ~BlockMatrixSizeSpecificBase() {}\
662  EIGENTOOLS_DEFINE_BLOCK_MATRIX_CONSTRUCTORS(BlockMatrixSizeSpecificBase)\
663 
664 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase< t_MatrixType, \
665  MatrixBlockSizeType::DYNAMIC, \
666  MatrixBlockSizeType::DYNAMIC>
667 
668  /**
669  * @brief Extra layer for handling of specific sizes of blocks using partial
670  * template specialization
671  *
672  * @tparam t_MatrixType type of raw matrix
673  * @tparam t_block_rows_num number of rows in one block
674  * @tparam t_block_cols_num number of columns in one block
675  */
676  template<typename t_MatrixType>
678  MatrixBlockSizeType::DYNAMIC,
681  {
683  };
684 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
685 
686 
687 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase< t_MatrixType, \
688  t_block_rows_num, \
689  MatrixBlockSizeType::DYNAMIC>
690  /**
691  * @brief Extra layer for handling of specific sizes of blocks using partial
692  * template specialization
693  *
694  * @tparam t_MatrixType type of raw matrix
695  * @tparam t_block_rows_num number of rows in one block
696  * @tparam t_block_cols_num number of columns in one block
697  */
698  template<typename t_MatrixType, int t_block_rows_num>
700  t_block_rows_num,
701  MatrixBlockSizeType::DYNAMIC>
703  {
705  };
706 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
707 
708 
709 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase< t_MatrixType, \
710  MatrixBlockSizeType::DYNAMIC, \
711  t_block_cols_num>
712  /**
713  * @brief Extra layer for handling of specific sizes of blocks using partial
714  * template specialization
715  *
716  * @tparam t_MatrixType type of raw matrix
717  * @tparam t_block_rows_num number of rows in one block
718  * @tparam t_block_cols_num number of columns in one block
719  */
720  template<typename t_MatrixType, int t_block_cols_num>
722  MatrixBlockSizeType::DYNAMIC,
723  t_block_cols_num>
725  {
727  };
728 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
729 #undef EIGENTOOLS_CODE_GENERATOR
730 
731 
732 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase<t_MatrixType, 1, 1>
733  /**
734  * @brief Extra layer for handling of specific sizes of blocks using partial
735  * template specialization
736  *
737  * Access matrix using 1x1 blocks. The reason for this is that Eigen does not
738  * support Block's of such size.
739  *
740  * @tparam t_MatrixType type of raw matrix, e.g. Eigen::MatrixXd or a reference to it
741  */
742  template<typename t_MatrixType>
744  {
745  public:
746  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DecayedRawMatrix DecayedRawMatrix;
747  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::Scalar Scalar;
748 
749 
750  /**
751  * @brief Block access operator
752  *
753  * @param[in] index_row
754  * @param[in] index_col
755  *
756  * @return matrix block
757  */
758  Scalar & operator()(const std::ptrdiff_t index_row,
759  const std::ptrdiff_t index_col)
760  {
761  return (matrix_(index_row, index_col));
762  }
763 
764 
765  /// @copydoc operator()(const std::ptrdiff_t, const std::ptrdiff_t)
766  Scalar operator()( const std::ptrdiff_t index_row,
767  const std::ptrdiff_t index_col) const
768  {
769  return (matrix_(index_row, index_col));
770  }
771 
772 
773  /**
774  * @brief Block access operator for diagonal blocks
775  *
776  * @param[in] index row and column index
777  *
778  * @return matrix block
779  */
780  Scalar & operator()(const std::ptrdiff_t index)
781  {
782  return (matrix_(index, index));
783  }
784 
785 
786  /// @copydoc operator()(const std::ptrdiff_t)
787  Scalar operator()( const std::ptrdiff_t index) const
788  {
789  return (matrix_(index, index));
790  }
791 
792 
793  protected:
794  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
795 
796 
797  /**
798  * @brief Protected destructor: prevent destruction of the child
799  * classes through a base pointer.
800  */
802 
803 
805  };
806 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
807 
808 
809  // ===========================================================================
810  // ===========================================================================
811  // ===========================================================================
812 
813 
814  /**
815  * @brief Sparsity type of a matrix
816  */
818  {
819  public:
820  enum Type
821  {
822  UNDEFINED = 0,
823  NONE = 1,
824  DIAGONAL = 2,
825  LEFT_LOWER_TRIANGULAR = 3
826  };
827  };
828 
829 
830  // ===========================================================================
831  // ===========================================================================
832  // ===========================================================================
833 
834 
835 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, t_block_rows_num, t_block_cols_num>
836  /**
837  * @brief Base class of a block matrix
838  *
839  * @tparam t_MatrixType type of raw matrix
840  * @tparam t_block_rows_num number of rows in one block
841  * @tparam t_block_cols_num number of columns in one block
842  * @tparam t_sparsity_type sparsity type
843  */
844  template< typename t_MatrixType,
845  int t_block_rows_num,
846  int t_block_cols_num,
847  MatrixSparsityType::Type t_sparsity_type>
849  {
850  protected:
851  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
852 
853 
854  public:
855  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DecayedRawMatrix DecayedRawMatrix;
856 
858 
859 
860  /**
861  * @brief this * Matrix
862  *
863  * @tparam t_DerivedOutput Eigen parameter
864  * @tparam t_DerivedInput Eigen parameter
865  *
866  * @param[out] result result of multiplication
867  * @param[in] matrix
868  */
869  template<class t_DerivedOutput, class t_DerivedInput>
870  void multiplyRight (Eigen::PlainObjectBase<t_DerivedOutput> & result,
871  const Eigen::MatrixBase<t_DerivedInput> & matrix) const
872  {
873  result.noalias() = matrix_*matrix;
874  }
875  };
876 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
877 
878 
879 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, t_block_rows_num, t_block_cols_num>
880  /**
881  * @brief Base class of a block matrix
882  *
883  * @tparam t_MatrixType type of raw matrix
884  * @tparam t_block_rows_num number of rows in one block
885  * @tparam t_block_cols_num number of columns in one block
886  * @tparam t_sparsity_type sparsity type
887  */
888  template< typename t_MatrixType,
889  int t_block_rows_num,
890  int t_block_cols_num >
892  t_block_rows_num,
893  t_block_cols_num,
895  {
896  public:
897  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DecayedRawMatrix DecayedRawMatrix;
898 
899  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator();
900  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::getNumberOfRows;
901  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::getNumberOfColumns;
902  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::column;
903  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::row;
904 
905 
906 
907  /**
908  * @brief this * Matrix
909  *
910  * @tparam t_DerivedOutput Eigen parameter
911  * @tparam t_DerivedInput Eigen parameter
912  *
913  * @param[out] result result of multiplication
914  * @param[in] matrix
915  */
916  template<class t_DerivedOutput, class t_DerivedInput>
917  void multiplyRight (Eigen::PlainObjectBase<t_DerivedOutput> & result,
918  const Eigen::MatrixBase<t_DerivedInput> & matrix) const
919  {
920  EIGENTOOLS_ASSERT(matrix.rows() == getNumberOfColumns(), "Size mismatch.");
921 
922  std::ptrdiff_t num_cols = matrix.cols();
923 
924  result.resize(getNumberOfRows(), num_cols);
925 
926  for(std::ptrdiff_t i = 0; i < num_blocks_hor_; ++i)
927  {
928  result.block(i*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, 0, EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, num_cols).noalias() =
929  (*this)(i)
930  *
931  matrix.block(i*EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM, 0, EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM, num_cols);
932  }
933  }
934 
935 
936  /**
937  * @brief Matrix * BlockMatrix<DIAGONAL>
938  *
939  * @tparam t_DerivedInput Eigen parameter
940  * @tparam t_DerivedOutput Eigen parameter
941  *
942  * @param[out] result result of multiplication
943  * @param[in] matrix
944  */
945  template< class t_DerivedInput,
946  class t_DerivedOutput>
947  void multiplyLeft( Eigen::PlainObjectBase<t_DerivedOutput> &result,
948  const Eigen::DenseBase<t_DerivedInput> &matrix) const
949  {
950  EIGENTOOLS_ASSERT(matrix.cols() == getNumberOfRows(), "Size mismatch.");
951 
952  std::ptrdiff_t num_rows = matrix.rows();
953 
954  result.resize(num_rows, getNumberOfColumns());
955 
956  for(std::ptrdiff_t i = 0; i < num_blocks_vert_; ++i)
957  {
958  result.block(0, i*EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM, num_rows, EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM).noalias() =
959  matrix.block(0, i*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, num_rows, EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM)
960  *
961  (*this)(i);
962  }
963  }
964 
965 
966  /**
967  * @brief this * BlockMatrix
968  *
969  * @tparam t_DerivedOutput Eigen parameter
970  * @tparam t_DerivedInput Eigen parameter
971  *
972  * @param[out] result result of multiplication
973  * @param[in] rhs right hand side
974  */
975  template< typename t_MatrixType_in,
976  int t_block_rows_num_in,
977  int t_block_cols_num_in,
978  MatrixSparsityType::Type t_sparsity_type_in,
979  class t_DerivedOutput>
980  void multiplyRight (Eigen::PlainObjectBase<t_DerivedOutput> & result,
981  const BlockMatrixBase< t_MatrixType_in,
982  t_block_rows_num_in,
983  t_block_cols_num_in,
984  t_sparsity_type_in> & rhs) const
985  {
986  multiplyRight(result, rhs.getRaw());
987  }
988 
989 
990  protected:
991  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
992  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_vert_;
993  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_hor_;
994  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;
995  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;
996 
997 
998  /**
999  * @brief Protected destructor: prevent destruction of the child
1000  * classes through a base pointer.
1001  */
1003 
1004 
1006  };
1007 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
1008 
1009 
1010 
1011 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, t_block_rows_num, t_block_cols_num>
1012  /**
1013  * @brief Base class of a block matrix
1014  *
1015  * @tparam t_MatrixType type of raw matrix
1016  * @tparam t_block_rows_num number of rows in one block
1017  * @tparam t_block_cols_num number of columns in one block
1018  * @tparam t_sparsity_type sparsity type
1019  */
1020  template< typename t_MatrixType,
1021  int t_block_rows_num,
1022  int t_block_cols_num >
1024  t_block_rows_num,
1025  t_block_cols_num,
1026  MatrixSparsityType::LEFT_LOWER_TRIANGULAR> : public EIGENTOOLS_PARENT_CLASS_SHORTHAND
1027  {
1028  public:
1029  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DecayedRawMatrix DecayedRawMatrix;
1030 
1031  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator();
1032  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::getNumberOfRows;
1033  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::getNumberOfColumns;
1034  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::column;
1035  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::row;
1036 
1037 
1038 
1039  /**
1040  * @brief this * Matrix
1041  *
1042  * @tparam t_DerivedOutput Eigen parameter
1043  * @tparam t_DerivedInput Eigen parameter
1044  *
1045  * @param[out] result result of multiplication
1046  * @param[in] matrix
1047  */
1048  template<class t_DerivedOutput, class t_DerivedInput>
1049  void multiplyRight (Eigen::PlainObjectBase<t_DerivedOutput> & result,
1050  const Eigen::MatrixBase<t_DerivedInput> & matrix) const
1051  {
1052  // slower
1053  /*
1054  EIGENTOOLS_ASSERT(static_cast<std::ptrdiff_t>(eigen_matrix.rows()) == getNumberOfColumns(), "Size mismatch.");
1055 
1056  std::ptrdiff_t num_cols = eigen_matrix.cols();
1057 
1058  result.resize(getNumberOfRows(), num_cols);
1059 
1060 
1061  for(std::ptrdiff_t i = 0; i < num_blocks_hor_; ++i)
1062  {
1063  result.block(i*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, 0, EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, num_cols).noalias() =
1064  row(i, 0, i+1)
1065  *
1066  eigen_matrix.block(0, 0, EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM*(i+1), num_cols);
1067  }
1068  */
1069  result.noalias() = matrix_*matrix;
1070  }
1071 
1072 
1073  protected:
1074  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
1075  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_vert_;
1076  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_hor_;
1077  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;
1078  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;
1079 
1080 
1081  /**
1082  * @brief Protected destructor: prevent destruction of the child
1083  * classes through a base pointer.
1084  */
1086 
1087 
1089  };
1090 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
1091 
1092 
1093 
1094 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, 1, 1>
1095  /**
1096  * @brief Base class of a block matrix
1097  *
1098  * @tparam t_MatrixType type of raw matrix
1099  * @tparam t_block_rows_num number of rows in one block
1100  * @tparam t_block_cols_num number of columns in one block
1101  * @tparam t_sparsity_type sparsity type
1102  */
1103  template< typename t_MatrixType >
1105  1,
1106  1,
1107  MatrixSparsityType::LEFT_LOWER_TRIANGULAR> : public EIGENTOOLS_PARENT_CLASS_SHORTHAND
1108  {
1109  public:
1110  typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::DecayedRawMatrix DecayedRawMatrix;
1111 
1112  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator();
1113  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::getNumberOfRows;
1114  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::getNumberOfColumns;
1115  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::column;
1116  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::row;
1117 
1118 
1119 
1120  /**
1121  * @brief this * Matrix
1122  *
1123  * @tparam t_DerivedOutput Eigen parameter
1124  * @tparam t_DerivedInput Eigen parameter
1125  *
1126  * @param[out] result result of multiplication
1127  * @param[in] matrix
1128  */
1129  template<class t_DerivedOutput, class t_DerivedInput>
1130  void multiplyRight (Eigen::PlainObjectBase<t_DerivedOutput> & result,
1131  const Eigen::MatrixBase<t_DerivedInput> & matrix) const
1132  {
1133  EIGENTOOLS_ASSERT(matrix.rows() == getNumberOfColumns(), "Size mismatch.");
1134 
1135  // https://eigen.tuxfamily.org/dox-devel/TopicTemplateKeyword.html
1136  result.noalias() = matrix_.template triangularView<Eigen::Lower>() * matrix;
1137  }
1138 
1139 
1140  protected:
1141  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
1142  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_vert_;
1143  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_hor_;
1144  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;
1145  using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;
1146 
1147 
1148  /**
1149  * @brief Protected destructor: prevent destruction of the child
1150  * classes through a base pointer.
1151  */
1153 
1154 
1156  };
1157 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND
1158 
1159 
1160 
1161  // ===========================================================================
1162  // ===========================================================================
1163  // ===========================================================================
1164 
1165 
1166  /**
1167  * @addtogroup BlockMatrixOperators
1168  * @{
1169  */
1170 
1171  /**
1172  * @brief 'BlockMatrixBase * Eigen::Matrix' operator
1173  *
1174  * @tparam t_MatrixType type of raw matrix
1175  * @tparam t_block_rows_num number of rows in one block
1176  * @tparam t_block_cols_num number of columns in one block
1177  * @tparam t_sparsity_type sparsity type
1178  * @tparam t_Derived Eigen parameter
1179  *
1180  * @param[in] bm block matrix
1181  * @param[in] matrix matrix
1182  *
1183  * @return result of multiplication
1184  */
1185  template< typename t_MatrixType,
1186  int t_block_rows_num,
1187  int t_block_cols_num,
1188  MatrixSparsityType::Type t_sparsity_type,
1189  class t_Derived>
1192  operator* ( const BlockMatrixBase< t_MatrixType,
1193  t_block_rows_num,
1194  t_block_cols_num,
1195  t_sparsity_type> & bm,
1196  const Eigen::MatrixBase<t_Derived> & matrix)
1197  {
1199  bm.multiplyRight(result, matrix);
1200  return (result);
1201  }
1202 
1203 
1204 
1205  /**
1206  * @brief Computes 'Eigen::Matrix * BlockMatrixBase'
1207  *
1208  * @tparam t_Derived Eigen parameter
1209  * @tparam t_MatrixType type of raw matrix
1210  * @tparam t_block_rows_num number of rows in one block
1211  * @tparam t_block_cols_num number of columns in one block
1212  * @tparam t_sparsity_type sparsity type
1213  * @tparam t_rows_in number of rows in the matrix
1214  * @tparam t_cols_in number of columns in the matrix
1215  *
1216  * @param[in] eigen_matrix matrix
1217  * @param[in] bm block matrix
1218  *
1219  * @return result of multiplication
1220  */
1221  template< class t_Derived,
1222  typename t_MatrixType,
1223  int t_block_rows_num,
1224  int t_block_cols_num,
1225  MatrixSparsityType::Type t_sparsity_type,
1226  int t_rows_in,
1227  int t_cols_in>
1228  EIGENTOOLS_DYNAMIC_MATRIX( typename Eigen::DenseBase<t_Derived>::Scalar )
1230  operator* ( const Eigen::MatrixBase<t_Derived> & eigen_matrix,
1231  const BlockMatrixBase< t_MatrixType,
1232  t_block_rows_num,
1233  t_block_cols_num,
1234  t_sparsity_type> & bm)
1235  {
1236  EIGENTOOLS_DYNAMIC_MATRIX( typename Eigen::DenseBase<t_Derived>::Scalar ) result;
1237  bm.multiplyLeft(result, eigen_matrix);
1238  return (result);
1239  }
1240 
1241 
1242 
1243  /**
1244  * @brief BlockMatrix * BlockMatrix (left * right)
1245  * @note 't_right_block_rows_num = t_left_block_cols_num' and therefore is
1246  * omitted
1247  *
1248  * @tparam t_left_MatrixType type of raw matrix
1249  * @tparam t_left_block_rows_num number of rows in one block
1250  * @tparam t_left_block_cols_num number of columns in one block
1251  * @tparam t_left_sparsity_type sparsity type
1252  * @tparam t_right_MatrixType type of raw matrix
1253  * @tparam t_right_block_cols_num number of columns in one block
1254  * @tparam t_right_sparsity_type sparsity type
1255  *
1256  * @param[in] left block matrix
1257  * @param[in] right block matrix
1258  *
1259  * @return result of multiplication
1260  */
1261  template< typename t_left_MatrixType,
1262  int t_left_block_rows_num,
1263  int t_left_block_cols_num,
1264  MatrixSparsityType::Type t_left_sparsity_type,
1265  typename t_right_MatrixType,
1266  int t_right_block_cols_num>
1269  operator* ( const BlockMatrixBase< t_left_MatrixType,
1270  t_left_block_rows_num,
1271  t_left_block_cols_num,
1272  t_left_sparsity_type> & left,
1273  const BlockMatrixBase< t_right_MatrixType,
1274  t_left_block_cols_num,
1275  t_right_block_cols_num,
1277  {
1279  right.multiplyLeft(result, left.getRaw());
1280  return (result);
1281  }
1282 
1283 
1284  /**
1285  * @brief BlockMatrix * BlockMatrix (left * right)
1286  * @note 't_right_block_rows_num = t_left_block_cols_num' and therefore is
1287  * omitted
1288  *
1289  * @tparam t_left_MatrixType type of raw matrix
1290  * @tparam t_left_block_rows_num number of rows in one block
1291  * @tparam t_left_block_cols_num number of columns in one block
1292  * @tparam t_left_sparsity_type sparsity type
1293  * @tparam t_right_MatrixType type of raw matrix
1294  * @tparam t_right_block_cols_num number of columns in one block
1295  * @tparam t_right_sparsity_type sparsity type
1296  *
1297  * @param[in] left block matrix
1298  * @param[in] right block matrix
1299  *
1300  * @return result of multiplication
1301  */
1302  template< typename t_left_MatrixType,
1303  int t_left_block_rows_num,
1304  int t_left_block_cols_num,
1305  MatrixSparsityType::Type t_left_sparsity_type,
1306  typename t_right_MatrixType,
1307  int t_right_block_cols_num,
1308  MatrixSparsityType::Type t_right_sparsity_type>
1311  operator* ( const BlockMatrixBase< t_left_MatrixType,
1312  t_left_block_rows_num,
1313  t_left_block_cols_num,
1314  t_left_sparsity_type> & left,
1315  const BlockMatrixBase< t_right_MatrixType,
1316  t_left_block_cols_num,
1317  t_right_block_cols_num,
1318  t_right_sparsity_type> & right)
1319  {
1321  left.multiplyRight(result, right);
1322  return (result);
1323  }
1324 
1325  // BlockMatrixOperators
1326  /**
1327  * @}
1328  */
1329 } // etools
void finalize()
Compute humber of blocks in matrix and check size consistency.
~BlockMatrixSizeSpecificBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
~BlockMatrixBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
std::ptrdiff_t getBlockRowsNum() const
Returns dimension of the matrix block.
StaticMatrixBlock operator()(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col)
Block access operator.
~BlockMatrixBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
ConstDynamicMatrixBlock row(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col_first, const std::ptrdiff_t index_num_cols) const
Access row of a matrix.
TypeDecayed< t_MatrixType >::Type DecayedRawMatrix
Raw matrix without &#39;const&#39; and &#39;&&#39;.
Type modifier (drop reference and &#39;const&#39;)
#define EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM
void multiplyRight(Eigen::PlainObjectBase< t_DerivedOutput > &result, const Eigen::MatrixBase< t_DerivedInput > &matrix) const
this * Matrix
Extra layer for handling of specific sizes of blocks using partial template specialization.
void multiplyLeft(Eigen::PlainObjectBase< t_DerivedOutput > &result, const Eigen::DenseBase< t_DerivedInput > &matrix) const
Matrix * BlockMatrix<DIAGONAL>
Block matrix basic functions.
void setBlockSize(const std::ptrdiff_t block_rows_num, const std::ptrdiff_t block_cols_num)
Returns dimension of the matrix block.
void resize(const std::ptrdiff_t num_blocks)
Resize square matrix.
EIGENTOOLS_VISIBILITY_ATTRIBUTE operator*(const BlockMatrixBase< t_MatrixType, t_block_rows_num, t_block_cols_num, t_sparsity_type > &bm, const Eigen::MatrixBase< t_Derived > &matrix)
&#39;BlockMatrixBase * Eigen::Matrix&#39; operator
ConstDynamicMatrixBlock column(const std::ptrdiff_t index_col, const std::ptrdiff_t index_row_first, const std::ptrdiff_t index_num_rows) const
Access column of a matrix.
BlockMatrixAccessBase(const DecayedRawMatrix &matrix, const std::ptrdiff_t block_rows_num=MatrixBlockSizeType::UNDEFINED, const std::ptrdiff_t block_cols_num=MatrixBlockSizeType::UNDEFINED)
Constructor with matrix initialization.
BlockMatrixAccessBase(DecayedRawMatrix &matrix, const std::ptrdiff_t block_rows_num=MatrixBlockSizeType::UNDEFINED, const std::ptrdiff_t block_cols_num=MatrixBlockSizeType::UNDEFINED)
Constructor with matrix initialization.
Scalar operator()(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col) const
Block access operator.
const Eigen::Block< const EIGENTOOLS_DYNAMIC_MATRIX(Scalar), t_block_rows_num, t_block_cols_num > ConstStaticMatrixBlock
Shorthand for Eigen block.
#define EIGENTOOLS_VISIBILITY_ATTRIBUTE
Definition: eigentools.h:21
BlockMatrixAccessBase< t_MatrixType, t_block_rows_num, t_block_cols_num >::DecayedRawMatrix DecayedRawMatrix
void multiplyRight(Eigen::PlainObjectBase< t_DerivedOutput > &result, const Eigen::MatrixBase< t_DerivedInput > &matrix) const
this * Matrix
void setZero(const std::ptrdiff_t num_blocks_vert, const std::ptrdiff_t num_blocks_hor)
Resize matrix and initialize it with zeros.
ConstDynamicMatrixBlock row(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col_first=0) const
Access row of a matrix.
#define EIGENTOOLS_DEFINE_BLOCK_MATRIX_CONSTRUCTORS(class_name)
DynamicMatrixBlock row(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col_first=0)
Access row of a matrix.
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
Base class of a block matrix.
void resize(const std::ptrdiff_t num_blocks_vert, const std::ptrdiff_t num_blocks_hor)
Resize matrix.
Matrix block size type.
ConstStaticMatrixBlock operator()(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col) const
Block access operator.
ConstStaticMatrixBlock operator()(const std::ptrdiff_t index) const
Block access operator for diagonal blocks.
~BlockMatrixSizeSpecificBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
Scalar & operator()(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col)
Block access operator.
BlockMatrixAccessBase< t_MatrixType, 1, 1 >::Scalar Scalar
void setZero(const std::ptrdiff_t num_blocks)
Resize square matrix and set it to zero.
#define EIGENTOOLS_DYNAMIC_MATRIX(Scalar)
Definition: eigentools.h:46
const DecayedRawMatrix & getRaw() const
Get raw matrix.
std::ptrdiff_t getNumberOfRows() const
Get total number of rows / columns.
BlockMatrixAccessBase(const std::ptrdiff_t block_rows_num=MatrixBlockSizeType::UNDEFINED, const std::ptrdiff_t block_cols_num=MatrixBlockSizeType::UNDEFINED)
Default constructor.
Scalar operator()(const std::ptrdiff_t index) const
Block access operator for diagonal blocks.
#define EIGENTOOLS_ASSERT(condition, message)
Definition: eigentools.h:20
DecayedRawMatrix selectRowInBlocksAsMatrix(const std::ptrdiff_t row_in_a_block)
Selects rows from the matrix.
void initializeBlockSize(const std::ptrdiff_t block_rows_num, const std::ptrdiff_t block_cols_num)
Compute humber of blocks in matrix and check size consistency.
DynamicMatrixBlock column(const std::ptrdiff_t index_col, const std::ptrdiff_t index_row_first, const std::ptrdiff_t index_num_rows)
Access column of a matrix.
BlockMatrixSizeSpecificBase< t_MatrixType, t_block_rows_num, t_block_cols_num >::DecayedRawMatrix DecayedRawMatrix
BlockMatrixSizeSpecificBase< t_MatrixType, t_block_rows_num, t_block_cols_num >::DecayedRawMatrix DecayedRawMatrix
std::ptrdiff_t getNumberOfColumns() const
Get total number of rows / columns.
const Eigen::Block< const EIGENTOOLS_DYNAMIC_MATRIX(Scalar) > ConstDynamicMatrixBlock
Shorthand for Eigen block.
#define EIGENTOOLS_CODE_GENERATOR
Type modifier (drop reference &)
std::ptrdiff_t getNumberOfBlocksHorizontal() const
Get number of blocks (horizontal/vertical)
void multiplyRight(Eigen::PlainObjectBase< t_DerivedOutput > &result, const Eigen::MatrixBase< t_DerivedInput > &matrix) const
this * Matrix
ConstDynamicMatrixBlock column(const std::ptrdiff_t index_col, const std::ptrdiff_t index_row_first=0) const
Access column of a matrix.
#define EIGENTOOLS_PARENT_CLASS_SHORTHAND
DynamicMatrixBlock row(const std::ptrdiff_t index_row, const std::ptrdiff_t index_col_first, const std::ptrdiff_t index_num_cols)
Access row of a matrix.
This namespace contains various functions operating on Eigen matrices and vectors.
Definition: blockmatrix.h:19
Eigen::Block< EIGENTOOLS_DYNAMIC_MATRIX(Scalar), t_block_rows_num, t_block_cols_num > StaticMatrixBlock
Shorthand for Eigen block.
void multiplyRight(Eigen::PlainObjectBase< t_DerivedOutput > &result, const BlockMatrixBase< t_MatrixType_in, t_block_rows_num_in, t_block_cols_num_in, t_sparsity_type_in > &rhs) const
this * BlockMatrix
std::ptrdiff_t getBlockColsNum() const
Returns dimension of the matrix block.
TypeWithoutConst< typename TypeWithoutReference< T >::Type >::Type Type
Sparsity type of a matrix.
BlockMatrixAccessBase< t_MatrixType, t_block_rows_num, t_block_cols_num >::Scalar Scalar
#define EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM
BlockMatrixAccessBase< t_MatrixType, 1, 1 >::DecayedRawMatrix DecayedRawMatrix
Eigen::Block< EIGENTOOLS_DYNAMIC_MATRIX(Scalar) > DynamicMatrixBlock
Shorthand for Eigen block.
BlockMatrixSizeSpecificBase< t_MatrixType, 1, 1 >::DecayedRawMatrix DecayedRawMatrix
void multiplyRight(Eigen::PlainObjectBase< t_DerivedOutput > &result, const Eigen::MatrixBase< t_DerivedInput > &matrix) const
this * Matrix
BlockMatrixSizeSpecificBase< t_MatrixType, t_block_rows_num, t_block_cols_num >::DecayedRawMatrix DecayedRawMatrix
std::ptrdiff_t getNumberOfBlocksVertical() const
Get number of blocks (horizontal/vertical)
~BlockMatrixBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
Type modifier (drop reference &#39;const&#39;)
Scalar & operator()(const std::ptrdiff_t index)
Block access operator for diagonal blocks.
~BlockMatrixAccessBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
StaticMatrixBlock operator()(const std::ptrdiff_t index)
Block access operator for diagonal blocks.
DecayedRawMatrix::Scalar Scalar
Scalar type of raw matrix (from Eigen)
DynamicMatrixBlock column(const std::ptrdiff_t index_col, const std::ptrdiff_t index_row_first=0)
Access column of a matrix.