/**
* Number of block rows.
*/
- size_type rows;
+ size_type block_rows;
/**
* Number of block columns.
*/
- size_type columns;
+ size_type block_columns;
/**
* Array of sparsity patterns.
BlockSparsityPatternBase<SparsityPatternType>::block(const size_type row,
const size_type column)
{
- AssertIndexRange(row, rows);
- AssertIndexRange(column, columns);
- return *sub_objects[row][column];
+ AssertIndexRange(row, n_block_rows());
+ AssertIndexRange(column, n_block_cols());
+ return *sub_objects(row, column);
}
const size_type row,
const size_type column) const
{
- AssertIndexRange(row, rows);
- AssertIndexRange(column, columns);
- return *sub_objects[row][column];
+ AssertIndexRange(row, n_block_rows());
+ AssertIndexRange(column, n_block_cols());
+ return *sub_objects(row, column);
}
Assert(n_cols() == compute_n_cols(), ExcNeedsCollectSizes());
// Resize scratch arrays
- if (block_column_indices.size() < this->n_block_cols())
+ if (block_column_indices.size() < n_block_cols())
{
- block_column_indices.resize(this->n_block_cols());
- counter_within_block.resize(this->n_block_cols());
+ block_column_indices.resize(n_block_cols());
+ counter_within_block.resize(n_block_cols());
}
- const size_type n_cols = static_cast<size_type>(end - begin);
+ const size_type n_added_cols = static_cast<size_type>(end - begin);
- // Resize sub-arrays to n_cols. This
+ // Resize sub-arrays to n_added_cols. This
// is a bit wasteful, but we resize
// only a few times (then the maximum
// row length won't increase that
// whether the size of one is large
// enough before actually going
// through all of them.
- if (block_column_indices[0].size() < n_cols)
+ if (block_column_indices[0].size() < n_added_cols)
for (size_type i = 0; i < this->n_block_cols(); ++i)
- block_column_indices[i].resize(n_cols);
+ block_column_indices[i].resize(n_added_cols);
// Reset the number of added elements
// in each block to zero.
// If in debug mode, do a check whether
// the right length has been obtained.
size_type length = 0;
- for (size_type i = 0; i < this->n_block_cols(); ++i)
+ for (size_type i = 0; i < n_block_cols(); ++i)
length += counter_within_block[i];
- Assert(length == n_cols, ExcInternalError());
+ Assert(length == n_added_cols, ExcInternalError());
#endif
// Now we found out about where the
unsigned int c = 0;
- for (size_type b = 0; b < rows; ++b)
+ for (size_type b = 0; b < n_block_rows(); ++b)
c += sub_objects[row_index.first][b]->row_length(row_index.second);
return c;
inline typename BlockSparsityPatternBase<SparsityPatternType>::size_type
BlockSparsityPatternBase<SparsityPatternType>::n_block_cols() const
{
- return columns;
+ return block_columns;
}
inline typename BlockSparsityPatternBase<SparsityPatternType>::size_type
BlockSparsityPatternBase<SparsityPatternType>::n_block_rows() const
{
- return rows;
+ return block_rows;
}
size_type c = 0;
size_type block_columns = 0; // sum of n_cols for all blocks to the left
- for (unsigned int b = 0; b < columns; ++b)
+ for (unsigned int b = 0; b < this->n_block_cols(); ++b)
{
unsigned int rowlen =
sub_objects[row_index.first][b]->row_length(row_index.second);
inline void
-BlockSparsityPattern::reinit(const size_type n_block_rows,
- const size_type n_block_columns)
+BlockSparsityPattern::reinit(const size_type new_block_rows,
+ const size_type new_block_columns)
{
- BlockSparsityPatternBase<SparsityPattern>::reinit(n_block_rows,
- n_block_columns);
+ BlockSparsityPatternBase<SparsityPattern>::reinit(new_block_rows,
+ new_block_columns);
}
template <class SparsityPatternType>
BlockSparsityPatternBase<SparsityPatternType>::BlockSparsityPatternBase()
- : rows(0)
- , columns(0)
+ : block_rows(0)
+ , block_columns(0)
{}
template <class SparsityPatternType>
BlockSparsityPatternBase<SparsityPatternType>::BlockSparsityPatternBase(
- const size_type n_block_rows,
- const size_type n_block_columns)
+ const size_type block_rows,
+ const size_type block_columns)
: BlockSparsityPatternBase()
{
- reinit(n_block_rows, n_block_columns);
+ reinit(block_rows, block_columns);
}
: BlockSparsityPatternBase()
{
(void)s;
- Assert(s.rows == 0 && s.columns == 0,
+ Assert(s.n_block_rows() == 0 && s.n_block_cols() == 0,
ExcMessage(
"This constructor can only be called if the provided argument "
"is the sparsity pattern for an empty matrix. This constructor can "
template <class SparsityPatternType>
void
BlockSparsityPatternBase<SparsityPatternType>::reinit(
- const size_type n_block_rows,
- const size_type n_block_columns)
+ const size_type new_block_rows,
+ const size_type new_block_columns)
{
sub_objects.reinit(0, 0);
- rows = n_block_rows;
- columns = n_block_columns;
+ block_rows = new_block_rows;
+ block_columns = new_block_columns;
- sub_objects.reinit(rows, columns);
- for (size_type i = 0; i < rows; ++i)
- for (size_type j = 0; j < columns; ++j)
+ sub_objects.reinit(block_rows, block_columns);
+ for (size_type i = 0; i < n_block_rows(); ++i)
+ for (size_type j = 0; j < n_block_cols(); ++j)
sub_objects[i][j] = std::make_unique<SparsityPatternType>();
}
BlockSparsityPatternBase<SparsityPatternType>::operator=(
const BlockSparsityPatternBase<SparsityPatternType> &bsp)
{
- Assert(rows == bsp.rows, ExcDimensionMismatch(rows, bsp.rows));
- Assert(columns == bsp.columns, ExcDimensionMismatch(columns, bsp.columns));
+ AssertDimension(n_block_rows(), bsp.n_block_rows());
+ AssertDimension(n_block_cols(), bsp.n_block_cols());
// copy objects
- for (size_type i = 0; i < rows; ++i)
- for (size_type j = 0; j < columns; ++j)
+ for (size_type i = 0; i < n_block_rows(); ++i)
+ for (size_type j = 0; j < n_block_cols(); ++j)
*sub_objects[i][j] = *bsp.sub_objects[i][j];
// update index objects
collect_sizes();
// only count in first column, since
// all rows should be equivalent
size_type count = 0;
- for (size_type r = 0; r < rows; ++r)
+ for (size_type r = 0; r < n_block_rows(); ++r)
count += sub_objects[r][0]->n_rows();
return count;
}
// only count in first row, since
// all rows should be equivalent
size_type count = 0;
- for (size_type c = 0; c < columns; ++c)
+ for (size_type c = 0; c < n_block_cols(); ++c)
count += sub_objects[0][c]->n_cols();
return count;
}
void
BlockSparsityPatternBase<SparsityPatternType>::collect_sizes()
{
- std::vector<size_type> row_sizes(rows);
- std::vector<size_type> col_sizes(columns);
+ std::vector<size_type> row_sizes(n_block_rows());
+ std::vector<size_type> col_sizes(n_block_cols());
// first find out the row sizes
// from the first block column
- for (size_type r = 0; r < rows; ++r)
+ for (size_type r = 0; r < n_block_rows(); ++r)
row_sizes[r] = sub_objects[r][0]->n_rows();
// then check that the following
// block columns have the same
// sizes
- for (size_type c = 1; c < columns; ++c)
- for (size_type r = 0; r < rows; ++r)
+ for (size_type c = 1; c < n_block_cols(); ++c)
+ for (size_type r = 0; r < n_block_rows(); ++r)
Assert(row_sizes[r] == sub_objects[r][c]->n_rows(),
ExcIncompatibleRowNumbers(r, 0, r, c));
// then do the same with the columns
- for (size_type c = 0; c < columns; ++c)
+ for (size_type c = 0; c < n_block_cols(); ++c)
col_sizes[c] = sub_objects[0][c]->n_cols();
- for (size_type r = 1; r < rows; ++r)
- for (size_type c = 0; c < columns; ++c)
+ for (size_type r = 1; r < n_block_rows(); ++r)
+ for (size_type c = 0; c < n_block_cols(); ++c)
Assert(col_sizes[c] == sub_objects[r][c]->n_cols(),
ExcIncompatibleRowNumbers(0, c, r, c));
void
BlockSparsityPatternBase<SparsityPatternType>::compress()
{
- for (size_type i = 0; i < rows; ++i)
- for (size_type j = 0; j < columns; ++j)
+ for (size_type i = 0; i < n_block_rows(); ++i)
+ for (size_type j = 0; j < n_block_cols(); ++j)
sub_objects[i][j]->compress();
}
bool
BlockSparsityPatternBase<SparsityPatternType>::empty() const
{
- for (size_type i = 0; i < rows; ++i)
- for (size_type j = 0; j < columns; ++j)
+ for (size_type i = 0; i < n_block_rows(); ++i)
+ for (size_type j = 0; j < n_block_cols(); ++j)
if (sub_objects[i][j]->empty() == false)
return false;
return true;
BlockSparsityPatternBase<SparsityPatternType>::max_entries_per_row() const
{
size_type max_entries = 0;
- for (size_type block_row = 0; block_row < rows; ++block_row)
+ for (size_type block_row = 0; block_row < n_block_rows(); ++block_row)
{
size_type this_row = 0;
- for (size_type c = 0; c < columns; ++c)
+ for (size_type c = 0; c < n_block_cols(); ++c)
this_row += sub_objects[block_row][c]->max_entries_per_row();
if (this_row > max_entries)
BlockSparsityPatternBase<SparsityPatternType>::n_nonzero_elements() const
{
size_type count = 0;
- for (size_type i = 0; i < rows; ++i)
- for (size_type j = 0; j < columns; ++j)
+ for (size_type i = 0; i < n_block_rows(); ++i)
+ for (size_type j = 0; j < n_block_cols(); ++j)
count += sub_objects[i][j]->n_nonzero_elements();
return count;
}
<< "\" fill=\"rgb(255, 255, 255)\"/>\n\n";
for (unsigned int block_i = 0; block_i < n_block_rows(); ++block_i)
- for (unsigned int block_j = 0; block_j < n_block_rows(); ++block_j)
+ for (unsigned int block_j = 0; block_j < n_block_cols(); ++block_j)
for (const auto &entry : block(block_i, block_j))
{
out << " <rect class=\"pixel\" x=\""
bool
BlockSparsityPattern::is_compressed() const
{
- for (size_type i = 0; i < rows; ++i)
- for (size_type j = 0; j < columns; ++j)
+ for (size_type i = 0; i < n_block_rows(); ++i)
+ for (size_type j = 0; j < n_block_cols(); ++j)
if (sub_objects[i][j]->is_compressed() == false)
return false;
return true;
BlockSparsityPattern::memory_consumption() const
{
std::size_t mem = 0;
- mem += (MemoryConsumption::memory_consumption(rows) +
- MemoryConsumption::memory_consumption(columns) +
+ mem += (MemoryConsumption::memory_consumption(n_block_rows()) +
+ MemoryConsumption::memory_consumption(n_block_cols()) +
MemoryConsumption::memory_consumption(sub_objects) +
MemoryConsumption::memory_consumption(row_indices) +
MemoryConsumption::memory_consumption(column_indices));
- for (size_type r = 0; r < rows; ++r)
- for (size_type c = 0; c < columns; ++c)
+ for (size_type r = 0; r < n_block_rows(); ++r)
+ for (size_type c = 0; c < n_block_cols(); ++c)
mem += MemoryConsumption::memory_consumption(*sub_objects[r][c]);
return mem;