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_) 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) {}; 104 template<
typename t_MatrixType,
105 int t_block_rows_num,
106 int t_block_cols_num>
114 typedef typename DecayedRawMatrix::Scalar
Scalar;
131 return(num_blocks_vert_);
138 return(num_blocks_hor_);
168 template <
class t_Derived>
169 void set (
const Eigen::DenseBase<t_Derived> &matrix)
182 void resize(
const std::ptrdiff_t num_blocks_vert,
183 const std::ptrdiff_t num_blocks_hor)
197 void setZero(
const std::ptrdiff_t num_blocks_vert,
198 const std::ptrdiff_t num_blocks_hor)
211 void resize(
const std::ptrdiff_t num_blocks)
213 resize(num_blocks, num_blocks);
224 setZero(num_blocks, num_blocks);
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)
242 return (DynamicMatrixBlock (matrix_.derived(),
260 DynamicMatrixBlock
column(
const std::ptrdiff_t index_col,
261 const std::ptrdiff_t index_row_first = 0)
263 return (column(index_col, index_row_first, num_blocks_vert_ - index_row_first));
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 272 return (ConstDynamicMatrixBlock ( matrix_.derived(),
281 ConstDynamicMatrixBlock
column(
const std::ptrdiff_t index_col,
282 const std::ptrdiff_t index_row_first = 0)
const 284 return (column(index_col, index_row_first, num_blocks_vert_ - index_row_first));
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)
301 return (DynamicMatrixBlock( matrix_.derived(),
319 DynamicMatrixBlock
row(
const std::ptrdiff_t index_row,
320 const std::ptrdiff_t index_col_first = 0)
322 return (row(index_row, index_col_first, num_blocks_hor_ - index_col_first));
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 331 return (ConstDynamicMatrixBlock(matrix_.derived(),
340 ConstDynamicMatrixBlock
row(
const std::ptrdiff_t index_row,
341 const std::ptrdiff_t index_col_first = 0)
const 343 return (row(index_row, index_col_first, num_blocks_hor_ - index_col_first));
396 const std::ptrdiff_t block_cols_num)
399 "Block dimension must be strictly positive.");
401 "Block dimension must be strictly positive.");
402 initializeBlockSize(block_rows_num, block_cols_num);
431 initializeBlockSize(block_rows_num, block_cols_num);
448 initializeBlockSize(block_rows_num, block_cols_num);
465 initializeBlockSize(block_rows_num, block_cols_num);
475 const std::ptrdiff_t block_cols_num)
479 block_rows_num_ = block_rows_num;
484 "Matrix block is static, but nonzero dimension size is passed to the constructor.");
485 block_rows_num_ = t_block_rows_num;
490 block_cols_num_ = block_cols_num;
495 "Matrix block is static, but nonzero dimension size is passed to the constructor.");
496 block_cols_num_ = t_block_cols_num;
510 "Wrong number of rows.");
513 "Vertical dimension of the matrix is not a multiple of the corresponding block dimension.");
522 "Wrong number of cols.");
525 "Horizontal dimension of the matrix is not a multiple of the corresponding block dimension.");
533 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase<t_MatrixType, t_block_rows_num, t_block_cols_num> 542 template<
typename t_MatrixType,
543 int t_block_rows_num,
544 int t_block_cols_num>
549 typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::Scalar
Scalar;
570 StaticMatrixBlock
operator()(
const std::ptrdiff_t index_row,
571 const std::ptrdiff_t index_col)
573 return (StaticMatrixBlock( matrix_.derived(),
574 index_row * t_block_rows_num,
575 index_col * t_block_cols_num));
580 ConstStaticMatrixBlock
operator()(
const std::ptrdiff_t index_row,
581 const std::ptrdiff_t index_col)
const 583 return (ConstStaticMatrixBlock( matrix_.derived(),
584 index_row * t_block_rows_num,
585 index_col * t_block_cols_num));
598 return ((*
this)(index,index));
603 ConstStaticMatrixBlock
operator()(
const std::ptrdiff_t index)
const 605 return ((*
this)(index,index));
610 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
621 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 624 #define EIGENTOOLS_CODE_GENERATOR\ 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)\ 632 return (DynamicMatrixBlock( matrix_.derived(),\ 633 index_row * block_rows_num_,\ 634 index_col * block_cols_num_,\ 638 ConstDynamicMatrixBlock operator()( const std::ptrdiff_t index_row,\ 639 const std::ptrdiff_t index_col) const\ 641 return (ConstDynamicMatrixBlock(matrix_.derived(),\ 642 index_row * block_rows_num_,\ 643 index_col * block_cols_num_,\ 648 operator()(const std::ptrdiff_t index)\ 650 return ((*this)(index,index));\ 652 ConstDynamicMatrixBlock\ 653 operator()(const std::ptrdiff_t index) const\ 655 return ((*this)(index,index));\ 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)\ 664 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase< t_MatrixType, \ 665 MatrixBlockSizeType::DYNAMIC, \ 666 MatrixBlockSizeType::DYNAMIC> 676 template<
typename t_MatrixType>
684 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 687 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase< t_MatrixType, \ 689 MatrixBlockSizeType::DYNAMIC> 698 template<
typename t_MatrixType,
int t_block_rows_num>
706 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 709 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase< t_MatrixType, \ 710 MatrixBlockSizeType::DYNAMIC, \ 720 template<
typename t_MatrixType,
int t_block_cols_num>
728 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 729 #undef EIGENTOOLS_CODE_GENERATOR 732 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixAccessBase<t_MatrixType, 1, 1> 742 template<
typename t_MatrixType>
747 typedef typename EIGENTOOLS_PARENT_CLASS_SHORTHAND::Scalar
Scalar;
759 const std::ptrdiff_t index_col)
761 return (matrix_(index_row, index_col));
767 const std::ptrdiff_t index_col)
const 769 return (matrix_(index_row, index_col));
782 return (matrix_(index, index));
789 return (matrix_(index, index));
794 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
806 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 825 LEFT_LOWER_TRIANGULAR = 3
835 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, t_block_rows_num, t_block_cols_num> 844 template<
typename t_MatrixType,
845 int t_block_rows_num,
846 int t_block_cols_num,
851 using EIGENTOOLS_PARENT_CLASS_SHORTHAND::matrix_;
869 template<
class t_DerivedOutput,
class t_DerivedInput>
871 const Eigen::MatrixBase<t_DerivedInput> & matrix)
const 873 result.noalias() = matrix_*matrix;
876 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 879 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, t_block_rows_num, t_block_cols_num> 888 template<
typename t_MatrixType,
889 int t_block_rows_num,
890 int t_block_cols_num >
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;
916 template<
class t_DerivedOutput,
class t_DerivedInput>
918 const Eigen::MatrixBase<t_DerivedInput> & matrix)
const 922 std::ptrdiff_t num_cols = matrix.cols();
924 result.resize(getNumberOfRows(), num_cols);
926 for(std::ptrdiff_t i = 0; i < num_blocks_hor_; ++i)
945 template<
class t_DerivedInput,
946 class t_DerivedOutput>
948 const Eigen::DenseBase<t_DerivedInput> &matrix)
const 952 std::ptrdiff_t num_rows = matrix.rows();
954 result.resize(num_rows, getNumberOfColumns());
956 for(std::ptrdiff_t i = 0; i < num_blocks_vert_; ++i)
975 template<
typename t_MatrixType_in,
976 int t_block_rows_num_in,
977 int t_block_cols_num_in,
979 class t_DerivedOutput>
984 t_sparsity_type_in> & rhs)
const 986 multiplyRight(result, rhs.getRaw());
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_;
1007 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 1011 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, t_block_rows_num, t_block_cols_num> 1020 template<
typename t_MatrixType,
1021 int t_block_rows_num,
1022 int t_block_cols_num >
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;
1048 template<
class t_DerivedOutput,
class t_DerivedInput>
1050 const Eigen::MatrixBase<t_DerivedInput> & matrix)
const 1069 result.noalias() = matrix_*matrix;
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_;
1090 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 1094 #define EIGENTOOLS_PARENT_CLASS_SHORTHAND BlockMatrixSizeSpecificBase<t_MatrixType, 1, 1> 1103 template<
typename t_MatrixType >
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;
1129 template<
class t_DerivedOutput,
class t_DerivedInput>
1131 const Eigen::MatrixBase<t_DerivedInput> & matrix)
const 1136 result.noalias() = matrix_.template triangularView<Eigen::Lower>() * matrix;
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_;
1157 #undef EIGENTOOLS_PARENT_CLASS_SHORTHAND 1185 template<
typename t_MatrixType,
1186 int t_block_rows_num,
1187 int t_block_cols_num,
1195 t_sparsity_type> & bm,
1196 const Eigen::MatrixBase<t_Derived> & matrix)
1199 bm.multiplyRight(result, matrix);
1221 template<
class t_Derived,
1222 typename t_MatrixType,
1223 int t_block_rows_num,
1224 int t_block_cols_num,
1230 operator* (
const Eigen::MatrixBase<t_Derived> & eigen_matrix,
1234 t_sparsity_type> & bm)
1237 bm.multiplyLeft(result, eigen_matrix);
1261 template<
typename t_left_MatrixType,
1262 int t_left_block_rows_num,
1263 int t_left_block_cols_num,
1265 typename t_right_MatrixType,
1266 int t_right_block_cols_num>
1270 t_left_block_rows_num,
1271 t_left_block_cols_num,
1272 t_left_sparsity_type> & left,
1274 t_left_block_cols_num,
1275 t_right_block_cols_num,
1279 right.multiplyLeft(result, left.getRaw());
1302 template<
typename t_left_MatrixType,
1303 int t_left_block_rows_num,
1304 int t_left_block_cols_num,
1306 typename t_right_MatrixType,
1307 int t_right_block_cols_num,
1312 t_left_block_rows_num,
1313 t_left_block_cols_num,
1314 t_left_sparsity_type> & left,
1316 t_left_block_cols_num,
1317 t_right_block_cols_num,
1318 t_right_sparsity_type> & right)
1321 left.multiplyRight(result, right);
#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_DEFINE_BLOCK_MATRIX_CONSTRUCTORS(class_name)
#define EIGENTOOLS_CODE_GENERATOR
#define EIGENTOOLS_PARENT_CLASS_SHORTHAND
#define EIGENTOOLS_BLOCKMATRIX_BLOCK_ROWS_NUM