- Main Page
- Related Pages
- Modules
- Classes
- Files

# work/git/mixpp/bdm/math/chmat.h

Go to the documentation of this file.

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