From: Wasim Niyaz Munshi Date: Tue, 4 Feb 2025 23:44:00 +0000 (-0700) Subject: Add checks that src is not equal to dst in mmult(). X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f683cc276cd82f33d2f707bdf567db1f871beeb0;p=dealii.git Add checks that src is not equal to dst in mmult(). --- diff --git a/include/deal.II/lac/full_matrix.templates.h b/include/deal.II/lac/full_matrix.templates.h index e6a01a9ae1..8fe9efd0b9 100644 --- a/include/deal.II/lac/full_matrix.templates.h +++ b/include/deal.II/lac/full_matrix.templates.h @@ -519,10 +519,19 @@ FullMatrix::mmult(FullMatrix &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) + { + 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::max(); if ((std::is_same_v ||