work/mixpp/bdm/math/libDC.h

Go to the documentation of this file.
00001 
00013 #ifndef DC_H
00014 #define DC_H
00015 
00016 #include <itpp/itbase.h>
00017 
00018 using namespace itpp;
00019 
00024 class sqmat
00025 {
00026         public:
00034                 virtual void opupdt ( const vec &v, double w ) =0;
00035 
00039                 virtual mat to_mat() =0;
00040 
00045                 virtual void mult_sym ( const mat &C, bool trans=true ) =0;
00046 
00047 
00052                 virtual double logdet() =0;
00053 
00059                 virtual vec sqrt_mult ( vec &v ) =0;
00060 
00065                 virtual double qform ( vec &v ) =0;
00066 
00067 //      //! easy version of the
00068 //      sqmat inv();
00069 
00071                 virtual void clear() =0;
00072 
00074                 int cols() const {return dim;};
00075 
00077                 int rows() const {return dim;};
00078 
00079         protected:
00080                 int dim;
00081 };
00082 
00083 
00088 class fsqmat: public sqmat
00089 {
00090         protected:
00091                 mat M;
00092         public:
00093                 void opupdt ( const vec &v, double w );
00094                 mat to_mat() ;
00095                 void mult_sym ( const mat &C, bool trans=false );
00096                 void mult_sym ( const mat &C, fsqmat &U, bool trans=false );
00097                 void clear();
00098 
00099 
00100                 fsqmat(); // mat will be initialized OK
00102                 fsqmat ( const mat &M );
00103 
00109                 virtual void inv ( fsqmat &Inv );
00110 
00111                 double logdet() {return log ( det ( M ) );};
00112                 double qform ( vec &v ) {return ( v* ( M*v ) );};
00113                 vec sqrt_mult ( vec &v ) {it_error ( "not implemented" );return v;};
00114 
00115                 fsqmat& operator += ( const fsqmat &A ) {M+=A.M;return *this;};
00116                 fsqmat& operator -= ( const fsqmat &A ) {M-=A.M;return *this;};
00117                 fsqmat& operator *= ( double x ) {M*=x;return *this;};
00118 //              fsqmat& operator = ( const fsqmat &A) {M=A.M; return *this;};
00119 };
00120 
00121 class ldmat: sqmat
00122 {
00123         public:
00124 
00126                 ldmat ( const mat &L, const vec &D );
00128                 ldmat ( mat V );
00130                 ldmat ( vec D0 );
00131                 ldmat ();
00132 
00133                 // Reimplementation of compulsory operatios
00134 
00135                 void opupdt ( const vec &v, double w );
00136                 mat to_mat();
00137                 void mult_sym ( const mat &C, bool trans=false );
00138                 void add ( const ldmat &ld2, double w=1.0 );
00139                 double logdet();
00140                 double qform ( vec &v );
00141 //      sqmat& operator -= ( const sqmat & ld2 );
00142                 void clear();
00143                 int cols();
00144                 int rows();
00145                 vec sqrt_mult ( vec &v );
00146 
00152                 virtual void inv ( ldmat &Inv );
00153 
00159                 void mult_sym ( const mat &C, ldmat &U, bool trans=false );
00160 
00169                 void ldform ( mat &A, vec &D0 );
00170 
00171                 ldmat& operator += ( const ldmat &ldA );
00172                 ldmat& operator -= ( const ldmat &ldA );
00173                 ldmat& operator *= ( double x );
00174 
00175                 friend std::ostream &operator<< ( std::ostream &os, ldmat &sq );
00176 
00177         protected:
00178                 vec D;
00179                 mat L;
00180 
00181 };
00182 
00184 
00185 inline ldmat& ldmat::operator += ( const ldmat &ldA )  {this->add ( ldA );return *this;}
00186 inline ldmat& ldmat::operator -= ( const ldmat &ldA )  {this->add ( ldA,-1.0 );return *this;}
00187 inline int ldmat::cols() {return dim;}
00188 inline int ldmat::rows() {return dim;}
00189 
00190 #endif // DC_H

Generated on Mon Feb 18 21:48:39 2008 for mixpp by  doxygen 1.5.3