14 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixBase< const typename TypeWithoutConst<t_MatrixType>::Type, \ 15 t_block_rows_num, t_block_cols_num, t_sparsity_type> 24 template<
class t_MatrixType,
35 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator();
36 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
37 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_hor_;
38 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_vert_;
39 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::multiplyRight;
40 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::column;
41 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;
42 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;
52 template<
class t_Derived>
55 Eigen::MatrixBase<t_Derived> & out =
const_cast< Eigen::MatrixBase<t_Derived> &
> (output);
57 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
59 std::ptrdiff_t primary_block_col = j * identity_size_;
61 for (std::ptrdiff_t i = 0; i < num_blocks_vert_; ++i)
63 std::ptrdiff_t primary_block_row = i * identity_size_;
65 for(std::ptrdiff_t k = 0; k < identity_size_; ++k)
69 EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
70 EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM) = (*this)(i, j);
92 template<
class t_Derived,
93 typename t_DBMMatrixType,
94 int t_dbm_block_rows_num,
95 int t_dbm_block_cols_num>
103 "Block sizes do not match.");
105 "Numbers of blocks do not match.");
107 "Sizes of matrices do not match.");
110 result.resize(identity_size_ * matrix_.rows(), dbm.getNumberOfColumns());
111 if (num_blocks_hor_ != 0)
113 Eigen::VectorXi indices;
115 indices.resize(identity_size_ * matrix_.rows());
117 for (std::ptrdiff_t i = 0; i < identity_size_; ++i)
119 for (std::ptrdiff_t j = 0; j < num_blocks_vert_; ++j)
122 Eigen::VectorXi::LinSpaced( EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
124 i*matrix_.rows() + (j+1)*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM - 1);
129 std::ptrdiff_t dbm_block_cols = dbm.getNumberOfColumns() / num_blocks_hor_;
131 for (std::ptrdiff_t i = 0; i < identity_size_; ++i)
133 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
135 result.block(i*matrix_.rows(), dbm_block_cols*j, matrix_.rows(), dbm_block_cols).noalias() =
142 result = (Eigen::PermutationWrapper<Eigen::VectorXi> (indices)).transpose() * result;
210 template<
class t_DerivedOutput,
213 int t_vector_options>
215 const Eigen::Matrix<t_Scalar, t_vector_size, 1, t_vector_options> & vector)
const 221 result.resize(identity_size_ * matrix_.rows());
223 vector_part.resize(matrix_.cols());
225 for (std::ptrdiff_t i = 0; i < identity_size_; ++i)
227 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
230 vector.segment(j*EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM*identity_size_ + i*EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM, EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM);
233 result_part.noalias() = matrix_ * vector_part;
235 for (std::ptrdiff_t j = 0; j < num_blocks_vert_; ++j)
238 result_part.segment(j*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM);
252 DecayedRawMatrix output;
266 template<
class t_Derived>
267 void evaluate(Eigen::PlainObjectBase<t_Derived> & output)
const 269 output.setZero(identity_size_ * matrix_.rows(),
270 identity_size_ * matrix_.cols());
271 evaluateWithoutInitialization(output);
285 template<
class t_Derived,
int t_rows,
int t_cols,
bool t_flag>
286 void evaluate(Eigen::Block<t_Derived, t_rows, t_cols, t_flag> output)
const 289 evaluateWithoutInitialization(output);
303 const std::ptrdiff_t identity_size = 1,
309 "Identity size cannot be less than 2.");
310 identity_size_ = identity_size;
313 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 317 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixBase< const typename TypeWithoutConst<t_MatrixType>::Type, \ 318 t_block_rows_num, t_block_cols_num, MatrixSparsityType::LEFT_LOWER_TRIANGULAR> 327 template<
class t_MatrixType,
328 int t_block_rows_num,
329 int t_block_cols_num>
341 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator();
342 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
343 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_hor_;
344 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_vert_;
345 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::multiplyRight;
346 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::column;
347 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;
348 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;
358 template<
class t_Derived>
361 Eigen::MatrixBase<t_Derived> & out =
const_cast< Eigen::MatrixBase<t_Derived> &
> (output);
363 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
365 std::ptrdiff_t primary_block_col = j * identity_size_;
367 for (std::ptrdiff_t i = j; i < num_blocks_vert_; ++i)
369 std::ptrdiff_t primary_block_row = i * identity_size_;
371 for(std::ptrdiff_t k = 0; k < identity_size_; ++k)
375 EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
376 EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM) = (*this)(i, j);
398 template<
class t_Derived,
399 typename t_DBMMatrixType,
400 int t_dbm_block_rows_num,
401 int t_dbm_block_cols_num>
404 t_dbm_block_rows_num,
405 t_dbm_block_cols_num,
409 "Block sizes do not match.");
411 "Numbers of blocks do not match.");
413 "Sizes of matrices do not match.");
415 result.setZero(identity_size_ * matrix_.rows(), dbm.getNumberOfColumns());
416 if (num_blocks_hor_ != 0)
418 Eigen::VectorXi indices;
420 indices.resize(identity_size_ * matrix_.rows());
422 for (std::ptrdiff_t i = 0; i < identity_size_; ++i)
424 for (std::ptrdiff_t j = 0; j < num_blocks_vert_; ++j)
427 Eigen::VectorXi::LinSpaced( EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM,
429 i*matrix_.rows() + (j+1)*EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM - 1);
434 std::ptrdiff_t dbm_block_cols = dbm.getNumberOfColumns() / num_blocks_hor_;
436 for (std::ptrdiff_t i = 0; i < identity_size_; ++i)
438 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
440 result.block(i*matrix_.rows() + j*
EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, dbm_block_cols*j, (num_blocks_vert_ - j) * EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM, dbm_block_cols).noalias() =
447 result = (Eigen::PermutationWrapper<Eigen::VectorXi> (indices)).transpose() * result;
460 DecayedRawMatrix output;
474 template<
class t_Derived>
475 void evaluate(Eigen::PlainObjectBase<t_Derived> & output)
const 477 output.setZero(identity_size_ * matrix_.rows(),
478 identity_size_ * matrix_.cols());
479 evaluateWithoutInitialization(output);
493 template<
class t_Derived,
int t_rows,
int t_cols,
bool t_flag>
494 void evaluate(Eigen::Block<t_Derived, t_rows, t_cols, t_flag> output)
const 497 evaluateWithoutInitialization(output);
510 const std::ptrdiff_t identity_size = 1,
516 "Identity size cannot be less than 2.");
517 identity_size_ = identity_size;
520 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 524 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixBase< const typename TypeWithoutConst<t_MatrixType>::Type, \ 525 1, 1, t_sparsity_type> 533 template<
class t_MatrixType,
543 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator();
544 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
545 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_hor_;
546 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_vert_;
547 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::multiplyRight;
548 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::column;
549 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;
550 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;
560 template<
class t_Derived>
563 Eigen::MatrixBase<t_Derived> & out =
const_cast< Eigen::MatrixBase<t_Derived> &
> (output);
565 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
567 std::ptrdiff_t primary_block_col = j * identity_size_;
569 for (std::ptrdiff_t i = 0; i < num_blocks_vert_; ++i)
571 std::ptrdiff_t primary_block_row = i * identity_size_;
573 for(std::ptrdiff_t k = 0; k < identity_size_; ++k)
575 out(primary_block_row + k,
576 primary_block_col + k) = (*this)(i, j);
598 template<
class t_Derived,
599 typename t_DBMMatrixType,
600 int t_dbm_block_rows_num,
601 int t_dbm_block_cols_num>
604 t_dbm_block_rows_num,
605 t_dbm_block_cols_num,
609 "Block sizes do not match.");
611 "Numbers of blocks do not match.");
613 "Sizes of matrices do not match.");
617 t_dbm_block_rows_num,
618 t_dbm_block_cols_num,
621 result_bmi.resize(num_blocks_vert_, dbm.getNumberOfBlocksHorizontal());
623 if (num_blocks_hor_ != 0)
625 for (std::ptrdiff_t j = 0; j < dbm.getNumberOfBlocksHorizontal(); ++j)
627 for (std::ptrdiff_t i = 0; i < num_blocks_vert_; ++i)
630 result_bmi(i,j) = EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator()(i,j) * dbm(j);
649 template<
class t_DerivedOutput,
652 int t_vector_options>
654 const Eigen::Matrix<t_Scalar, t_vector_size, 1, t_vector_options> & vector)
const 656 result.setZero(identity_size_ * matrix_.rows());
658 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
660 for (std::ptrdiff_t i = 0; i < num_blocks_vert_; ++i)
662 result.segment(i*identity_size_, identity_size_)
663 += EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator()(i,j)
665 vector.segment(j*identity_size_, identity_size_);
679 DecayedRawMatrix output;
693 template<
class t_Derived>
694 void evaluate(Eigen::PlainObjectBase<t_Derived> & output)
const 696 output.setZero(identity_size_ * matrix_.rows(),
697 identity_size_ * matrix_.cols());
698 evaluateWithoutInitialization(output);
712 template<
class t_Derived,
int t_rows,
int t_cols,
bool t_flag>
713 void evaluate(Eigen::Block<t_Derived, t_rows, t_cols, t_flag> output)
const 716 evaluateWithoutInitialization(output);
730 const std::ptrdiff_t identity_size = 1,
736 "Identity size cannot be less than 2.");
737 identity_size_ = identity_size;
740 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 743 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixBase< const typename TypeWithoutConst<t_MatrixType>::Type, \ 744 1, 1, MatrixSparsityType::LEFT_LOWER_TRIANGULAR> 751 template<
class t_MatrixType>
760 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator();
761 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
762 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_hor_;
763 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::num_blocks_vert_;
764 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::multiplyRight;
765 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::column;
766 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_rows_num_;
767 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::block_cols_num_;
777 template<
class t_Derived>
780 Eigen::MatrixBase<t_Derived> & out =
const_cast< Eigen::MatrixBase<t_Derived> &
> (output);
782 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
784 std::ptrdiff_t primary_block_col = j * identity_size_;
786 for (std::ptrdiff_t i = j; i < num_blocks_vert_; ++i)
788 std::ptrdiff_t primary_block_row = i * identity_size_;
790 for(std::ptrdiff_t k = 0; k < identity_size_; ++k)
792 out(primary_block_row + k,
793 primary_block_col + k) = (*this)(i, j);
815 template<
class t_Derived,
816 typename t_DBMMatrixType,
817 int t_dbm_block_rows_num,
818 int t_dbm_block_cols_num>
821 t_dbm_block_rows_num,
822 t_dbm_block_cols_num,
826 "Block sizes do not match.");
828 "Numbers of blocks do not match.");
830 "Sizes of matrices do not match.");
835 t_dbm_block_rows_num,
836 t_dbm_block_cols_num,
839 result_bmi.setZero(num_blocks_vert_, dbm.getNumberOfBlocksHorizontal());
841 if (num_blocks_hor_ != 0)
843 for (std::ptrdiff_t j = 0; j < dbm.getNumberOfBlocksHorizontal(); ++j)
845 for (std::ptrdiff_t i = j; i < num_blocks_vert_; ++i)
848 result_bmi(i,j) = EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator()(i,j) * dbm(j);
867 template<
class t_Derived,
868 typename t_DBMMatrixType,
869 int t_dbm_block_rows_num,
870 int t_dbm_block_cols_num>
873 t_dbm_block_rows_num,
874 t_dbm_block_cols_num,
878 "Block sizes do not match.");
880 "Numbers of blocks do not match.");
882 "Sizes of matrices do not match.");
886 t_dbm_block_rows_num,
887 t_dbm_block_cols_num,
890 result_bmi.setZero(num_blocks_vert_, dbm.getNumberOfBlocksHorizontal());
892 if (num_blocks_hor_ != 0)
894 for (std::ptrdiff_t j = 0; j < num_blocks_hor_; ++j)
896 for (std::ptrdiff_t i = j; i < dbm.getNumberOfBlocksVertical(); ++i)
898 result_bmi(i,j) = dbm(i) * EIGENTOOLS_PARENT_CLASS_SHORTHAND::operator()(i,j);
913 DecayedRawMatrix output;
927 template<
class t_Derived>
928 void evaluate(Eigen::PlainObjectBase<t_Derived> & output)
const 930 output.setZero(identity_size_ * matrix_.rows(),
931 identity_size_ * matrix_.cols());
932 evaluateWithoutInitialization(output);
946 template<
class t_Derived,
int t_rows,
int t_cols,
bool t_flag>
947 void evaluate(Eigen::Block<t_Derived, t_rows, t_cols, t_flag> output)
const 950 evaluateWithoutInitialization(output);
963 const std::ptrdiff_t identity_size = 1,
969 "Identity size cannot be less than 2.");
970 identity_size_ = identity_size;
973 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 1003 template<
class t_MatrixType,
1004 int t_block_rows_num,
1005 int t_block_cols_num,
1009 int t_vector_options >
1015 t_sparsity_type> & bm,
1016 const Eigen::Matrix<t_Scalar,
1019 t_vector_options> & vector)
1022 bm.multiplyRight(result, vector);
1044 template<
typename t_left_MatrixType,
1045 int t_left_block_rows_num,
1046 int t_left_block_cols_num,
1048 typename t_right_MatrixType,
1049 int t_right_block_rows_num,
1050 int t_right_block_cols_num,
1055 t_left_block_rows_num,
1056 t_left_block_cols_num,
1057 t_left_sparsity_type> & left,
1059 t_right_block_rows_num,
1060 t_right_block_cols_num,
1061 t_right_sparsity_type> & right)
1064 left.multiplyRight(result, right);
1088 template<
typename t_left_MatrixType,
1089 int t_left_block_rows_num,
1090 int t_left_block_cols_num,
1092 typename t_right_MatrixType,
1093 int t_right_block_rows_num,
1094 int t_right_block_cols_num,
1099 t_left_block_rows_num,
1100 t_left_block_cols_num,
1101 t_left_sparsity_type> & left,
1103 t_right_block_rows_num,
1104 t_right_block_cols_num,
1105 t_right_sparsity_type> & right)
1108 right.multiplyLeft(result, left);
#define EIGENTOOLS_BLOCKMATRIX_BLOCK_COLS_NUM
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)
'BlockMatrixBase * Eigen::Matrix' operator
#define EIGENTOOLS_PARENT_CLASS_SHORTHAND
#define EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM