toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN helpers.h


From: Tom Drummond
Subject: [Toon-members] TooN helpers.h
Date: Wed, 25 Mar 2009 21:33:37 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Tom Drummond <twd20>    09/03/25 21:33:37

Modified files:
        .              : helpers.h 

Log message:
        Zero converted to operator object

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

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- helpers.h   25 Mar 2009 21:24:20 -0000      1.30
+++ helpers.h   25 Mar 2009 21:33:37 -0000      1.31
@@ -26,20 +26,6 @@
 namespace TooN {
 
 
-template<int Size, class Precision, class Base> void Zero(Vector<Size, 
Precision, Base>& v)
-{
-       for(int i=0; i < v.size(); i++)
-                       v[i]= 0;
-}
-
-template<int Rows, int Cols, class Precision, class Base> void 
Zero(Matrix<Rows, Cols, Precision, Base>& m)
-{
-       for(int i=0; i < m.num_rows(); i++)
-               for(int j=0; j < m.num_cols(); j++)
-                       m[i][j] = 0;
-}
-
-
 template<int Size, class Precision, class Base> void Fill(Vector<Size, 
Precision, Base>& v, const Precision& p)
 {
        for(int i=0; i < v.size(); i++)
@@ -61,33 +47,44 @@
 
 namespace Internal{
 
-struct Identity
-{
-       template<int R, int C, class P, class B> static void eval(Matrix<R, C, 
P, B>& m)
-       {
+       struct Zero {
+               template<int R, int C, class P, class B>
+                       static void eval(Matrix<R, C, P, B>& m) {
+                       for(int r=0; r < m.num_rows(); r++) {
+                               for(int c=0; c < m.num_rows(); c++) {
+                                       m[r][c] = 0;
+                               }
+                       }
+               }
+
+               template<int Size, class Precision, class Base>
+                       static void eval(Vector<Size, Precision, Base>& v) {
+                       for(int i=0; i < v.size(); i++) {
+                               v[i]= 0;
+                       }
+               }
+       };
+
+       struct Identity {
+               template<int R, int C, class P, class B> static void 
eval(Matrix<R, C, P, B>& m) {
                SizeMismatch<R, C>::test(m.num_rows(), m.num_cols());
 
-               for(int r=0; r < m.num_rows(); r++)
-                 for(int c=0; c < m.num_rows(); c++)
+                       for(int r=0; r < m.num_rows(); r++) {
+                               for(int c=0; c < m.num_rows(); c++) {
                        m[r][c] = 0;
+                               }
+                       }
 
-               for(int i=0; i < m.num_rows(); i++)
+                       for(int i=0; i < m.num_rows(); i++) {
                        m[i][i] = 1;
        }
-};
-
-struct Fill
-{
-       template<int R, int C, class P, class B, class Data> static void 
eval(Matrix<R, C, P, B>& m, const Data * data)
-       {
-               for(int r=0; r < m.num_rows(); r++)
-                       for(int c=0; c < m.num_rows(); c++)
-                               m[r][c] = *data++;
        }
-};
-
+       };
 }
+
+static Operator<Internal::Zero> Zero;
 static Operator<Internal::Identity> Identity;
 
+
 }
 #endif




reply via email to

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