]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Reduce the scope of some variables.
authorDavid Wells <wellsd2@rpi.edu>
Sat, 27 Jan 2018 18:24:47 +0000 (13:24 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Sat, 27 Jan 2018 22:47:58 +0000 (17:47 -0500)
This was found by cppcheck.

include/deal.II/lac/utilities.h
source/base/quadrature_lib.cc

index f7689437eaf9d575d1aa40426be4207f35a2d2ad..1b0496e652ece5a26fa463522bfb8c7cf3dba47e 100644 (file)
@@ -328,12 +328,9 @@ namespace Utilities
       std::vector<double> diagonal;
       std::vector<double> subdiagonal;
 
-      // scalars to store norms and inner products
-      double a = 0, b = 0;
-
       // 1. Normalize input vector
       (*v) = v0_;
-      a = v->l2_norm();
+      double a = v->l2_norm();
       Assert (a!=0, ExcDivideByZero());
       (*v) *= 1./a;
 
@@ -347,7 +344,7 @@ namespace Utilities
       for (unsigned int i = 1; i < k; ++i)
         {
           // 4. L2 norm of f
-          b = f->l2_norm();
+          const double b = f->l2_norm();
           Assert (b!=0, ExcDivideByZero());
           // 5. v0 <- v; v <- f/b
           *v0 = *v;
index 37eaf86d264a33551fb9a1d0938fb1669a07abbf..48be55bfffb210d23205516a03f44eb14e0eb141 100644 (file)
@@ -268,7 +268,6 @@ compute_quadrature_weights(const std::vector<long double> &x,
 {
   const unsigned int q = x.size();
   std::vector<long double> w(q);
-  long double s = 0.L;
 
   const long double factor = std::pow(2., alpha+beta+1) *
                              gamma(alpha+q) *
@@ -276,7 +275,7 @@ compute_quadrature_weights(const std::vector<long double> &x,
                              ((q-1)*gamma(q)*gamma(alpha+beta+q+1));
   for (unsigned int i=0; i<q; ++i)
     {
-      s = JacobiP(x[i], alpha, beta, q-1);
+      const long double s = JacobiP(x[i], alpha, beta, q-1);
       w[i] = factor/(s*s);
     }
   w[0]   *= (beta + 1);

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.