]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add some missing assertions. 16677/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 19 Feb 2024 23:15:59 +0000 (16:15 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 19 Feb 2024 23:15:59 +0000 (16:15 -0700)
include/deal.II/lac/trilinos_tpetra_sparse_matrix.templates.h
source/lac/petsc_matrix_base.cc
source/lac/trilinos_sparse_matrix.cc

index 9c20d527134bc58b25f425b71fb8650289f76bcd..e9701d5a2394f99fb772dcfd532a4244b94fa6cf 100644 (file)
@@ -806,6 +806,7 @@ namespace LinearAlgebra
     SparseMatrix<Number, MemorySpace>::matrix_norm_square(
       const Vector<Number, MemorySpace> &v) const
     {
+      AssertDimension(m(), v.size());
       Assert(matrix->isFillComplete(), ExcMatrixNotCompressed());
       Assert(matrix->getRowMap()->isSameAs(*matrix->getDomainMap()),
              ExcNotQuadratic());
@@ -825,6 +826,8 @@ namespace LinearAlgebra
       const Vector<Number, MemorySpace> &u,
       const Vector<Number, MemorySpace> &v) const
     {
+      AssertDimension(m(), u.size());
+      AssertDimension(m(), v.size());
       Assert(matrix->isFillComplete(), ExcMatrixNotCompressed());
       Assert(matrix->getRowMap()->isSameAs(*matrix->getDomainMap()),
              ExcNotQuadratic());
index 2475988e230b306aa4eb604e473f96109c7f06d0..c1a8b98a61abff6bb409812063db408e52d3e1ae 100644 (file)
@@ -457,6 +457,8 @@ namespace PETScWrappers
   PetscScalar
   MatrixBase::matrix_norm_square(const VectorBase &v) const
   {
+    AssertDimension(m(), v.size());
+
     VectorBase tmp(v);
     vmult(tmp, v);
     return tmp * v;
@@ -467,6 +469,9 @@ namespace PETScWrappers
   MatrixBase::matrix_scalar_product(const VectorBase &u,
                                     const VectorBase &v) const
   {
+    AssertDimension(m(), u.size());
+    AssertDimension(m(), v.size());
+
     VectorBase tmp(u);
     vmult(tmp, v);
     return u * tmp;
index ef9cedaa836cfe04d2753dd08d9971e91a3741f6..06aeb03030b1445f717002700a9f3b01a789f94f 100644 (file)
@@ -2101,6 +2101,7 @@ namespace TrilinosWrappers
   TrilinosScalar
   SparseMatrix::matrix_norm_square(const MPI::Vector &v) const
   {
+    AssertDimension(m(), v.size());
     Assert(matrix->RowMap().SameAs(matrix->DomainMap()), ExcNotQuadratic());
 
     MPI::Vector temp_vector;
@@ -2116,6 +2117,8 @@ namespace TrilinosWrappers
   SparseMatrix::matrix_scalar_product(const MPI::Vector &u,
                                       const MPI::Vector &v) const
   {
+    AssertDimension(m(), u.size());
+    AssertDimension(m(), v.size());
     Assert(matrix->RowMap().SameAs(matrix->DomainMap()), ExcNotQuadratic());
 
     MPI::Vector temp_vector;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.