From 1cbc86bc4aa7ad92af2cf2c003656f9fb6815681 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 9 May 2020 15:32:12 -0400 Subject: [PATCH] cppcheck: clean up some loops. --- include/deal.II/lac/full_matrix.templates.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) 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 & FullMatrix::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 & FullMatrix::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::vmult(Vector & dst, // get access to the data in order to // avoid copying it when using the () // operator - const number2 * src_ptr = &(*const_cast *>(&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) { -- 2.39.5