]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Lp-norms
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Aug 2002 19:54:28 +0000 (19:54 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 Aug 2002 19:54:28 +0000 (19:54 +0000)
git-svn-id: https://svn.dealii.org/trunk@6316 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/2002/c-3-4.html
deal.II/lac/include/lac/vector.h
deal.II/lac/include/lac/vector.templates.h

index d410b923197e414035caac634f840d42e91aa30f..9b90c33a9c40984a4b2e1d4987e7dbebbd1f83c4 100644 (file)
@@ -153,6 +153,15 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p> Improved: <code class="class">VectorTools</code>::<code
+  class="member">integrate_difference</code> can compute <i>L<sup>p</sup></i>
+  and <i>W<sup>1,p</sup></i> norms for arbitrary <i>p</i>. The function
+  receives an additional optional argument <i>p</i> for this. All previous
+  fuctionality remains unchanged, although the code has been cleaned up a bit.
+  <br>
+  (GK 2002/08/01)
+  </p>
+
   <li> <p> New: The <code class="class">GridTools</code> class now
        offers functions to apply general transformations to all
        vertices of a triangulation, and also more specialized
index 5fd37c96f6fc9c2d7624581c21d9748e04536ed9..54a50402b5eefae118ffaa58bc1876628ab44d08 100644 (file)
@@ -229,28 +229,35 @@ class Vector
     Number norm_sqr () const;
 
                                     /**
-                                     * Return the mean value of the elements of
+                                     * Mean value of the elements of
                                      * this vector.
                                      */
     Number mean_value () const;
 
                                     /**
-                                     * Return the $l_1$-norm of the vector, i.e.
-                                     * the sum of the absolute values.
+                                     * $l_1$-norm of the vector.
+                                     * The sum of the absolute values.
                                      */
     Number l1_norm () const;
 
                                     /**
-                                     * Return the $l_2$-norm of the vector, i.e.
-                                     * the square root of the sum of the
+                                     * $l_2$-norm of the vector.  The
+                                     * square root of the sum of the
                                      * squares of the elements.
                                      */
     Number l2_norm () const;
 
                                     /**
-                                     * Return the maximum absolute value of the
-                                     * elements of this vector, which is the
-                                     * $l_\infty$-norm of a vector.
+                                     * $l_p$-norm of the vector. The
+                                     * pth root of the sum of the pth
+                                     * powers of the absolute values
+                                     * of the elements.
+                                     */
+    Number lp_norm (double p) const;
+
+                                    /**
+                                     * Maximum absolute value of the
+                                     * elements.
                                      */
     Number linfty_norm () const;
 
index 36f400ec2fedf00464544ebd28374447f6e52f1a..793ee1690a7f7428d111b41ba5fbe64d98ad269d 100644 (file)
@@ -239,6 +239,36 @@ Number Vector<Number>::l2_norm () const
 };
 
 
+template <typename Number>
+Number Vector<Number>::lp_norm (double p) const
+{
+  Assert (dim!=0, ExcEmptyVector());
+
+  Number sum0 = 0,
+        sum1 = 0,
+        sum2 = 0,
+        sum3 = 0;
+
+                                  // use modern processors better by
+                                  // allowing pipelined commands to be
+                                  // executed in parallel
+  const_iterator ptr  = begin(),
+                eptr = ptr + (dim/4)*4;
+  while (ptr!=eptr)
+    {
+      sum0 += std::pow(std::fabs(*ptr++), p);
+      sum1 += std::pow(std::fabs(*ptr++), p);
+      sum2 += std::pow(std::fabs(*ptr++), p);
+      sum3 += std::pow(std::fabs(*ptr++), p);
+    };
+                                  // add up remaining elements
+  while (ptr != end())
+    sum0 += pow(std::fabs(*ptr++), p);
+  
+  return pow(sum0+sum1+sum2+sum3, 1./p);
+};
+
+
 template <typename Number>
 Number Vector<Number>::linfty_norm () const {
   Assert (dim!=0, ExcEmptyVector());

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.