n_nonzero_elements() const;
/**
- * Number of entries in a specific row.
+ * Return the number of entries in the given row.
+ *
+ * In a parallel context, the row in question may of course not be
+ * stored on the current processor, and in that case it is not
+ * possible to query the number of entries in it. In that case,
+ * the returned value is `static_cast<size_type>(-1)`.
*/
size_type
row_length(const size_type row) const;
{
Assert(row < n_rows(), ExcInternalError());
- // get a representation of the
- // present row
- TrilinosWrappers::types::int_type ncols = -1;
+ // Get a representation of the where the present row is located on
+ // the current processor
TrilinosWrappers::types::int_type local_row =
graph->LRID(static_cast<TrilinosWrappers::types::int_type>(row));
- // on the processor who owns this
- // row, we'll have a non-negative
- // value.
+ // On the processor who owns this row, we'll have a non-negative
+ // value for `local_row` and can ask for the length of the row.
if (local_row >= 0)
- ncols = graph->NumMyIndices(local_row);
-
- return static_cast<size_type>(ncols);
+ return graph->NumMyIndices(local_row);
+ else
+ return static_cast<size_type>(-1);
}