Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

elemop.h

00001 // 00002 // elemop.h 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 00026 // 00027 00028 #ifndef _math_scmat_elemop_h 00029 #define _math_scmat_elemop_h 00030 00031 #ifdef __GNUC__ 00032 #pragma interface 00033 #endif 00034 00035 #include <util/state/state.h> 00036 #include <util/group/message.h> 00037 00038 namespace sc { 00039 00040 class SCMatrixBlock; 00041 class SCMatrixBlockIter; 00042 class SCMatrixRectBlock; 00043 class SCMatrixLTriBlock; 00044 class SCMatrixDiagBlock; 00045 class SCVectorSimpleBlock; 00046 class SCMatrixRectSubBlock; 00047 class SCMatrixLTriSubBlock; 00048 class SCMatrixDiagSubBlock; 00049 class SCVectorSimpleSubBlock; 00050 00051 class SCMatrix; 00052 class SymmSCMatrix; 00053 class DiagSCMatrix; 00054 class SCVector; 00055 00060 class SCElementOp: public SavableState { 00061 public: 00062 SCElementOp(); 00063 SCElementOp(StateIn&s): SavableState(s) {} 00064 virtual ~SCElementOp(); 00072 virtual int has_collect(); 00073 virtual void defer_collect(int); 00074 virtual void collect(const Ref<MessageGrp>&); 00078 virtual void collect(const Ref<SCElementOp>&); 00082 virtual int has_side_effects(); 00083 00086 virtual bool threadsafe(); 00087 00090 virtual bool cloneable(); 00091 00095 virtual Ref<SCElementOp> clone(); 00096 00099 virtual void process(SCMatrixBlockIter&) = 0; 00100 00105 void process_base(SCMatrixBlock*block); 00106 00111 virtual void process_spec_rect(SCMatrixRectBlock*); 00112 virtual void process_spec_ltri(SCMatrixLTriBlock*); 00113 virtual void process_spec_diag(SCMatrixDiagBlock*); 00114 virtual void process_spec_vsimp(SCVectorSimpleBlock*); 00115 virtual void process_spec_rectsub(SCMatrixRectSubBlock*); 00116 virtual void process_spec_ltrisub(SCMatrixLTriSubBlock*); 00117 virtual void process_spec_diagsub(SCMatrixDiagSubBlock*); 00118 virtual void process_spec_vsimpsub(SCVectorSimpleSubBlock*); 00119 }; 00120 00125 class SCElementOp2: public SavableState { 00126 public: 00127 SCElementOp2(); 00128 SCElementOp2(StateIn&s): SavableState(s) {} 00129 virtual ~SCElementOp2(); 00130 virtual int has_collect(); 00131 virtual void defer_collect(int); 00132 virtual int has_side_effects(); 00133 virtual int has_side_effects_in_arg(); 00134 virtual void collect(const Ref<MessageGrp>&); 00135 virtual void process(SCMatrixBlockIter&,SCMatrixBlockIter&) = 0; 00136 void process_base(SCMatrixBlock*,SCMatrixBlock*); 00137 virtual void process_spec_rect(SCMatrixRectBlock*,SCMatrixRectBlock*); 00138 virtual void process_spec_ltri(SCMatrixLTriBlock*,SCMatrixLTriBlock*); 00139 virtual void process_spec_diag(SCMatrixDiagBlock*,SCMatrixDiagBlock*); 00140 virtual void process_spec_vsimp(SCVectorSimpleBlock*,SCVectorSimpleBlock*); 00141 }; 00142 00147 class SCElementOp3: public SavableState { 00148 public: 00149 SCElementOp3(); 00150 SCElementOp3(StateIn&s): SavableState(s) {} 00151 virtual ~SCElementOp3(); 00152 virtual int has_collect(); 00153 virtual void defer_collect(int); 00154 virtual int has_side_effects(); 00155 virtual int has_side_effects_in_arg1(); 00156 virtual int has_side_effects_in_arg2(); 00157 virtual void collect(const Ref<MessageGrp>&); 00158 virtual void process(SCMatrixBlockIter&, 00159 SCMatrixBlockIter&, 00160 SCMatrixBlockIter&) = 0; 00161 void process_base(SCMatrixBlock*,SCMatrixBlock*,SCMatrixBlock*); 00162 virtual void process_spec_rect(SCMatrixRectBlock*, 00163 SCMatrixRectBlock*, 00164 SCMatrixRectBlock*); 00165 virtual void process_spec_ltri(SCMatrixLTriBlock*, 00166 SCMatrixLTriBlock*, 00167 SCMatrixLTriBlock*); 00168 virtual void process_spec_diag(SCMatrixDiagBlock*, 00169 SCMatrixDiagBlock*, 00170 SCMatrixDiagBlock*); 00171 virtual void process_spec_vsimp(SCVectorSimpleBlock*, 00172 SCVectorSimpleBlock*, 00173 SCVectorSimpleBlock*); 00174 }; 00175 00176 class SCElementScalarProduct: public SCElementOp2 { 00177 private: 00178 int deferred_; 00179 double product; 00180 public: 00181 SCElementScalarProduct(); 00182 SCElementScalarProduct(StateIn&); 00183 ~SCElementScalarProduct(); 00184 void save_data_state(StateOut&); 00185 void process(SCMatrixBlockIter&,SCMatrixBlockIter&); 00186 int has_collect(); 00187 void defer_collect(int); 00188 void collect(const Ref<MessageGrp>&); 00189 double result(); 00190 void init() { product = 0.0; } 00191 }; 00192 00193 00194 class SCDestructiveElementProduct: public SCElementOp2 { 00195 public: 00196 SCDestructiveElementProduct(); 00197 SCDestructiveElementProduct(StateIn&); 00198 ~SCDestructiveElementProduct(); 00199 int has_side_effects(); 00200 void save_data_state(StateOut&); 00201 void process(SCMatrixBlockIter&,SCMatrixBlockIter&); 00202 }; 00203 00204 class SCElementScale: public SCElementOp { 00205 private: 00206 double scale; 00207 public: 00208 SCElementScale(double a); 00209 SCElementScale(StateIn&); 00210 ~SCElementScale(); 00211 int has_side_effects(); 00212 void save_data_state(StateOut&); 00213 void process(SCMatrixBlockIter&); 00214 }; 00215 00216 class SCElementRandomize: public SCElementOp { 00217 private: 00218 double assign; 00219 public: 00220 SCElementRandomize(); 00221 SCElementRandomize(StateIn&); 00222 ~SCElementRandomize(); 00223 int has_side_effects(); 00224 void save_data_state(StateOut&); 00225 void process(SCMatrixBlockIter&); 00226 }; 00227 00228 class SCElementAssign: public SCElementOp { 00229 private: 00230 double assign; 00231 public: 00232 SCElementAssign(double a); 00233 SCElementAssign(StateIn&); 00234 ~SCElementAssign(); 00235 int has_side_effects(); 00236 void save_data_state(StateOut&); 00237 void process(SCMatrixBlockIter&); 00238 }; 00239 00240 class SCElementSquareRoot: public SCElementOp { 00241 public: 00242 SCElementSquareRoot(); 00243 SCElementSquareRoot(double a); 00244 SCElementSquareRoot(StateIn&); 00245 ~SCElementSquareRoot(); 00246 int has_side_effects(); 00247 void save_data_state(StateOut&); 00248 void process(SCMatrixBlockIter&); 00249 }; 00250 00251 class SCElementInvert: public SCElementOp { 00252 private: 00253 double threshold_; 00254 int nbelowthreshold_; 00255 int deferred_; 00256 public: 00257 SCElementInvert(double threshold = 0.0); 00258 SCElementInvert(StateIn&); 00259 ~SCElementInvert(); 00260 int has_side_effects(); 00261 void save_data_state(StateOut&); 00262 void process(SCMatrixBlockIter&); 00263 int has_collect(); 00264 void defer_collect(int); 00265 void collect(const Ref<MessageGrp>&); 00266 int result() { return nbelowthreshold_; } 00267 }; 00268 00269 00270 class SCElementScaleDiagonal: public SCElementOp { 00271 private: 00272 double scale_diagonal; 00273 public: 00274 SCElementScaleDiagonal(double a); 00275 SCElementScaleDiagonal(StateIn&); 00276 ~SCElementScaleDiagonal(); 00277 int has_side_effects(); 00278 void save_data_state(StateOut&); 00279 void process(SCMatrixBlockIter&); 00280 }; 00281 00282 class SCElementShiftDiagonal: public SCElementOp { 00283 private: 00284 double shift_diagonal; 00285 public: 00286 SCElementShiftDiagonal(double a); 00287 SCElementShiftDiagonal(StateIn&); 00288 ~SCElementShiftDiagonal(); 00289 int has_side_effects(); 00290 void save_data_state(StateOut&); 00291 void process(SCMatrixBlockIter&); 00292 }; 00293 00294 class SCElementMaxAbs: public SCElementOp { 00295 private: 00296 int deferred_; 00297 double r; 00298 public: 00299 SCElementMaxAbs(); 00300 SCElementMaxAbs(StateIn&); 00301 ~SCElementMaxAbs(); 00302 void save_data_state(StateOut&); 00303 void process(SCMatrixBlockIter&); 00304 int has_collect(); 00305 void defer_collect(int); 00306 void collect(const Ref<MessageGrp>&); 00307 double result(); 00308 }; 00309 00310 00311 class SCElementMinAbs: public SCElementOp { 00312 private: 00313 int deferred_; 00314 double r; 00315 public: 00316 // rinit must be greater than the magnitude of the smallest element 00317 SCElementMinAbs(double rinit); 00318 SCElementMinAbs(StateIn&); 00319 ~SCElementMinAbs(); 00320 void save_data_state(StateOut&); 00321 void process(SCMatrixBlockIter&); 00322 int has_collect(); 00323 void defer_collect(int); 00324 void collect(const Ref<MessageGrp>&); 00325 double result(); 00326 }; 00327 00328 00329 class SCElementSumAbs: public SCElementOp { 00330 private: 00331 int deferred_; 00332 double r; 00333 public: 00334 SCElementSumAbs(); 00335 SCElementSumAbs(StateIn&); 00336 ~SCElementSumAbs(); 00337 void save_data_state(StateOut&); 00338 void process(SCMatrixBlockIter&); 00339 int has_collect(); 00340 void defer_collect(int); 00341 void collect(const Ref<MessageGrp>&); 00342 double result(); 00343 void init() { r = 0.0; } 00344 }; 00345 00346 00347 class SCElementDot: public SCElementOp { 00348 private: 00349 double** avects; 00350 double** bvects; 00351 int length; 00352 public: 00353 SCElementDot(StateIn&); 00354 void save_data_state(StateOut&); 00355 SCElementDot(double**a, double**b, int length); 00356 void process(SCMatrixBlockIter&); 00357 int has_side_effects(); 00358 }; 00359 00360 class SCElementAccumulateSCMatrix: public SCElementOp { 00361 private: 00362 SCMatrix *m; 00363 public: 00364 SCElementAccumulateSCMatrix(SCMatrix *); 00365 int has_side_effects(); 00366 void process(SCMatrixBlockIter&); 00367 }; 00368 00369 class SCElementAccumulateSymmSCMatrix: public SCElementOp { 00370 private: 00371 SymmSCMatrix *m; 00372 public: 00373 SCElementAccumulateSymmSCMatrix(SymmSCMatrix *); 00374 int has_side_effects(); 00375 void process(SCMatrixBlockIter&); 00376 }; 00377 00378 class SCElementAccumulateDiagSCMatrix: public SCElementOp { 00379 private: 00380 DiagSCMatrix *m; 00381 public: 00382 SCElementAccumulateDiagSCMatrix(DiagSCMatrix *); 00383 int has_side_effects(); 00384 void process(SCMatrixBlockIter&); 00385 }; 00386 00387 class SCElementAccumulateSCVector: public SCElementOp { 00388 private: 00389 SCVector *m; 00390 public: 00391 SCElementAccumulateSCVector(SCVector *); 00392 int has_side_effects(); 00393 void process(SCMatrixBlockIter&); 00394 }; 00395 00396 } 00397 00398 #endif 00399 00400 // Local Variables: 00401 // mode: c++ 00402 // c-file-style: "CLJ" 00403 // End:

Generated at Sat Aug 7 00:04:21 2004 for MPQC 2.2.2 using the documentation package Doxygen 1.3.8.