00001
00013 #ifndef CHMAT_H
00014 #define CHMAT_H
00015
00016 #include <itpp/itbase.h>
00017 #include "libDC.h"
00018
00019 using namespace itpp;
00020
00026 class chmat : public sqmat {
00027 protected:
00029 mat Ch;
00030 public:
00031
00032 void opupdt ( const vec &v, double w );
00033 mat to_mat();
00034 void mult_sym ( const mat &C );
00035 void mult_sym ( const mat &C , chmat &U ) const;
00036 void mult_sym_t ( const mat &C );
00037 void mult_sym_t ( const mat &C, chmat &U ) const;
00038 double logdet() const;
00039 vec sqrt_mult ( const vec &v ) const;
00040 double qform ( const vec &v ) const;
00041 double invqform ( const vec &v ) const;
00042 void clear();
00043 void add ( const chmat &A2, double w=1.0 ) {};
00045 void inv ( chmat &Inv ) const { ( Inv.Ch ) = itpp::inv ( Ch ).T();};
00046 ;
00047
00048
00050 virtual ~chmat() {};
00052 chmat ( const int dim0 ) : sqmat ( dim0 ),Ch ( dim0,dim0 ) {};
00054 chmat ( const vec &v) : sqmat ( v.length() ),Ch ( diag(sqrt(v)) ) {};
00056 chmat ( const chmat &Ch0) : sqmat ( Ch0.dim),Ch ( Ch0.dim,Ch0.dim ) {Ch=Ch0.Ch;};
00058 chmat ( const mat &M ) : sqmat ( M.rows() ),Ch ( M.rows(),M.cols() ) {
00059 mat Q;
00060 it_assert_debug ( M.rows() ==M.cols(),"chmat:: input matrix must be square!" );
00061 Ch=chol ( M );
00062 };
00064 mat & _Ch() {return Ch;}
00066 void setD ( const vec &nD ) {Ch=diag ( sqrt(nD) );}
00068 void setD ( const vec &nD, int i ) {for ( int j=i;j<nD.length();j++ ) {Ch( j,j ) =sqrt(nD ( j-i ));}}
00069
00071 chmat& operator += ( const chmat &A2 );
00072 chmat& operator -= ( const chmat &A2 ) ;
00073 };
00074
00075
00078 inline chmat& chmat::operator += ( const chmat &A2 ) {this->add ( A2 );return *this;}
00080 inline chmat& chmat::operator -= ( const chmat &A2 ) {this->add ( A2,-1.0 );return *this;}
00081 #endif // CHMAT_H