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 ) =0;
00064
00069 virtual double qform (const vec &v ) =0;
00070
00071
00072
00073
00075 virtual void clear() =0;
00076
00078 int cols() const {return dim;};
00079
00081 int rows() const {return dim;};
00082
00084 virtual ~sqmat(){};
00085 protected:
00086 int dim;
00087 };
00088
00089
00094 class fsqmat: public sqmat
00095 {
00096 protected:
00097 mat M;
00098 public:
00099 void opupdt ( const vec &v, double w );
00100 mat to_mat() ;
00101 void mult_sym ( const mat &C);
00102 void mult_sym_t ( const mat &C);
00103 void mult_sym ( const mat &C, fsqmat &U);
00104 void mult_sym_t ( const mat &C, fsqmat &U);
00105 void clear();
00106
00108 fsqmat();
00110 fsqmat(const int dim0);
00112 fsqmat ( const mat &M );
00113
00115 virtual ~fsqmat(){};
00116
00117
00123 virtual void inv ( fsqmat &Inv );
00124
00125 double logdet() const {return log ( det ( M ) );};
00126 double qform (const vec &v ) {return ( v* ( M*v ) );};
00127 vec sqrt_mult (const vec &v ) {it_error ( "not implemented" );return v;};
00128
00129 fsqmat& operator += ( const fsqmat &A ) {M+=A.M;return *this;};
00130 fsqmat& operator -= ( const fsqmat &A ) {M-=A.M;return *this;};
00131 fsqmat& operator *= ( double x ) {M*=x;return *this;};
00132
00133
00134 friend std::ostream &operator<< ( std::ostream &os, const fsqmat &sq );
00135
00136 };
00137
00138 class ldmat: sqmat
00139 {
00140 public:
00141
00143 ldmat ( const mat &L, const vec &D );
00145 ldmat (const mat &V );
00147 ldmat ( vec D0 );
00149 ldmat ();
00151 ldmat(const int dim0);
00152
00154 virtual ~ldmat(){};
00155
00156
00157
00158 void opupdt ( const vec &v, double w );
00159 mat to_mat();
00160 void mult_sym ( const mat &C);
00161 void mult_sym_t ( const mat &C);
00162 void add ( const ldmat &ld2, double w=1.0 );
00163 double logdet() const;
00164 double qform (const vec &v );
00165
00166 void clear();
00167 int cols() const;
00168 int rows() const;
00169 vec sqrt_mult ( const vec &v );
00170
00176 virtual void inv ( ldmat &Inv );
00177
00183 void mult_sym ( const mat &C, ldmat &U);
00184
00190 void mult_sym_t ( const mat &C, ldmat &U);
00191
00192
00201 void ldform (const mat &A,const vec &D0 );
00202
00204 void setD (const vec &nD){D=nD;}
00205 void setL (const vec &nL){L=nL;}
00206
00207 ldmat& operator += ( const ldmat &ldA );
00208 ldmat& operator -= ( const ldmat &ldA );
00209 ldmat& operator *= ( double x );
00210
00211 friend std::ostream &operator<< ( std::ostream &os, const ldmat &sq );
00212
00213
00214 protected:
00215 vec D;
00216 mat L;
00217
00218 };
00219
00221
00222 inline ldmat& ldmat::operator += ( const ldmat &ldA ) {this->add ( ldA );return *this;}
00223 inline ldmat& ldmat::operator -= ( const ldmat &ldA ) {this->add ( ldA,-1.0 );return *this;}
00224 inline int ldmat::cols() const {return dim;}
00225 inline int ldmat::rows() const {return dim;}
00226
00227 #endif // DC_H