toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN wls.h


From: Gerhard Reitmayr
Subject: [Toon-members] TooN wls.h
Date: Fri, 30 Apr 2010 13:41:09 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Gerhard Reitmayr <gerhard>      10/04/30 13:41:09

Modified files:
        .              : wls.h 

Log message:
        Added methods to add measurements with sparse jacobians to the WLS. So 
far only a method for a single block and for 2 blocks is implemented. more 
could be added or a dynamic version which takes a list of jacobians. In all 
cases, here the jacobians are represented as a stack of row vectors (as opposed 
to columns as in the original interface). The postfix _rows signifies that.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/wls.h?cvsroot=toon&r1=1.22&r2=1.23

Patches:
Index: wls.h
===================================================================
RCS file: /cvsroot/toon/TooN/wls.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- wls.h       11 Dec 2009 16:59:50 -0000      1.22
+++ wls.h       30 Apr 2010 13:41:09 -0000      1.23
@@ -117,11 +117,62 @@
        inline void add_mJ(const Vector<N,Precision,B1>& m,
                                           const Matrix<Size,N,Precision,B2>& J,
                                           const Matrix<N,N,Precision,B3>& 
invcov){
-               Matrix<Size,N,Precision> temp =  J * invcov;
+               const Matrix<Size,N,Precision> temp =  J * invcov;
                my_C_inv += temp * J.T();
                my_vector += temp * m;
        }
 
+       /// Add multiple measurements at once (much more efficiently)
+       /// @param m The measurements to add
+       /// @param J The Jacobian matrix 
\f$\frac{\partial\text{m}_i}{\partial\text{param}_j}\f$
+       /// @param invcov The inverse covariance of the measurement values
+       template<int N, class B1, class B2, class B3>
+       inline void add_mJ_rows(const Vector<N,Precision,B1>& m,
+                                          const Matrix<N,Size,Precision,B2>& J,
+                                          const Matrix<N,N,Precision,B3>& 
invcov){
+               const Matrix<Size,N,Precision> temp =  J.T() * invcov;
+               my_C_inv += temp * J;
+               my_vector += temp * m;
+       }
+
+       /// Add multiple measurements at once with a sparse Jacobian (much, 
much more efficiently)
+       /// @param m The measurements to add
+       /// @param J1 The first block of the Jacobian matrix 
\f$\frac{\partial\text{m}_i}{\partial\text{param}_j}\f$
+       /// @param index1 starting index for the first block
+       /// @param invcov The inverse covariance of the measurement values
+       template<int N, int S1, class B1, class B2, class B3>
+       inline void add_sparse_mJ_rows(const Vector<N,Precision,B1>& m,
+                                          const Matrix<N,S1,Precision,B2>& J1, 
const int index1,
+                                          const Matrix<N,N,Precision,B3>& 
invcov){
+               const Matrix<S1,N,Precision> temp1 = J1.T() * invcov;
+               const int size1 = J1.num_cols();
+               my_C_inv.slice(index1, index1, size1, size1) += temp1 * J1;
+               my_vector.slice(index1, size1) += temp1 * m;
+       }
+
+       /// Add multiple measurements at once with a sparse Jacobian (much, 
much more efficiently)
+       /// @param m The measurements to add
+       /// @param J1 The first block of the Jacobian matrix 
\f$\frac{\partial\text{m}_i}{\partial\text{param}_j}\f$
+       /// @param index1 starting index for the first block
+       /// @param J2 The second block of the Jacobian matrix 
\f$\frac{\partial\text{m}_i}{\partial\text{param}_j}\f$
+       /// @param index2 starting index for the second block
+       /// @param invcov The inverse covariance of the measurement values
+       template<int N, int S1, int S2, class B1, class B2, class B3, class B4>
+       inline void add_sparse_mJ_rows(const Vector<N,Precision,B1>& m,
+                                          const Matrix<N,S1,Precision,B2>& J1, 
const int index1,
+                                          const Matrix<N,S2,Precision,B3>& J2, 
const int index2,
+                                          const Matrix<N,N,Precision,B4>& 
invcov){
+               const Matrix<S1,N,Precision> temp1 = J1.T() * invcov;
+               const Matrix<S2,N,Precision> temp2 = J2.T() * invcov;
+               const int size1 = J1.num_cols();
+               const int size2 = J2.num_cols();
+               my_C_inv.slice(index1, index1, size1, size1) += temp1 * J1;
+               my_C_inv.slice(index2, index2, size2, size2) += temp2 * J2;
+               my_C_inv.slice(index1, index2, size1, size2) += temp1 * J2;
+               my_C_inv.slice(index2, index1, size2, size1) += temp2 * J1;
+               my_vector.slice(index1, size1) += temp1 * m;
+               my_vector.slice(index2, size2) += temp2 * m;
+       }
 
        /// Process all the measurements and compute the weighted least squares 
set of parameter values
        /// stores the result internally which can then be accessed by calling 
get_mu()




reply via email to

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