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