From 9927c343a6ac439655d59037d0e2663b6217295c Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 20 Mar 2024 11:31:14 -0600 Subject: [PATCH] Augment assertions in TrilinosWrappers::*::SparseMatrix::add(). --- include/deal.II/lac/trilinos_tpetra_sparse_matrix.templates.h | 4 ++-- source/lac/trilinos_sparse_matrix.cc | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) 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) { -- 2.39.5