26 typedef std::pair<unsigned,unsigned> Index;
27 typedef std::map<Index,Matrix> Blocks;
34 size_t size()
const override {
36 for (
const auto&
block : all_blocks)
41 void info()
const override {
43 std::cout <<
"Empty matrix" << std::endl;
47 std::cout <<
"Block matrix" << std::endl;
48 std::cout <<
"Dimensions: " <<
nlin() <<
" x " <<
ncol() << std::endl;
49 std::cout <<
"Number of blocks: " << all_blocks.size() << std::endl;
50 std::cout <<
"Number of coefficients: " <<
size() << std::endl;
54 const Matrix&
block(
const unsigned i,
const unsigned j)
const {
return all_blocks.at({
i,
j}); }
56 const Blocks&
blocks()
const {
return all_blocks; }
68 for (
const auto&
ir : row_ranges)
69 for (
const auto&
jr : col_ranges)
74 const Index& ind = find_block_indices(
i,
j);
81 const Index& ind = find_block_indices(
i,
j);
95 Index find_block_indices(
const unsigned i,
const unsigned j)
const {
96 const unsigned iind = row_ranges.
find_index(i);
97 const unsigned jind = col_ranges.
find_index(j);
98 return { iind, jind };
107 for (
const auto& block :
bm.blocks())
108 os <<
"Block " << block.first.first <<
',' << block.first.second << std::endl;
110 os <<
"Block " << block.first.first <<
',' << block.first.second << std::endl
111 << block.second << std::endl;
virtual Dimension ncol() const
Matrix class Matrix class.
size_t size() const
Get Matrix size.
Block matrix class Block matrix class.
BlockMatrix(const size_t M, const size_t N)
double operator()(const size_t i, const size_t j) const
void set_blocks(const Ranges &rows, const Ranges &cols)
void add_block(const Range &ir, const Range &jr)
double & operator()(const size_t i, const size_t j)
void info() const override
size_t size() const override
const Blocks & blocks() const
const Matrix & block(const unsigned i, const unsigned j) const
Matrix & block(const unsigned i, const unsigned j)
unsigned add(const Range &range)
unsigned find_index(const size_t ind) const
std::ostream & operator<<(std::ostream &os, const BlockMatrix &bm)