]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Well, do it correctly.
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Apr 2013 18:49:48 +0000 (18:49 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Apr 2013 18:49:48 +0000 (18:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@29221 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/numerics/vector_tools.templates.h

index 33bde2ad2fe09f9060a5f4b946055c9faacd2c58..01b12b9a27307827a051058f1b2bf3116e6d275f 100644 (file)
@@ -5645,18 +5645,14 @@ namespace VectorTools
     Assert(p_select.size() == 0 || p_select.size() == n,
            ExcDimensionMismatch(p_select.size(), n));
 
-    typename VECTOR::value_type s = 0.;
-
     if(p_select.size() == 0)
       {
         // In case of an empty boolean mask operate on the whole vector:
-        for (unsigned int i=0; i<n; ++i)
-          s += v(i);
-
-        v.add(-s/n);
+        v.add( - v.mean_value() );
       }
     else
       {
+        typename VECTOR::value_type s = 0.;
         unsigned int counter = 0;
         for (unsigned int i=0; i<n; ++i)
           if (p_select[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.