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 
00021 void dydr( double * r, double *f, double *Dr, double *Df, double *R, int jl, int jh, double *kr, int m, int mx );
00022 
00024 //TODO can be done via: dtrtri.f from lapack
00025 mat ltuinv( const mat &L );
00026 
00031 class sqmat
00032 {
00033         public:
00041                 virtual void opupdt ( const vec &v, double w ) =0;
00042 
00046                 virtual mat to_mat() =0;
00047 
00051                 virtual void mult_sym ( const mat &C ) =0;
00052                 
00056                 virtual void mult_sym_t ( const mat &C ) =0;
00057 
00058 
00063                 virtual double logdet() const =0;
00064 
00070                 virtual vec sqrt_mult (const vec &v ) const =0;
00071 
00076                 virtual double qform (const vec &v ) const =0;
00077 
00078 //      //! easy version of the
00079 //      sqmat inv();
00080 
00082                 virtual void clear() =0;
00083 
00085                 int cols() const {return dim;};
00086 
00088                 int rows() const {return dim;};
00089 
00091                 virtual ~sqmat(){};
00093                 sqmat(const int dim0): dim(dim0){};
00094         protected:
00096                 int dim;
00097 };
00098 
00099 
00104 class fsqmat: public sqmat
00105 {
00106         protected:
00108                 mat M;
00109         public:
00110                 void opupdt ( const vec &v, double w );
00111                 mat to_mat() ;
00112                 void mult_sym ( const mat &C);
00113                 void mult_sym_t ( const mat &C);
00115                 void mult_sym ( const mat &C, fsqmat &U) const;
00117                 void mult_sym_t ( const mat &C, fsqmat &U) const;
00118                 void clear();
00119 
00121                 fsqmat(); // mat will be initialized OK
00123                 fsqmat(const int dim0); // mat will be initialized OK
00125                 fsqmat ( const mat &M );
00126 
00128                 virtual ~fsqmat(){};
00129 
00130 
00136                 virtual void inv ( fsqmat &Inv );
00137 
00138                 double logdet() const {return log ( det ( M ) );};
00139                 double qform (const  vec &v ) const {return ( v* ( M*v ) );};
00140                 vec sqrt_mult (const vec &v ) const {it_error ( "not implemented" );return v;};
00141 
00143                 fsqmat& operator += ( const fsqmat &A ) {M+=A.M;return *this;};
00145                 fsqmat& operator -= ( const fsqmat &A ) {M-=A.M;return *this;};
00147                 fsqmat& operator *= ( double x ) {M*=x;return *this;};
00148 //              fsqmat& operator = ( const fsqmat &A) {M=A.M; return *this;};
00150                 friend std::ostream &operator<< ( std::ostream &os, const fsqmat &sq );
00151 
00152 };
00153 
00159 class ldmat: sqmat
00160 {
00161         public:
00162 
00164                 ldmat ( const mat &L, const vec &D );
00166                 ldmat (const mat &V );
00168                 ldmat ( vec D0 );
00170                 ldmat ();
00172                 ldmat(const int dim0);
00173 
00175                 virtual ~ldmat(){};
00176 
00177                 // Reimplementation of compulsory operatios
00178 
00179                 void opupdt ( const vec &v, double w );
00180                 mat to_mat();
00181                 void mult_sym ( const mat &C);
00182                 void mult_sym_t ( const mat &C);
00184                 void add ( const ldmat &ld2, double w=1.0 );
00185                 double logdet() const;
00186                 double qform (const vec &v ) const;
00187 //      sqmat& operator -= ( const sqmat & ld2 );
00188                 void clear();
00189                 int cols() const;
00190                 int rows() const;
00191                 vec sqrt_mult ( const vec &v ) const;
00192 
00196                 virtual void inv ( ldmat &Inv ) const;
00197 
00202                 void mult_sym ( const mat &C, ldmat &U) const;
00203 
00208                 void mult_sym_t ( const mat &C, ldmat &U) const;
00209 
00210 
00217                 void ldform (const mat &A,const vec &D0 );
00218 
00220                 void setD (const vec &nD){D=nD;}
00222                 void setD (const vec &nD, int i){D.replace_mid(i,nD);} //Fixme can be more general
00224                 void setL (const vec &nL){L=nL;}
00225 
00227                 ldmat& operator += ( const ldmat &ldA );
00229                 ldmat& operator -= ( const ldmat &ldA );
00231                 ldmat& operator *= ( double x );
00232 
00234                 friend std::ostream &operator<< ( std::ostream &os, const ldmat &sq );
00235 
00236 
00237         protected:
00239                 vec D;
00241                 mat L;
00242 
00243 };
00244 
00245 
00248 inline ldmat& ldmat::operator += ( const ldmat &ldA )  {this->add ( ldA );return *this;}
00250 inline ldmat& ldmat::operator -= ( const ldmat &ldA )  {this->add ( ldA,-1.0 );return *this;}
00252 inline int ldmat::cols() const {return dim;}
00254 inline int ldmat::rows() const {return dim;}
00255 
00256 #endif // DC_H

Generated on Wed Mar 12 16:15:44 2008 for mixpp by  doxygen 1.5.3