/**
* Compute the matrix representation of a linear operator (@p matrix), given
- * @p matrix_free and the local cell integral operation @p local_vmult. The
- * vector is initialized to the right size in the function.
+ * @p matrix_free and the local cell integral operation @p local_vmult.
+ * Constrained entries on the diagonal are set to one.
*
* The parameters @p dof_no, @p quad_no, and @p first_selected_component are
* passed to the constructor of the FEEvaluation that is internally set up.
matrix.compress(VectorOperation::add);
- for (unsigned int i = 0; i < matrix.m(); ++i)
- if (matrix.get_row_length(i) > 0 && matrix(i, i) == 0.0 &&
- constraints.is_constrained(i))
- matrix.add(i, i, 1);
+ for (auto &entry : matrix)
+ if (entry.row() == entry.column() && entry.value() == 0.0)
+ {
+ Assert(constraints.is_constrained(entry.row()), ExcNotImplemented());
+ entry.value() = 1.0;
+ }
}
template <typename CLASS,