#include <deal.II/lac/block_indices.h>
#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/sparsity_pattern_base.h>
#include <deal.II/lac/trilinos_sparsity_pattern.h>
DEAL_II_NAMESPACE_OPEN
* @ref GlossBlockLA "Block (linear algebra)"
*/
template <typename SparsityPatternType>
-class BlockSparsityPatternBase : public Subscriptor
+class BlockSparsityPatternBase : public SparsityPatternBase
{
public:
/**
ForwardIterator end,
const bool indices_are_sorted = false);
+ /**
+ * Add several nonzero entries to the specified matrix row. This function may
+ * only be called for non-compressed sparsity patterns and works the same way
+ * as the overload which takes iterators.
+ */
+ virtual void
+ add_row_entries(const size_type & row,
+ const ArrayView<const size_type> &columns,
+ const bool indices_are_sorted = false) override;
+
+ virtual void
+ add_entries(const ArrayView<const size_type> &rows,
+ const ArrayView<const size_type> &columns) override;
+
/**
* Return number of rows of this matrix, which equals the dimension of the
* image space. It is the sum of rows of the (block-)rows of sub-matrices.
*/
- size_type
- n_rows() const;
+ using SparsityPatternBase::n_rows;
/**
* Return number of columns of this matrix, which equals the dimension of
* the range space. It is the sum of columns of the (block-)columns of sub-
* matrices.
*/
- size_type
- n_cols() const;
+ using SparsityPatternBase::n_cols;
/**
* Check if a value at a certain position may be non-zero.
+template <typename SparsityPatternType>
+void
+BlockSparsityPatternBase<SparsityPatternType>::add_row_entries(
+ const size_type & row,
+ const ArrayView<const size_type> &columns,
+ const bool indices_are_sorted)
+{
+ add_entries(row, columns.begin(), columns.end(), indices_are_sorted);
+}
+
+
+
+template <typename SparsityPatternType>
+inline void
+BlockSparsityPatternBase<SparsityPatternType>::add_entries(
+ const ArrayView<const size_type> &rows,
+ const ArrayView<const size_type> &columns)
+{
+ AssertDimension(rows.size(), columns.size());
+ for (std::size_t i = 0; i < rows.size(); ++i)
+ add(rows[i], columns[i]);
+}
+
+
+
template <typename SparsityPatternType>
inline bool
BlockSparsityPatternBase<SparsityPatternType>::exists(const size_type i,
void
BlockSparsityPatternBase<SparsityPatternType>::collect_sizes()
{
+ SparsityPatternBase::resize(compute_n_rows(), compute_n_cols());
+
std::vector<size_type> row_sizes(n_block_rows());
std::vector<size_type> col_sizes(n_block_cols());
-template <class SparsityPatternType>
-typename BlockSparsityPatternBase<SparsityPatternType>::size_type
-BlockSparsityPatternBase<SparsityPatternType>::n_rows() const
-{
- // While trivial for the moment, this will be replaced by a base class
- // function in a future patch
- return compute_n_rows();
-}
-
-
-
-template <class SparsityPatternType>
-typename BlockSparsityPatternBase<SparsityPatternType>::size_type
-BlockSparsityPatternBase<SparsityPatternType>::n_cols() const
-{
- // While trivial for the moment, this will be replaced by a base class
- // function in a future patch
- return compute_n_cols();
-}
-
-
-
template <class SparsityPatternType>
typename BlockSparsityPatternBase<SparsityPatternType>::size_type
BlockSparsityPatternBase<SparsityPatternType>::n_nonzero_elements() const