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_local_h
00033 #define _math_scmat_local_h
00034
00035 #include <math/scmat/block.h>
00036 #include <math/scmat/matrix.h>
00037 #include <math/scmat/abstract.h>
00038
00039 class LocalSCMatrixKit;
00040 class LocalSCVector;
00041 class LocalSCMatrix;
00042 class LocalSymmSCMatrix;
00043 class LocalDiagSCMatrix;
00044
00047 class LocalSCMatrixKit: public SCMatrixKit {
00048 public:
00049 LocalSCMatrixKit();
00050 LocalSCMatrixKit(const Ref<KeyVal>&);
00051 ~LocalSCMatrixKit();
00052 SCMatrix* matrix(const RefSCDimension&,const RefSCDimension&);
00053 SymmSCMatrix* symmmatrix(const RefSCDimension&);
00054 DiagSCMatrix* diagmatrix(const RefSCDimension&);
00055 SCVector* vector(const RefSCDimension&);
00056 };
00057
00058 class LocalSCVector: public SCVector {
00059 friend class LocalSCMatrix;
00060 friend class LocalSymmSCMatrix;
00061 friend class LocalDiagSCMatrix;
00062 private:
00063 Ref<SCVectorSimpleBlock> block;
00064
00065 void resize(int);
00066 public:
00067 LocalSCVector();
00068 LocalSCVector(const RefSCDimension&,LocalSCMatrixKit*);
00069 ~LocalSCVector();
00070 void assign_val(double);
00071 void assign_v(SCVector*);
00072 void assign_p(const double*);
00073
00074 void set_element(int,double);
00075 void accumulate_element(int,double);
00076 double get_element(int) const;
00077 void accumulate_product_sv(SymmSCMatrix*,SCVector*);
00078 void accumulate_product_rv(SCMatrix*,SCVector*);
00079 void accumulate(const SCVector*);
00080 void accumulate(const SCMatrix*);
00081 double scalar_product(SCVector*);
00082 void element_op(const Ref<SCElementOp>&);
00083 void element_op(const Ref<SCElementOp2>&,
00084 SCVector*);
00085 void element_op(const Ref<SCElementOp3>&,
00086 SCVector*,SCVector*);
00087 void vprint(const char* title=0,
00088 std::ostream& out=ExEnv::out(), int =10) const;
00089
00090
00091 double *get_data();
00092
00093 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00094 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00095 };
00096
00097 class LocalSCMatrix: public SCMatrix {
00098 friend class LocalSymmSCMatrix;
00099 friend class LocalDiagSCMatrix;
00100 friend class LocalSCVector;
00101 private:
00102 Ref<SCMatrixRectBlock> block;
00103 double** rows;
00104 private:
00105
00106 int compute_offset(int,int) const;
00107 void resize(int,int);
00108 public:
00109 LocalSCMatrix(const RefSCDimension&,const RefSCDimension&,
00110 LocalSCMatrixKit*);
00111 ~LocalSCMatrix();
00112
00113
00114 void assign_val(double);
00115 double get_element(int,int) const;
00116 void set_element(int,int,double);
00117 void accumulate_element(int,int,double);
00118 SCMatrix * get_subblock(int,int,int,int);
00119 void assign_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
00120 void accumulate_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
00121 SCVector * get_row(int i);
00122 SCVector * get_column(int i);
00123 void assign_row(SCVector *v, int i);
00124 void assign_column(SCVector *v, int i);
00125 void accumulate_row(SCVector *v, int i);
00126 void accumulate_column(SCVector *v, int i);
00127 void accumulate_outer_product(SCVector*,SCVector*);
00128 void accumulate_product_rr(SCMatrix*,SCMatrix*);
00129 void accumulate_product_rs(SCMatrix*,SymmSCMatrix*);
00130 void accumulate_product_rd(SCMatrix*,DiagSCMatrix*);
00131 void accumulate(const SCMatrix*);
00132 void accumulate(const SymmSCMatrix*);
00133 void accumulate(const DiagSCMatrix*);
00134 void accumulate(const SCVector*);
00135 void transpose_this();
00136 double invert_this();
00137 void svd_this(SCMatrix *U, DiagSCMatrix *sigma, SCMatrix *V);
00138 double solve_this(SCVector*);
00139 double determ_this();
00140 double trace();
00141 void schmidt_orthog(SymmSCMatrix*,int);
00142 int schmidt_orthog_tol(SymmSCMatrix*, double tol, double *res=0);
00143 void element_op(const Ref<SCElementOp>&);
00144 void element_op(const Ref<SCElementOp2>&,
00145 SCMatrix*);
00146 void element_op(const Ref<SCElementOp3>&,
00147 SCMatrix*,SCMatrix*);
00148 void vprint(const char* title=0,
00149 std::ostream& out=ExEnv::out(), int =10) const;
00150
00151
00152 double *get_data();
00153 double **get_rows();
00154
00155 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00156 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00157 };
00158
00159 class LocalSymmSCMatrix: public SymmSCMatrix {
00160 friend class LocalSCMatrix;
00161 friend class LocalDiagSCMatrix;
00162 friend class LocalSCVector;
00163 private:
00164 Ref<SCMatrixLTriBlock> block;
00165 double** rows;
00166 private:
00167
00168 int compute_offset(int,int) const;
00169 void resize(int n);
00170 public:
00171 LocalSymmSCMatrix(const RefSCDimension&, LocalSCMatrixKit*);
00172 ~LocalSymmSCMatrix();
00173
00174
00175 double get_element(int,int) const;
00176 void set_element(int,int,double);
00177 void accumulate_element(int,int,double);
00178
00179 SCMatrix * get_subblock(int,int,int,int);
00180 SymmSCMatrix * get_subblock(int,int);
00181 void assign_subblock(SCMatrix*, int,int,int,int);
00182 void assign_subblock(SymmSCMatrix*, int,int);
00183 void accumulate_subblock(SCMatrix*, int,int,int,int);
00184 void accumulate_subblock(SymmSCMatrix*, int,int);
00185 SCVector * get_row(int i);
00186 void assign_row(SCVector *v, int i);
00187 void accumulate_row(SCVector *v, int i);
00188
00189 void accumulate_product_rr(SCMatrix*,SCMatrix*);
00190 void accumulate(const SymmSCMatrix*);
00191 double invert_this();
00192 double solve_this(SCVector*);
00193 double trace();
00194 double determ_this();
00195 void gen_invert_this();
00196
00197 double scalar_product(SCVector*);
00198 void diagonalize(DiagSCMatrix*,SCMatrix*);
00199 void accumulate_symmetric_outer_product(SCVector*);
00200 void accumulate_symmetric_product(SCMatrix*);
00201 void accumulate_symmetric_sum(SCMatrix*);
00202 void accumulate_transform(SCMatrix*,SymmSCMatrix*,
00203 SCMatrix::Transform = SCMatrix::NormalTransform);
00204 void accumulate_transform(SCMatrix*,DiagSCMatrix*,
00205 SCMatrix::Transform = SCMatrix::NormalTransform);
00206 void accumulate_transform(SymmSCMatrix*,SymmSCMatrix*);
00207 void element_op(const Ref<SCElementOp>&);
00208 void element_op(const Ref<SCElementOp2>&,
00209 SymmSCMatrix*);
00210 void element_op(const Ref<SCElementOp3>&,
00211 SymmSCMatrix*,SymmSCMatrix*);
00212 void vprint(const char* title=0,
00213 std::ostream& out=ExEnv::out(), int =10) const;
00214
00215
00216 double *get_data();
00217 double **get_rows();
00218
00219 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00220 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00221 };
00222
00223 class LocalDiagSCMatrix: public DiagSCMatrix {
00224 friend class LocalSCMatrix;
00225 friend class LocalSymmSCMatrix;
00226 friend class LocalSCVector;
00227 private:
00228 Ref<SCMatrixDiagBlock> block;
00229 void resize(int n);
00230 public:
00231 LocalDiagSCMatrix(const RefSCDimension&, LocalSCMatrixKit*);
00232 ~LocalDiagSCMatrix();
00233
00234
00235 void save_data_state(StateOut&);
00236 double get_element(int) const;
00237 void set_element(int,double);
00238 void accumulate_element(int,double);
00239 void accumulate(const DiagSCMatrix*);
00240 double invert_this();
00241 double determ_this();
00242 double trace();
00243 void gen_invert_this();
00244
00245 void element_op(const Ref<SCElementOp>&);
00246 void element_op(const Ref<SCElementOp2>&,
00247 DiagSCMatrix*);
00248 void element_op(const Ref<SCElementOp3>&,
00249 DiagSCMatrix*,DiagSCMatrix*);
00250 void vprint(const char* title=0,
00251 std::ostream& out=ExEnv::out(), int =10) const;
00252
00253
00254 double *get_data();
00255
00256 Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
00257 Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
00258 };
00259
00260 #endif
00261
00262
00263
00264
00265