From ecdaae05737ba43db68da3974c6f0b2fb0313763 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Wed, 8 Sep 2010 15:50:11 +0000 Subject: [PATCH] Fix adding of several elements. git-svn-id: https://svn.dealii.org/trunk@21889 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/sparse_matrix.templates.h | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index faaf4ea460..fa50806a87 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -410,11 +410,12 @@ SparseMatrix::add (const unsigned int row, #ifdef DEBUG for (unsigned int i=1; i col_indices[i-1], - ExcMessage("List of indices not sorted or with duplicates.")); + ExcMessage("List of indices is unsorted or contains duplicates.")); #endif const unsigned int * this_cols = &cols->get_column_numbers()[cols->get_rowstart_indices()[row]]; + const unsigned int row_length = cols->row_length(row); number * val_ptr = &val[cols->get_rowstart_indices()[row]]; if (cols->optimize_diagonal() == true) @@ -438,9 +439,8 @@ SparseMatrix::add (const unsigned int row, unsigned int counter = 1; for (unsigned int i=0; i= this_cols[counter], ExcInternalError()); - - while (this_cols[counter] < col_indices[i]) + while (this_cols[counter] < col_indices[i] && + this_cols[counter] < row_length) ++counter; Assert (this_cols[counter] == col_indices[i] || values[i] == 0, @@ -452,9 +452,8 @@ SparseMatrix::add (const unsigned int row, // add indices after diagonal for (unsigned int i=post_diag; i= this_cols[counter], ExcInternalError()); - - while (this_cols[counter] < col_indices[i]) + while (this_cols[counter] < col_indices[i] && + this_cols[counter] < row_length) ++counter; Assert (this_cols[counter] == col_indices[i] || values[i] == 0, @@ -463,16 +462,16 @@ SparseMatrix::add (const unsigned int row, val_ptr[counter] += values[i]; } - Assert (counter < cols->row_length(row), ExcInternalError()); + Assert (counter < cols->row_length(row), + ExcMessage("Specified invalid column indices in add function.")); } else { unsigned int counter = 0; for (unsigned int i=0; i= this_cols[counter], ExcInternalError()); - - while (this_cols[counter] < col_indices[i]) + while (this_cols[counter] < col_indices[i] && + this_cols[counter] < row_length) ++counter; Assert (this_cols[counter] == col_indices[i] || values[i] == 0, @@ -480,7 +479,8 @@ SparseMatrix::add (const unsigned int row, val_ptr[counter] += values[i]; } - Assert (counter < cols->row_length(row), ExcInternalError()); + Assert (counter < cols->row_length(row), + ExcMessage("Specified invalid column indices in add function.")); } return; } -- 2.39.5