From: David Wells <drwells@email.unc.edu>
Date: Sat, 9 May 2020 19:32:12 +0000 (-0400)
Subject: cppcheck: clean up some loops.
X-Git-Tag: v9.2.0-rc1~60^2~1
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cbc86bc4aa7ad92af2cf2c003656f9fb6815681;p=dealii.git

cppcheck: clean up some loops.
---

diff --git a/include/deal.II/lac/full_matrix.templates.h b/include/deal.II/lac/full_matrix.templates.h
index e5d8726a29..89d051ac24 100644
--- a/include/deal.II/lac/full_matrix.templates.h
+++ b/include/deal.II/lac/full_matrix.templates.h
@@ -137,11 +137,8 @@ FullMatrix<number> &
 FullMatrix<number>::operator*=(const number factor)
 {
   AssertIsFinite(factor);
-
-  number *      p = &(*this)(0, 0);
-  const number *e = &(*this)(0, 0) + n() * m();
-  while (p != e)
-    *p++ *= factor;
+  for (number &v : this->values)
+    v *= factor;
 
   return *this;
 }
@@ -153,18 +150,9 @@ FullMatrix<number> &
 FullMatrix<number>::operator/=(const number factor)
 {
   AssertIsFinite(factor);
-
-  number *      p = &(*this)(0, 0);
-  const number *e = &(*this)(0, 0) + n() * m();
-
   const number factor_inv = number(1.) / factor;
 
-  AssertIsFinite(factor_inv);
-
-  while (p != e)
-    *p++ *= factor_inv;
-
-  return *this;
+  return *this *= factor_inv;
 }
 
 
@@ -187,7 +175,7 @@ FullMatrix<number>::vmult(Vector<number2> &      dst,
   // get access to the data in order to
   // avoid copying it when using the ()
   // operator
-  const number2 * src_ptr = &(*const_cast<Vector<number2> *>(&src))(0);
+  const number2 * src_ptr = src.begin();
   const size_type size_m = m(), size_n = n();
   for (size_type i = 0; i < size_m; ++i)
     {