toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN helpers.h


From: Georg Klein
Subject: [Toon-members] TooN helpers.h
Date: Tue, 30 Jan 2007 15:57:11 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Georg Klein <georgklein>        07/01/30 15:57:11

Modified files:
        .              : helpers.h 

Log message:
        Added Fill({Matrix,Vector}, value) which is just like Zero( ) but with 
a value.

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

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- helpers.h   15 Jan 2007 18:03:17 -0000      1.17
+++ helpers.h   30 Jan 2007 15:57:11 -0000      1.18
@@ -66,6 +66,12 @@
 // set a vector to zero
 template <class Accessor> inline void Zero(VectorBase<Accessor>& v);
 
+// Fill a matrix with a certain value
+template <class Accessor> void Fill(MatrixBase<Accessor>&m, double value);
+
+// Fill a vector with a certain value
+template <class Accessor> inline void Fill(VectorBase<Accessor>& v, double 
value);
+
  template <class T, int N> struct ZeroBlock {
      static const T data[N];
  };
@@ -239,6 +245,22 @@
   }
 }
 
+// Fill a matrix with a certain value
+template <class Accessor> void Fill(MatrixBase<Accessor>&m, double value){
+  for(int r=0; r<m.num_rows(); r++){
+    for(int c=0; c<m.num_cols(); c++){
+      m(r,c) = value;
+    }
+  }
+}
+
+// Fill a vector with a certain value
+template <class Accessor> inline void Fill(VectorBase<Accessor>& v, double 
value){
+  for(int i=0; i<v.size(); i++){
+    v[i]=value;
+  }
+}
+
  namespace util {
      template <class F, int R, int N, class A1, class A2, class A3> inline 
void transformCovariance(const FixedMatrix<R,N,A1>& A, const 
FixedMatrix<N,N,A2>& B, FixedMatrix<R,R,A3>& M)
      {




reply via email to

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