]> https://gitweb.dealii.org/ - dealii.git/commitdiff
cppcheck: clean up some loops.
authorDavid Wells <drwells@email.unc.edu>
Sat, 9 May 2020 19:32:12 +0000 (15:32 -0400)
committerDavid Wells <drwells@email.unc.edu>
Sat, 9 May 2020 23:24:48 +0000 (19:24 -0400)
include/deal.II/lac/full_matrix.templates.h

index e5d8726a29483ca046ea38b9fca040d9ed14786e..89d051ac2464d4057bf090fbd53033ff269ab87d 100644 (file)
@@ -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)
     {

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.