From: Wolfgang Bangerth Date: Wed, 20 Mar 2024 17:31:14 +0000 (-0600) Subject: Augment assertions in TrilinosWrappers::*::SparseMatrix::add(). X-Git-Tag: v9.6.0-rc1~467^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16766%2Fhead;p=dealii.git Augment assertions in TrilinosWrappers::*::SparseMatrix::add(). --- diff --git a/include/deal.II/lac/trilinos_tpetra_sparse_matrix.templates.h b/include/deal.II/lac/trilinos_tpetra_sparse_matrix.templates.h index 59914a70cf..8d1e237a1e 100644 --- a/include/deal.II/lac/trilinos_tpetra_sparse_matrix.templates.h +++ b/include/deal.II/lac/trilinos_tpetra_sparse_matrix.templates.h @@ -1114,6 +1114,8 @@ namespace LinearAlgebra const bool /*col_indices_are_sorted*/) { AssertIndexRange(row, this->m()); + for (size_t n = 0; n < n_cols; ++n) + AssertIndexRange(col_indices[n], this->n()); // If the matrix is marked as compressed, we need to // call resumeFill() first. @@ -1145,7 +1147,6 @@ namespace LinearAlgebra if (values[i] != 0) { AssertIsFinite(values[i]); - AssertIndexRange(col_indices[i], n()); AssertIndexRange(n_columns, n_zero_entries); col_indices_array[n_columns] = col_indices[i]; values_array[n_columns] = values[i]; @@ -1157,7 +1158,6 @@ namespace LinearAlgebra for (size_t i = 0; i < n_cols; ++i) { AssertIsFinite(values[i]); - AssertIndexRange(col_indices[i], n()); col_indices_array[i] = col_indices[i]; values_array[i] = values[i]; } diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index 6341c867f2..1902bcf489 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -1599,6 +1599,9 @@ namespace TrilinosWrappers const bool /*col_indices_are_sorted*/) { AssertIndexRange(row, this->m()); + for (size_type n = 0; n < n_cols; ++n) + AssertIndexRange(col_indices[n], this->n()); + int ierr; if (last_action == Insert) {