* pattern's lifetime, you will iterate over elements that are not
* valid. If this is so, then this function will return false.
*/
- inline bool is_valid_entry () const;
+ bool is_valid_entry () const;
/**
* iterator can be used to walk over all nonzero entries of the sparsity
* pattern.
*/
- inline iterator begin () const;
+ iterator begin () const;
/**
* Final iterator.
*/
- inline iterator end () const;
+ iterator end () const;
/**
* STL-like iterator with the first entry of row <tt>r</tt>.
* <tt>end(r)</tt>. Note also that the iterator may not be dereferencable in
* that case.
*/
- inline iterator begin (const unsigned int r) const;
+ iterator begin (const unsigned int r) const;
/**
* Final iterator of row <tt>r</tt>. It points to the first element past the
* particular the case if it is the end iterator for the last row of a
* matrix.
*/
- inline iterator end (const unsigned int r) const;
+ iterator end (const unsigned int r) const;
/**
* STL-like iterator with the first entry of row <tt>r</tt>.
* <tt>end(r)</tt>. Note also that the iterator may not be dereferencable in
* that case.
*/
- inline row_iterator row_begin (const unsigned int r) const;
+ row_iterator row_begin (const unsigned int r) const;
/**
* Final iterator of row <tt>r</tt>. It points to the first element past the
* particular the case if it is the end iterator for the last row of a
* matrix.
*/
- inline row_iterator row_end (const unsigned int r) const;
+ row_iterator row_end (const unsigned int r) const;
// @}
/**
* Return number of rows of this matrix, which equals the dimension of the
* image space.
*/
- inline unsigned int n_rows () const;
+ unsigned int n_rows () const;
/**
* Return number of columns of this matrix, which equals the dimension of
* the range space.
*/
- inline unsigned int n_cols () const;
+ unsigned int n_cols () const;
/**
* Number of entries in a specific row.
* yourself, you should also rename this function to avoid programs relying
* on outdated information!
*/
- inline const std::size_t *get_rowstart_indices () const;
+ const std::size_t *get_rowstart_indices () const;
/**
* @deprecated. Use @p row_length and @p column_number instead. Also, using
* yourself, you should also rename this function to avoid programs relying
* on outdated information!
*/
- inline const unsigned int *get_column_numbers () const;
+ const unsigned int *get_column_numbers () const;
BOOST_SERIALIZATION_SPLIT_MEMBER()
/** @addtogroup Exceptions
}
set_matrix_values:
- // fill the values. the same as above: go
- // through all rows of the matrix, and then
- // all columns. since the sparsity patterns of
- // the input matrix and the specified sparsity
- // pattern might be different, need to go
- // through the row for both these sparsity
- // structures simultaneously in order to
- // really set the correct values.
+ // fill the values. the same as above: go through all rows of the matrix,
+ // and then all columns. since the sparsity patterns of the input matrix
+ // and the specified sparsity pattern might be different, need to go
+ // through the row for both these sparsity structures simultaneously in
+ // order to really set the correct values.
const std::size_t *const in_rowstart_indices
= dealii_sparse_matrix.get_sparsity_pattern().get_rowstart_indices();
const unsigned int *const in_cols
unsigned int maximum_row_length = matrix->MaxNumEntries();
std::vector<unsigned int> row_indices (maximum_row_length);
std::vector<TrilinosScalar> values (maximum_row_length);
- std::size_t in_index, index;
for (unsigned int row=0; row<n_rows; ++row)
// see if the row is locally stored on this processor
if (input_row_map.MyGID(static_cast<int>(row)) == true)
{
- index = rowstart_indices[row];
- in_index = in_rowstart_indices[row];
+ ::dealii::SparsityPattern::iterator select_index =
+ sparsity_pattern.begin(row);
+ typename ::dealii::SparseMatrix<number>::const_iterator it =
+ dealii_sparse_matrix.begin(row);
unsigned int col = 0;
if (sparsity_pattern.optimize_diagonal())
{
- values[col] = dealii_sparse_matrix.global_entry(in_index);
- row_indices[col++] = row;
- ++index;
- ++in_index;
+ Assert(dealii_sparse_matrix.get_sparsity_pattern().optimize_diagonal(),
+ ExcMessage("If the manual sparsity pattern optimizes the "
+ "diagonal, the deal.II matrix must optimize it,"
+ " too. And vice versa."));
+ AssertDimension(it->column(), row);
+ values[col] = it->value();
+ row_indices[col++] = it->column();
+ ++select_index;
+ ++it;
}
- while (in_index < in_rowstart_indices[row+1] &&
- index < rowstart_indices[row+1])
+ while (it != dealii_sparse_matrix.end(row) &&
+ select_index != sparsity_pattern.end(row))
{
- while (cols[index] < in_cols[in_index] && index < rowstart_indices[row+1])
- ++index;
- while (in_cols[in_index] < cols[index] && in_index < in_rowstart_indices[row+1])
- ++in_index;
-
- if (std::fabs(dealii_sparse_matrix.global_entry(in_index)) > drop_tolerance)
+ while (select_index->column() < it->column() &&
+ select_index != sparsity_pattern.end(row))
+ ++select_index;
+ while (it->column() < select_index->column() &&
+ it != dealii_sparse_matrix.end(row))
+ ++it;
+
+ if (it == dealii_sparse_matrix.end(row))
+ break;
+ if (std::fabs(it->value()) > drop_tolerance)
{
- values[col] = dealii_sparse_matrix.global_entry(in_index);
- row_indices[col++] = in_cols[in_index];
+ values[col] = it->value();
+ row_indices[col++] = it->column();
}
- ++index;
- ++in_index;
+ ++select_index;
+ ++it;
}
set (row, col, reinterpret_cast<unsigned int *>(&row_indices[0]),
&values[0], false);