]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add some norms to the dVector class.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 7 Apr 1998 14:04:47 +0000 (14:04 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 7 Apr 1998 14:04:47 +0000 (14:04 +0000)
git-svn-id: https://svn.dealii.org/trunk@153 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/dvector.h
deal.II/lac/source/dvector.cc

index 33a08d319b8ad92151f6c2340b3f8288f7dc1a9d..c593ca6e75a5c1b9218f7fcd2f2eeb2d316f9b5d 100644 (file)
@@ -117,6 +117,12 @@ class dVector : public VectorBase
                                      * squares of the elements.
                                      */
     double l2_norm () const;
+
+                                    /**
+                                     * Return the maximum absolute value of the
+                                     * elements of this vector.
+                                     */
+    double linfty_norm () const;
     
     
                                     /**
index 9ede32ce1bf09040a973ae0e442f64106387b48d..57de9513011c85df52d3920330b3435cc659bb1e 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <lac/dvector.h>
 #include <math.h>
+#include <algo.h>
 
 dVector::dVector () :
                dim(0),
@@ -226,6 +227,30 @@ double dVector::l2_norm () const
 
 
 
+double dVector::linfty_norm () const {
+  double max0=0.,
+        max1=0.,
+        max2=0.,
+        max3=0.;
+  for (unsigned int i=0; i<(dim/4); ++i) 
+    {
+      if (max0<fabs(val[4*i]))   max0=fabs(val[4*i]);
+      if (max1<fabs(val[4*i+1])) max1=fabs(val[4*i+1]);
+      if (max2<fabs(val[4*i+2])) max2=fabs(val[4*i+2]);
+      if (max3<fabs(val[4*i+3])) max3=fabs(val[4*i+3]);
+    };
+                                  // add up remaining elements
+  for (unsigned int i=(dim/4)*4; i<dim; ++i)
+    if (max0<val[i])
+      max0 = val[i];
+
+  return max (max(max0, max1),
+             max(max2, max3));
+};
+  
+
+
+
 
 
 void dVector::add (const double v)

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.