* @{
*/
+ /**
+ * Exception
+ */
+ DeclExceptionMsg(
+ ExcNeedsCollectSizes,
+ "The number of rows and columns (returned by n_rows() and n_cols()) does "
+ "not match their directly computed values. This typically means that a "
+ "call to collect_sizes() is missing.");
+
/**
* Exception
*/
BlockIndices column_indices;
private:
+ /**
+ * Internal utility function for computing the number of rows.
+ */
+ size_type
+ compute_n_rows() const;
+
+ /**
+ * Internal utility function for computing the number of columns.
+ */
+ size_type
+ compute_n_cols() const;
+
/**
* Temporary vector for counting the elements written into the individual
* blocks when doing a collective add or set.
ForwardIterator end,
const bool indices_are_sorted)
{
+ // In debug mode, verify that collect_sizes() was called by redoing the
+ // calculation
+ Assert(n_rows() == compute_n_rows(), ExcNeedsCollectSizes());
+ Assert(n_cols() == compute_n_cols(), ExcNeedsCollectSizes());
+
// Resize scratch arrays
if (block_column_indices.size() < this->n_block_cols())
{
+template <class SparsityPatternType>
+typename BlockSparsityPatternBase<SparsityPatternType>::size_type
+BlockSparsityPatternBase<SparsityPatternType>::compute_n_rows() const
+{
+ // only count in first column, since
+ // all rows should be equivalent
+ size_type count = 0;
+ for (size_type r = 0; r < rows; ++r)
+ count += sub_objects[r][0]->n_rows();
+ return count;
+}
+
+
+
+template <class SparsityPatternType>
+typename BlockSparsityPatternBase<SparsityPatternType>::size_type
+BlockSparsityPatternBase<SparsityPatternType>::compute_n_cols() const
+{
+ // only count in first row, since
+ // all rows should be equivalent
+ size_type count = 0;
+ for (size_type c = 0; c < columns; ++c)
+ count += sub_objects[0][c]->n_cols();
+ return count;
+}
+
+
+
template <class SparsityPatternType>
void
BlockSparsityPatternBase<SparsityPatternType>::collect_sizes()
typename BlockSparsityPatternBase<SparsityPatternType>::size_type
BlockSparsityPatternBase<SparsityPatternType>::n_rows() const
{
- // only count in first column, since
- // all rows should be equivalent
- size_type count = 0;
- for (size_type r = 0; r < rows; ++r)
- count += sub_objects[r][0]->n_rows();
- return count;
+ // While trivial for the moment, this will be replaced by a base class
+ // function in a future patch
+ return compute_n_rows();
}
typename BlockSparsityPatternBase<SparsityPatternType>::size_type
BlockSparsityPatternBase<SparsityPatternType>::n_cols() const
{
- // only count in first row, since
- // all rows should be equivalent
- size_type count = 0;
- for (size_type c = 0; c < columns; ++c)
- count += sub_objects[0][c]->n_cols();
- return count;
+ // While trivial for the moment, this will be replaced by a base class
+ // function in a future patch
+ return compute_n_cols();
}