toon-members
[Top][All Lists]

## [Toon-members] TooN helpers.h

 From: Edward Rosten Subject: [Toon-members] TooN helpers.h Date: Wed, 16 Dec 2009 16:44:14 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/12/16 16:44:14

Modified files:
.              : helpers.h

Log message:
Vector infinity norm.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/helpers.h?cvsroot=toon&r1=1.88&r2=1.89

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- helpers.h   7 Dec 2009 16:54:55 -0000       1.88
+++ helpers.h   16 Dec 2009 16:44:14 -0000      1.89
@@ -35,6 +35,7 @@
#include <TooN/TooN.h>
#include <cmath>
#include <functional>
+#include <utility>

#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -92,6 +93,21 @@
return n;
}

+       ///Compute the \f$L_\infty\f$ norm of \e v
+       ///@param v \e v
+       ///@ingroup gLinAlg
+       template<int Size, class Precision, class Base> inline Precision
norm_inf(const Vector<Size, Precision, Base>& v)
+       {
+               using std::abs;
+               using std::max;
+               Precision n = 0;
+               n = abs(v[0]);
+
+               for(int i=1; i < v.size(); i++)
+                       n = max(n, abs(v[i]));
+               return n;
+       }
+
///Compute the \f$L_2\f$ norm of \e v.
///Synonym for norm()
///@param v \e v



reply via email to