toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN helpers.h


From: Gerhard Reitmayr
Subject: [Toon-members] TooN helpers.h
Date: Tue, 28 Apr 2009 17:19:12 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Gerhard Reitmayr <gerhard>      09/04/28 17:19:11

Modified files:
        .              : helpers.h 

Log message:
        trace of a square matrix

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

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- helpers.h   27 Apr 2009 13:36:32 -0000      1.59
+++ helpers.h   28 Apr 2009 17:19:11 -0000      1.60
@@ -208,5 +208,14 @@
                }
        }
        
+       /// computes the trace of a square matrix
+       template<int Rows, int Cols, typename Precision, typename Base>
+       Precision trace(const Matrix<Rows, Cols, Precision, Base> & m ){
+               SizeMismatch<Rows,Cols>::test(m.num_rows(), m.num_cols());
+               Precision tr = 0;
+               for(int i = 0; i < m.num_rows(); ++i)
+                       tr += m(i,i);
+               return tr;
+       }
 }
 #endif




reply via email to

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