Changeset 37 for bdm/math

Show
Ignore:
Timestamp:
03/14/08 18:11:21 (16 years ago)
Author:
smidl
Message:

Matrix in Cholesky decomposition, Square-root Kalman and many bug fixes

Location:
bdm/math
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • bdm/math/libDC.cpp

    r32 r37  
    55 
    66using std::endl; 
    7  
    8 //! Auxiliary function dydr; dyadic reduction 
    9 void dydr( double * r, double *f, double *Dr, double *Df, double *R, int jl, int jh, double *kr, int m, int mx ); 
    10  
    11 //! Auxiliary function ltuinv; inversion of a triangular matrix; 
    12 //TODO can be done via: dtrtri.f from lapack 
    13 mat ltuinv( const mat &L ); 
    147 
    158void fsqmat::opupdt ( const vec &v, double w ) {M+=outer_product ( v,v*w );}; 
  • bdm/math/libDC.h

    r33 r37  
    1818using namespace itpp; 
    1919 
     20//! Auxiliary function dydr; dyadic reduction 
     21void dydr( double * r, double *f, double *Dr, double *Df, double *R, int jl, int jh, double *kr, int m, int mx ); 
     22 
     23//! Auxiliary function ltuinv; inversion of a triangular matrix; 
     24//TODO can be done via: dtrtri.f from lapack 
     25mat ltuinv( const mat &L ); 
     26 
    2027/*! \brief Virtual class for representation of double symmetric matrices in square-root form. 
    2128 
    22 All operations defined on this class should be optimized for the chosed decomposition. 
     29All operations defined on this class should be optimized for the chosen decomposition. 
    2330*/ 
    2431class sqmat 
     
    117124                //! Constructor 
    118125                fsqmat ( const mat &M ); 
     126                //! Constructor 
     127                fsqmat ( const vec &d ):sqmat(d.length()){M=diag(d);}; 
    119128 
    120129                //! Destructor for future use; 
     
    131140                double logdet() const {return log ( det ( M ) );}; 
    132141                double qform (const  vec &v ) const {return ( v* ( M*v ) );}; 
    133                 vec sqrt_mult (const vec &v ) const {it_error ( "not implemented" );return v;}; 
     142                vec sqrt_mult (const vec &v ) const {mat Ch=chol(M); return Ch*v;}; 
     143 
     144                //! Access functions 
     145                void setD (const vec &nD){M=diag(nD);} 
     146                //! Access functions 
     147                void setD (const vec &nD, int i){for(int j=i;j<nD.length();j++){M(j,j)=nD(j-i);}} //Fixme can be more general 
    134148 
    135149                //! add another fsqmat matrix 
     
    236250}; 
    237251 
     252 
    238253//////// Operations: 
    239254//!mapping of add operation to operators