From: Bruno Turcksin Date: Tue, 3 May 2016 17:45:14 +0000 (-0400) Subject: Use constant variable for end value of for loop. X-Git-Tag: v8.5.0-rc1~1048^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed0d9b83e5f1c222ae46a7cc7f6bec0576d86043;p=dealii.git Use constant variable for end value of for loop. --- diff --git a/include/deal.II/lac/la_vector.h b/include/deal.II/lac/la_vector.h index e14c508fbe..c89eb06094 100644 --- a/include/deal.II/lac/la_vector.h +++ b/include/deal.II/lac/la_vector.h @@ -383,7 +383,8 @@ namespace LinearAlgebra void Vector::add(const Number a) { AssertIsFinite(a); - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i] += a; } @@ -424,7 +425,7 @@ namespace LinearAlgebra inline void Vector::serialize(Archive &ar, const unsigned int) { - unsigned int current_size = this->size(); + size_type current_size = this->size(); ar &static_cast(*this); ar &this->stored_elements; // If necessary, resize the vector during a read operation diff --git a/include/deal.II/lac/la_vector.templates.h b/include/deal.II/lac/la_vector.templates.h index de99473af3..5743151a64 100644 --- a/include/deal.II/lac/la_vector.templates.h +++ b/include/deal.II/lac/la_vector.templates.h @@ -28,7 +28,8 @@ namespace LinearAlgebra Vector &Vector::operator*= (const Number factor) { AssertIsFinite(factor); - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i] *= factor; return *this; @@ -58,7 +59,8 @@ namespace LinearAlgebra const Vector &down_V = dynamic_cast&>(V); Assert(down_V.size()==this->size(), ExcMessage("Cannot add two vectors with different numbers of elements")); - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i] += down_V[i]; @@ -79,7 +81,8 @@ namespace LinearAlgebra const Vector &down_V = dynamic_cast&>(V); Assert(down_V.size()==this->size(), ExcMessage("Cannot subtract two vectors with different numbers of elements")); - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i] -= down_V[i]; @@ -102,8 +105,9 @@ namespace LinearAlgebra Assert(down_V.size()==this->size(), ExcMessage("Cannot compute the scalar product " "of two vectors with different numbers of elements")); + const size_type size = this->size(); Number value = 0.; - for (unsigned int i=0; isize(); ++i) + for (size_type i=0; ival[i]*down_V[i]; @@ -136,7 +140,8 @@ namespace LinearAlgebra AssertIsFinite(a); Assert(down_V.size()==this->size(), ExcMessage("Cannot add two vectors with different numbers of elements")); - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i] += a*down_V[i]; @@ -166,7 +171,8 @@ namespace LinearAlgebra AssertIsFinite(b); Assert(down_W.size()==this->size(), ExcMessage("Cannot add two vectors with different numbers of elements")); - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; i&>(scaling_factors); Assert(down_scaling_factors.size()==this->size(), ExcMessage("Cannot add two vectors with different numbers of elements")); - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i] *= down_scaling_factors[i]; @@ -264,7 +271,8 @@ namespace LinearAlgebra { real_type scale = 0.; real_type sum = 1.; - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i] != Number()) { @@ -290,7 +298,8 @@ namespace LinearAlgebra typename VectorSpaceVector::real_type Vector::linfty_norm() const { typename ReadWriteVector::real_type norm = 0.; - for (unsigned int i=0; isize(); ++i) + const size_type size = this->size(); + for (size_type i=0; ival[i]),norm); return norm;