toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN helpers.h


From: Edward Rosten
Subject: [Toon-members] TooN helpers.h
Date: Mon, 07 Dec 2009 10:44:25 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/12/07 10:44:25

Modified files:
        .              : helpers.h 

Log message:
        norm_1 for vectors. Also add norm_2 as a synonym for norm, to give more
        consistency in naming.

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

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- helpers.h   3 Dec 2009 20:14:48 -0000       1.86
+++ helpers.h   7 Dec 2009 10:44:25 -0000       1.87
@@ -79,6 +79,29 @@
                return v*v;
        }
 
+       ///Compute the \f$L_1\f$ norm of \e v
+       ///@param v \e v
+       ///@ingroup gLinAlg
+       template<int Size, class Precision, class Base> inline Precision 
norm_1(const Vector<Size, Precision, Base>& v)
+       {
+               using std::abs;
+               Precision n = 0;
+               for(int i=0; i < v.size(); i++)
+                       n += abs(v[i]);
+               return n;
+       }
+       
+       ///Compute the \f$L_2\f$ norm of \e v.
+       ///Synonym for norm()
+       ///@param v \e v
+       ///@ingroup gLinAlg
+       template<int Size, class Precision, class Base> inline Precision 
norm_2(const Vector<Size, Precision, Base>& v)
+       {
+               return norm(v);
+       }
+       
+
+
 
        ///Compute a the unit vector \f$\hat{v}\f$.
        ///@param v \e v




reply via email to

[Prev in Thread] Current Thread [Next in Thread]