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 
00044                 virtual void mult_sym ( const mat &C ) =0;
00045                 
00049                 virtual void mult_sym_t ( const mat &C ) =0;
00050 
00051 
00056                 virtual double logdet() const =0;
00057 
00063                 virtual vec sqrt_mult (const vec &v ) const =0;
00064 
00069                 virtual double qform (const vec &v ) const =0;
00070 
00071 //      //! easy version of the
00072 //      sqmat inv();
00073 
00075                 virtual void clear() =0;
00076 
00078                 int cols() const {return dim;};
00079 
00081                 int rows() const {return dim;};
00082 
00084                 virtual ~sqmat(){};
00086                 sqmat(const int dim0): dim(dim0){};
00087         protected:
00089                 int dim;
00090 };
00091 
00092 
00097 class fsqmat: public sqmat
00098 {
00099         protected:
00101                 mat M;
00102         public:
00103                 void opupdt ( const vec &v, double w );
00104                 mat to_mat() ;
00105                 void mult_sym ( const mat &C);
00106                 void mult_sym_t ( const mat &C);
00108                 void mult_sym ( const mat &C, fsqmat &U) const;
00110                 void mult_sym_t ( const mat &C, fsqmat &U) const;
00111                 void clear();
00112 
00114                 fsqmat(); // mat will be initialized OK
00116                 fsqmat(const int dim0); // mat will be initialized OK
00118                 fsqmat ( const mat &M );
00119 
00121                 virtual ~fsqmat(){};
00122 
00123 
00129                 virtual void inv ( fsqmat &Inv );
00130 
00131                 double logdet() const {return log ( det ( M ) );};
00132                 double qform (const  vec &v ) const {return ( v* ( M*v ) );};
00133                 vec sqrt_mult (const vec &v ) const {it_error ( "not implemented" );return v;};
00134 
00136                 fsqmat& operator += ( const fsqmat &A ) {M+=A.M;return *this;};
00138                 fsqmat& operator -= ( const fsqmat &A ) {M-=A.M;return *this;};
00140                 fsqmat& operator *= ( double x ) {M*=x;return *this;};
00141 //              fsqmat& operator = ( const fsqmat &A) {M=A.M; return *this;};
00143                 friend std::ostream &operator<< ( std::ostream &os, const fsqmat &sq );
00144 
00145 };
00146 
00152 class ldmat: sqmat
00153 {
00154         public:
00155 
00157                 ldmat ( const mat &L, const vec &D );
00159                 ldmat (const mat &V );
00161                 ldmat ( vec D0 );
00163                 ldmat ();
00165                 ldmat(const int dim0);
00166 
00168                 virtual ~ldmat(){};
00169 
00170                 // Reimplementation of compulsory operatios
00171 
00172                 void opupdt ( const vec &v, double w );
00173                 mat to_mat();
00174                 void mult_sym ( const mat &C);
00175                 void mult_sym_t ( const mat &C);
00177                 void add ( const ldmat &ld2, double w=1.0 );
00178                 double logdet() const;
00179                 double qform (const vec &v ) const;
00180 //      sqmat& operator -= ( const sqmat & ld2 );
00181                 void clear();
00182                 int cols() const;
00183                 int rows() const;
00184                 vec sqrt_mult ( const vec &v ) const;
00185 
00189                 virtual void inv ( ldmat &Inv ) const;
00190 
00195                 void mult_sym ( const mat &C, ldmat &U) const;
00196 
00201                 void mult_sym_t ( const mat &C, ldmat &U) const;
00202 
00203 
00210                 void ldform (const mat &A,const vec &D0 );
00211 
00213                 void setD (const vec &nD){D=nD;}
00215                 void setD (const vec &nD, int i){D.replace_mid(i,nD);} //Fixme can be more general
00217                 void setL (const vec &nL){L=nL;}
00218 
00220                 ldmat& operator += ( const ldmat &ldA );
00222                 ldmat& operator -= ( const ldmat &ldA );
00224                 ldmat& operator *= ( double x );
00225 
00227                 friend std::ostream &operator<< ( std::ostream &os, const ldmat &sq );
00228 
00229 
00230         protected:
00232                 vec D;
00234                 mat L;
00235 
00236 };
00237 
00240 inline ldmat& ldmat::operator += ( const ldmat &ldA )  {this->add ( ldA );return *this;}
00242 inline ldmat& ldmat::operator -= ( const ldmat &ldA )  {this->add ( ldA,-1.0 );return *this;}
00244 inline int ldmat::cols() const {return dim;}
00246 inline int ldmat::rows() const {return dim;}
00247 
00248 #endif // DC_H

Generated on Wed Mar 5 15:40:00 2008 for mixpp by  doxygen 1.5.3