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
00029
00030
00031 #ifndef SUNDANCE_EVALVECTOR_H
00032 #define SUNDANCE_EVALVECTOR_H
00033
00034 #include "SundanceDefs.hpp"
00035 #include "Teuchos_RefCountPtr.hpp"
00036 #include "Teuchos_Array.hpp"
00037 #include "SundanceObjectWithVerbosity.hpp"
00038 #include "SundanceUnaryFunctor.hpp"
00039 #include "SundanceNoncopyable.hpp"
00040
00041
00042 namespace Sundance
00043 {
00044 using namespace Teuchos;
00045 class TempStack;
00046
00047
00048
00049 class EvalVector : public Noncopyable,
00050 public ObjectWithClassVerbosity<EvalVector>
00051 {
00052 friend class EvalManager;
00053 friend class TempStack;
00054
00055 private:
00056
00057
00058 EvalVector(TempStack* s);
00059
00060
00061 EvalVector(TempStack* s, const RCP<Array<double> >& data,
00062 const std::string& str);
00063
00064
00065 public:
00066
00067
00068
00069
00070
00071 ~EvalVector();
00072
00073
00074
00075
00076
00077 void add_SV(const double& alpha,
00078 const EvalVector* B) ;
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 void add_SVV(const double& alpha,
00089 const EvalVector* B,
00090 const EvalVector* C) ;
00091
00092
00093 void add_V(const EvalVector* A) ;
00094
00095
00096 void add_S(const double& alpha);
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 void add_VV(const EvalVector* A,
00107 const EvalVector* B) ;
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 void multiply_S_add_SV(const double& alpha,
00119 const double& beta,
00120 const EvalVector* C) ;
00121
00122
00123
00124
00125
00126
00127
00128
00129 void multiply_S_add_S(const double& alpha,
00130 const double& beta) ;
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 void multiply_V_add_VVV(const EvalVector* A,
00141 const EvalVector* B,
00142 const EvalVector* C,
00143 const EvalVector* D) ;
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154 void multiply_V_add_SVV(const EvalVector* A,
00155 const double& beta,
00156 const EvalVector* C,
00157 const EvalVector* D) ;
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 void multiply_V_add_SV(const EvalVector* A,
00168 const double& beta,
00169 const EvalVector* C) ;
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 void multiply_VV(const EvalVector* A,
00180 const EvalVector* B) ;
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 void multiply_SV(const double& alpha,
00191 const EvalVector* B) ;
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 void multiply_V(const EvalVector* A) ;
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 void multiply_S(const double& alpha) ;
00212
00213
00214
00215
00216 void setTo_S_add_SVV(const double& alpha,
00217 const double& beta,
00218 const EvalVector* C,
00219 const EvalVector* D);
00220
00221
00222
00223
00224 void setTo_S_add_VV(const double& alpha,
00225 const EvalVector* B,
00226 const EvalVector* C);
00227
00228
00229
00230
00231 void setTo_S_add_SV(const double& alpha,
00232 const double& beta,
00233 const EvalVector* C);
00234
00235
00236
00237
00238 void setTo_S_add_V(const double& alpha,
00239 const EvalVector* B);
00240
00241
00242
00243
00244
00245 void setTo_V(const EvalVector* A);
00246
00247
00248
00249
00250 void setTo_VV(const EvalVector* A,
00251 const EvalVector* B);
00252
00253
00254
00255
00256 void setTo_SV(const double& alpha,
00257 const EvalVector* B);
00258
00259
00260
00261
00262 void setTo_SVV(const double& alpha,
00263 const EvalVector* B,
00264 const EvalVector* C);
00265
00266
00267
00268
00269
00270
00271
00272 void setToConstant(const double& alpha) ;
00273
00274
00275
00276
00277 void applyUnaryOperator(const UnaryFunctor* func,
00278 Array<RCP<EvalVector> >& opDerivs);
00279
00280
00281
00282 RCP<EvalVector> clone() const ;
00283
00284
00285 void resize(int n);
00286
00287
00288 int length() const {return data_->size();}
00289
00290
00291 void print(std::ostream& os) const ;
00292
00293
00294 const double * start() const {return &((*data_)[0]);}
00295
00296
00297 double * start() {return &((*data_)[0]);}
00298
00299 const std::string& str() const {return str_;}
00300
00301 void setString(const std::string& str) {str_ = str;}
00302
00303 inline static bool& shadowOps() {static bool rtn = false; return rtn;}
00304
00305 bool isValid() const {return data_.get() != 0 && s_ != 0;}
00306
00307
00308
00309
00310 inline static double& totalFlops() {static double rtn = 0; return rtn;}
00311
00312 private:
00313
00314 inline static void addFlops(const double& flops) {totalFlops() += flops;}
00315
00316 mutable TempStack* s_;
00317
00318 RCP<Array<double> > data_;
00319
00320 std::string str_;
00321
00322 };
00323
00324
00325
00326 }
00327
00328 namespace std
00329 {
00330 inline ostream& operator<<(std::ostream& os,
00331 const Sundance::EvalVector& vec)
00332 {
00333 vec.print(os);
00334 return os;
00335 }
00336 }
00337
00338
00339 #endif