From: Wolfgang Bangerth Date: Wed, 17 May 2000 10:52:22 +0000 (+0000) Subject: Make an assertion stronger. Move invariant code out of the loop. X-Git-Tag: v8.0.0~20534 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16e869785f3e02d254b41f029a54a45bd9500661;p=dealii.git Make an assertion stronger. Move invariant code out of the loop. git-svn-id: https://svn.dealii.org/trunk@2871 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index dafa1ac2b7..8f838033f6 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -524,9 +524,24 @@ void MatrixTools::apply_boundary_values (const map &bo const unsigned int *sparsity_rowstart = sparsity.get_rowstart_indices(); const unsigned int *sparsity_colnums = sparsity.get_column_numbers(); + // if a diagonal entry is zero + // later, then we use another + // number instead. take it to be + // the first nonzero diagonal + // element of the matrix, or 1 if + // there is no such thing + double first_nonzero_diagonal_entry = 1; + for (unsigned int i=0; ifirst <= n_dofs, ExcInternalError()); + Assert (dof->first < n_dofs, ExcInternalError()); const unsigned int dof_number = dof->first; // for each boundary dof: @@ -563,20 +578,10 @@ void MatrixTools::apply_boundary_values (const map &bo = dof->second * matrix.diag_element(dof_number); else { - double first_diagonal_entry = 1; - for (unsigned int i=0; i:: as a workaround - // for a bug in egcs - matrix.SparseMatrix::set(dof_number, dof_number, - first_diagonal_entry); + matrix.set (dof_number, dof_number, + first_nonzero_diagonal_entry); new_rhs = right_hand_side(dof_number) - = dof->second * first_diagonal_entry; + = dof->second * first_nonzero_diagonal_entry; }; // store the only nonzero entry