]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add checks that src is not equal to dst in mmult().
authorWasim Niyaz Munshi <munshiw0@gmail.com>
Tue, 4 Feb 2025 23:44:00 +0000 (16:44 -0700)
committerWasim Niyaz Munshi <munshiw0@gmail.com>
Tue, 4 Feb 2025 23:44:00 +0000 (16:44 -0700)
include/deal.II/lac/full_matrix.templates.h

index e6a01a9ae136032b4e2559439552b8a06ff21095..8fe9efd0b9d22f0a2610d44f23607d80f93b8be8 100644 (file)
@@ -519,10 +519,19 @@ FullMatrix<number>::mmult(FullMatrix<number2>       &dst,
   Assert(n() == src.m(), ExcDimensionMismatch(n(), src.m()));
   Assert(dst.n() == src.n(), ExcDimensionMismatch(dst.n(), src.n()));
   Assert(dst.m() == m(), ExcDimensionMismatch(m(), dst.m()));
+  if constexpr (std::is_same_v<number, number2>)
+    {
+      Assert(&dst != this,
+             ExcMessage(
+               "The output matrix cannot be the same as the current matrix."));
+      Assert(&dst != &src,
+             ExcMessage(
+               "The output matrix cannot be the same as the input matrix."));
+    }
 
-  // see if we can use BLAS algorithms for this and if the type for 'number'
-  // works for us (it is usually not efficient to use BLAS for very small
-  // matrices):
+    // see if we can use BLAS algorithms for this and if the type for 'number'
+    // works for us (it is usually not efficient to use BLAS for very small
+    // matrices):
 #ifdef DEAL_II_WITH_LAPACK
   const size_type max_blas_int = std::numeric_limits<types::blas_int>::max();
   if ((std::is_same_v<number, double> ||

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.