00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef __GNUC__
00029 #pragma interface
00030 #endif
00031
00032 #ifndef _math_scmat_repl_h
00033 #define _math_scmat_repl_h
00034
00035 #include <util/group/message.h>
00036
00037 #include <math/scmat/block.h>
00038 #include <math/scmat/matrix.h>
00039 #include <math/scmat/abstract.h>
00040
00044 class ReplSCMatrixKit: public SCMatrixKit {
00045 public:
00046 ReplSCMatrixKit();
00047 ReplSCMatrixKit(const Ref<KeyVal>&);
00048 ~ReplSCMatrixKit();
00049 SCMatrix* matrix(const RefSCDimension&,const RefSCDimension&);
00050 SymmSCMatrix* symmmatrix(const RefSCDimension&);
00051 DiagSCMatrix* diagmatrix(const RefSCDimension&);
00052 SCVector* vector(const RefSCDimension&);
00053 };
00054
00055
00056 class ReplSCMatrixListSubblockIter: public SCMatrixListSubblockIter {
00057 protected:
00058 Ref<MessageGrp> grp_;
00059 double *data_;
00060 int ndata_;
00061 public:
00062 ReplSCMatrixListSubblockIter(Access,
00063 const Ref<SCMatrixBlockList> &list,
00064 const Ref<MessageGrp> &grp,
00065 double *data, int ndata);
00066 ~ReplSCMatrixListSubblockIter();
00067 };
00068
00069 class ReplSCVector: public SCVector {
00070 friend class ReplSCMatrix;
00071 friend class ReplSymmSCMatrix;
00072 friend class ReplDiagSCMatrix;
00073 protected:
00074 Ref<SCMatrixBlockList> blocklist;
00075 double* vector;
00076 void init_blocklist();
00077 void before_elemop();
00078 void after_elemop();
00079 public:
00080 ReplSCVector(const RefSCDimension&,ReplSCMatrixKit*);
00081 ~ReplSCVector();
00082 void assign_val(double);
00083 void assign_v(SCVector*);
00084 void assign_p(const double*);
00085
00086 void set_element(int,double);
00087 void accumulate_element(int,double);
00088 double get_element(int) const;
00089 void accumulate_product_sv(SymmSCMatrix*,SCVector*);
00090 void accumulate_product_rv(SCMatrix*,SCVector*);
00091 void accumulate(const SCVector*);
00092 void accumulate(const SCMatrix*);
00093 double scalar_product(SCVector*);
00094 void element_op(const Ref<SCElementOp>&);
00095 void element_op(const Ref<SCElementOp2>&,
00096 SCVector*);
00097 void element_op(const Ref<SCElementOp3>&,
00098 SCVector*,SCVector*);
00099 void vprint(const char* title=0,
00100 std::ostream& out=ExEnv::out(), int =10) const;
00101
00102
00103 double *get_data() { return vector; }
00104
00105 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00106 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00107
00108 Ref<ReplSCMatrixKit> skit();
00109 };
00110
00111 class ReplSCMatrix: public SCMatrix {
00112 friend class ReplSymmSCMatrix;
00113 friend class ReplDiagSCMatrix;
00114 friend class ReplSCVector;
00115 protected:
00116 Ref<SCMatrixBlockList> blocklist;
00117 double* matrix;
00118 double** rows;
00119 protected:
00120
00121 int compute_offset(int,int) const;
00122 void init_blocklist();
00123
00124 void before_elemop();
00125 void after_elemop();
00126 public:
00127 ReplSCMatrix(const RefSCDimension&,const RefSCDimension&,
00128 ReplSCMatrixKit*);
00129 ~ReplSCMatrix();
00130
00131
00132 void assign_val(double);
00133 double get_element(int,int) const;
00134 void set_element(int,int,double);
00135 void accumulate_element(int,int,double);
00136 SCMatrix * get_subblock(int,int,int,int);
00137 void assign_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
00138 void accumulate_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
00139 SCVector * get_row(int i);
00140 SCVector * get_column(int i);
00141 void assign_row(SCVector *v, int i);
00142 void assign_column(SCVector *v, int i);
00143 void accumulate_row(SCVector *v, int i);
00144 void accumulate_column(SCVector *v, int i);
00145
00146 void accumulate_outer_product(SCVector*,SCVector*);
00147 void accumulate_product_rr(SCMatrix*,SCMatrix*);
00148 void accumulate_product_rs(SCMatrix*,SymmSCMatrix*);
00149 void accumulate_product_rd(SCMatrix*,DiagSCMatrix*);
00150 void accumulate(const SCMatrix*);
00151 void accumulate(const SymmSCMatrix*);
00152 void accumulate(const DiagSCMatrix*);
00153 void accumulate(const SCVector*);
00154 void transpose_this();
00155 double invert_this();
00156 void svd_this(SCMatrix *U, DiagSCMatrix *sigma, SCMatrix *V);
00157 double solve_this(SCVector*);
00158 double determ_this();
00159 double trace();
00160 void schmidt_orthog(SymmSCMatrix*,int);
00161 int schmidt_orthog_tol(SymmSCMatrix*, double tol, double *res=0);
00162 void element_op(const Ref<SCElementOp>&);
00163 void element_op(const Ref<SCElementOp2>&,
00164 SCMatrix*);
00165 void element_op(const Ref<SCElementOp3>&,
00166 SCMatrix*,SCMatrix*);
00167 void vprint(const char* title=0,
00168 std::ostream& out=ExEnv::out(), int =10) const;
00169
00170
00171 double *get_data() { return matrix; }
00172 double **get_rows() { return rows; }
00173
00174 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00175 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00176
00177 Ref<ReplSCMatrixKit> skit();
00178 };
00179
00180 class ReplSymmSCMatrix: public SymmSCMatrix {
00181 friend class ReplSCMatrix;
00182 friend class ReplDiagSCMatrix;
00183 friend class ReplSCVector;
00184 protected:
00185 Ref<SCMatrixBlockList> blocklist;
00186 double* matrix;
00187 double** rows;
00188 protected:
00189
00190 int compute_offset(int,int) const;
00191 void init_blocklist();
00192
00193 void before_elemop();
00194 void after_elemop();
00195 public:
00196 ReplSymmSCMatrix(const RefSCDimension&, ReplSCMatrixKit*);
00197 ~ReplSymmSCMatrix();
00198
00199
00200 void assign_val(double);
00201 void assign_s(SymmSCMatrix*);
00202 void assign_p(const double*);
00203 void assign_pp(const double**);
00204 double get_element(int,int) const;
00205 void set_element(int,int,double);
00206 void accumulate_element(int,int,double);
00207 void scale(double);
00208
00209 SCMatrix * get_subblock(int,int,int,int);
00210 SymmSCMatrix * get_subblock(int,int);
00211 void assign_subblock(SCMatrix*, int,int,int,int);
00212 void assign_subblock(SymmSCMatrix*, int,int);
00213 void accumulate_subblock(SCMatrix*, int,int,int,int);
00214 void accumulate_subblock(SymmSCMatrix*, int,int);
00215 SCVector * get_row(int i);
00216 void assign_row(SCVector *v, int i);
00217 void accumulate_row(SCVector *v, int i);
00218
00219 void accumulate_product_rr(SCMatrix*,SCMatrix*);
00220 void accumulate(const SymmSCMatrix*);
00221 double invert_this();
00222 double solve_this(SCVector*);
00223 double trace();
00224 double determ_this();
00225 void gen_invert_this();
00226
00227 double scalar_product(SCVector*);
00228 void diagonalize(DiagSCMatrix*,SCMatrix*);
00229 void accumulate_symmetric_outer_product(SCVector*);
00230 void accumulate_symmetric_product(SCMatrix*);
00231 void accumulate_symmetric_sum(SCMatrix*);
00232 void accumulate_transform(SCMatrix*,SymmSCMatrix*,
00233 SCMatrix::Transform = SCMatrix::NormalTransform);
00234 void accumulate_transform(SCMatrix*,DiagSCMatrix*,
00235 SCMatrix::Transform = SCMatrix::NormalTransform);
00236 void accumulate_transform(SymmSCMatrix*,SymmSCMatrix*);
00237 void element_op(const Ref<SCElementOp>&);
00238 void element_op(const Ref<SCElementOp2>&,
00239 SymmSCMatrix*);
00240 void element_op(const Ref<SCElementOp3>&,
00241 SymmSCMatrix*,SymmSCMatrix*);
00242 void vprint(const char* title=0,
00243 std::ostream& out=ExEnv::out(), int =10) const;
00244
00245
00246 double *get_data() { return matrix; }
00247 double **get_rows() { return rows; }
00248
00249 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00250 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00251
00252 Ref<ReplSCMatrixKit> skit();
00253 };
00254
00255 class ReplDiagSCMatrix: public DiagSCMatrix {
00256 friend class ReplSCMatrix;
00257 friend class ReplSymmSCMatrix;
00258 friend class ReplSCVector;
00259 protected:
00260 Ref<SCMatrixBlockList> blocklist;
00261 void init_blocklist();
00262 double* matrix;
00263
00264 void before_elemop();
00265 void after_elemop();
00266 public:
00267 ReplDiagSCMatrix(const RefSCDimension&, ReplSCMatrixKit*);
00268 ~ReplDiagSCMatrix();
00269
00270
00271 void assign_val(double);
00272 double get_element(int) const;
00273 void set_element(int,double);
00274 void accumulate_element(int,double);
00275 void accumulate(const DiagSCMatrix*);
00276 double invert_this();
00277 double determ_this();
00278 double trace();
00279 void gen_invert_this();
00280
00281 void element_op(const Ref<SCElementOp>&);
00282 void element_op(const Ref<SCElementOp2>&,
00283 DiagSCMatrix*);
00284 void element_op(const Ref<SCElementOp3>&,
00285 DiagSCMatrix*,DiagSCMatrix*);
00286 void vprint(const char* title=0,
00287 std::ostream& out=ExEnv::out(), int =10) const;
00288
00289
00290 double *get_data() { return matrix; }
00291
00292 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00293 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00294
00295 Ref<ReplSCMatrixKit> skit();
00296 };
00297
00298 #endif
00299
00300
00301
00302
00303