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 public:
00033 virtual void opupdt( const vec &v, double w ) =0;
00034
00038 virtual mat to_mat() =0;
00039
00044 virtual void mult_sym( const mat &C, bool trans=true ) =0;
00045
00046
00051 virtual double logdet() =0;
00052
00058 virtual vec sqrt_mult(vec &v) =0;
00059
00064 virtual double qform(vec &v) =0;
00065
00066
00067
00068
00070 virtual void clear() =0;
00071
00073 virtual int cols() =0;
00074
00076 virtual int rows() =0;
00077
00078 protected:
00079 int dim;
00080 };
00081
00082
00087 class fsqmat: sqmat {
00088 void opupdt( const vec &v, double w );
00089 mat to_mat();
00090 void mult_sym( const mat &C, bool trans=false );
00091 void mult_sym( const mat &C, fsqmat &U, bool trans=false );
00092 void inv(fsqmat &Inv);
00093 void clear();
00094
00095
00097 fsqmat(const mat &M);
00098
00104 virtual void inv(fsqmat* Inv);
00105
00106
00107 };
00108
00109 class ldmat: sqmat {
00110 public:
00111
00113 ldmat( const mat &L, const vec &D );
00115 ldmat( mat V );
00117 ldmat( vec D0 );
00118 ldmat ();
00119
00120
00121
00122 void opupdt( const vec &v, double w );
00123 mat to_mat();
00124 void mult_sym( const mat &C, bool trans=false );
00125 void add ( const ldmat &ld2, double w=1.0 );
00126 double logdet();
00127 double qform(vec &v);
00128
00129 void clear();
00130 int cols();
00131 int rows();
00132 vec sqrt_mult(vec &v);
00133
00139 virtual void inv(ldmat &Inv);
00140
00146 void mult_sym( const mat &C, ldmat &U, bool trans=false );
00147
00156 void ldform( mat &A, vec &D0 );
00157
00158 ldmat& operator += (const ldmat &ldA);
00159 ldmat& operator -= (const ldmat &ldA);
00160 ldmat& operator *= (double x);
00161
00162 friend std::ostream &operator<< ( std::ostream &os, ldmat &sq );
00163
00164 protected:
00165 vec D;
00166 mat L;
00167
00168 };
00169
00171
00172 inline ldmat& ldmat::operator += (const ldmat &ldA) {this->add(ldA);return *this;}
00173 inline ldmat& ldmat::operator -= (const ldmat &ldA) {this->add(ldA,-1.0);return *this;}
00174 inline int ldmat::cols(){return dim;}
00175 inline int ldmat::rows(){return dim;}
00176
00177 #endif // DC_H