From: Wolfgang Bangerth Date: Mon, 7 Jan 2013 04:35:12 +0000 (+0000) Subject: Avoid use of SparseMatrix::global_entry in one more place. Many more to come. X-Git-Tag: v8.0.0~1645 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d9eda55540f95a3a16f00c0db8fb8cab6cf4d32;p=dealii.git Avoid use of SparseMatrix::global_entry in one more place. Many more to come. git-svn-id: https://svn.dealii.org/trunk@27956 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/numerics/matrix_tools.cc b/deal.II/source/numerics/matrix_tools.cc index 16eaf0ff75..ac21e24c72 100644 --- a/deal.II/source/numerics/matrix_tools.cc +++ b/deal.II/source/numerics/matrix_tools.cc @@ -1929,6 +1929,15 @@ namespace MatrixCreator namespace MatrixTools { + namespace + { + template + bool column_less_than(const typename Iterator::value_type &p, + const unsigned int column) + { + return (p.column() < column); + } + }; //TODO:[WB] I don't think that the optimized storage of diagonals is needed (GK) template @@ -2048,18 +2057,20 @@ namespace MatrixTools // since that is the // diagonal element and // thus the present row - const unsigned int last = sparsity_rowstart[dof_number+1]; - for (unsigned int j=sparsity_rowstart[dof_number]+1; j::iterator + q = matrix.begin(dof_number)++; + q != matrix.end(dof_number); ++q) { - const unsigned int row = sparsity_colnums[j]; + const unsigned int row = q->column(); // find the position of // element // (row,dof_number) - const unsigned int * - p = Utilities::lower_bound(&sparsity_colnums[sparsity_rowstart[row]+1], - &sparsity_colnums[sparsity_rowstart[row+1]], - dof_number); + const typename SparseMatrix::iterator + p = Utilities::lower_bound(matrix.begin(row)++, + matrix.end(row), + dof_number, + &column_less_than::iterator>); // check whether this line has // an entry in the regarding column @@ -2070,19 +2081,17 @@ namespace MatrixTools // to dof_number anyway...) // // there should be such an entry! - Assert ((*p == dof_number) && - (p != &sparsity_colnums[sparsity_rowstart[row+1]]), + Assert ((p != matrix.end(row)) + && + (p->column() == dof_number), ExcInternalError()); - const unsigned int global_entry - = (p - &sparsity_colnums[sparsity_rowstart[0]]); - // correct right hand side - right_hand_side(row) -= matrix.global_entry(global_entry) / + right_hand_side(row) -= p->value() / diagonal_entry * new_rhs; // set matrix entry to zero - matrix.global_entry(global_entry) = 0.; + q->value() = 0.; } }