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
00032 #ifndef SACADO_PCE_HERMITE_HPP
00033 #define SACADO_PCE_HERMITE_HPP
00034
00035 #include "Sacado_Handle.hpp"
00036 #include "Sacado_PCE_HermiteBasis.hpp"
00037 #include "Sacado_PCE_HermiteEBasis.hpp"
00038 #include "Sacado_PCE_UnitHermiteBasis.hpp"
00039 #include "Sacado_PCE_Workspace.hpp"
00040
00041 #include <cmath>
00042 #include <algorithm>
00043 #include <ostream>
00044
00045 namespace Sacado {
00046
00048 namespace PCE {
00049
00051
00055 template <typename T>
00056 class Hermite {
00057 public:
00058
00060 typedef T value_type;
00061
00063 Hermite();
00064
00066
00069 Hermite(const T& x);
00070
00072
00075 Hermite(unsigned int d, const T & x);
00076
00078
00081 Hermite(unsigned int d);
00082
00084 Hermite(const Hermite& x);
00085
00087 ~Hermite();
00088
00090
00094 void resize(unsigned int d, bool keep_coeffs);
00095
00097
00100 void reserve(unsigned int d);
00101
00103
00112 void copyForWrite() { th.makeOwnCopy(); }
00113
00115
00118 static void initWorkspace(unsigned int d);
00119
00121 StandardPoly<T> toStandardBasis() const;
00122
00127
00129 Hermite<T>& operator=(const T& val);
00130
00132 Hermite<T>& operator=(const Hermite<T>& x);
00133
00135
00140
00142 const T& val() const { return th->coeff_[0];}
00143
00145 T& val() { return th->coeff_[0];}
00146
00148
00153
00155 unsigned int degree() const { return th->deg_;}
00156
00158 bool hasFastAccess(unsigned int d) const { return th->deg_>=d;}
00159
00161 const T* coeff() const { return th->coeff_;}
00162
00164 T* coeff() { return th->coeff_;}
00165
00167 T coeff(unsigned int i) const {
00168 T tmp= i<=th->deg_ ? th->coeff_[i]:T(0.); return tmp;}
00169
00171 T& fastAccessCoeff(unsigned int i) { return th->coeff_[i];}
00172
00174 T fastAccessCoeff(unsigned int i) const { return th->coeff_[i];}
00175
00177
00182
00184 Hermite<T> operator + () const;
00185
00187 Hermite<T> operator - () const;
00188
00190 Hermite<T>& operator += (const T& x);
00191
00193 Hermite<T>& operator -= (const T& x);
00194
00196 Hermite<T>& operator *= (const T& x);
00197
00199 Hermite<T>& operator /= (const T& x);
00200
00202 Hermite<T>& operator += (const Hermite<T>& x);
00203
00205 Hermite<T>& operator -= (const Hermite<T>& x);
00206
00208 Hermite<T>& operator *= (const Hermite<T>& x);
00209
00211 Hermite<T>& operator /= (const Hermite<T>& x);
00212
00214
00215 protected:
00216
00218 unsigned int length() const { return th->len_; }
00219
00221 void resizeCoeffs(unsigned int len);
00222
00223 protected:
00224
00225 struct HermiteData {
00226
00228 T* coeff_;
00229
00231 unsigned int deg_;
00232
00234 unsigned int len_;
00235
00237 HermiteData();
00238
00240 HermiteData(const T& x);
00241
00243 HermiteData(unsigned int d, const T & x);
00244
00246 HermiteData(unsigned int d);
00247
00249 HermiteData(unsigned int d, unsigned int l);
00250
00252 HermiteData(const HermiteData& x);
00253
00255 ~HermiteData();
00256
00258 HermiteData& operator=(const HermiteData& x);
00259
00260 };
00261
00262 Sacado::Handle<HermiteData> th;
00263
00264 public:
00265
00267 typedef Workspace< HermiteEBasis<T> > ws_type;
00268
00270 static ws_type workspace;
00271
00272 };
00273
00274
00275 template <typename T> Hermite<T> operator+(const Hermite<T>& a,
00276 const Hermite<T>& b);
00277 template <typename T> Hermite<T> operator+(const T& a,
00278 const Hermite<T>& b);
00279 template <typename T> Hermite<T> operator+(const Hermite<T>& a,
00280 const T& b);
00281 template <typename T> Hermite<T> operator-(const Hermite<T>& a,
00282 const Hermite<T>& b);
00283 template <typename T> Hermite<T> operator-(const T& a,
00284 const Hermite<T>& b);
00285 template <typename T> Hermite<T> operator-(const Hermite<T>& a,
00286 const T& b);
00287 template <typename T> Hermite<T> operator*(const Hermite<T>& a,
00288 const Hermite<T>& b);
00289 template <typename T> Hermite<T> operator*(const T& a,
00290 const Hermite<T>& b);
00291 template <typename T> Hermite<T> operator*(const Hermite<T>& a,
00292 const T& b);
00293 template <typename T> Hermite<T> operator/(const Hermite<T>& a,
00294 const Hermite<T>& b);
00295 template <typename T> Hermite<T> operator/(const T& a,
00296 const Hermite<T>& b);
00297 template <typename T> Hermite<T> operator/(const Hermite<T>& a,
00298 const T& b);
00299 template <typename T> Hermite<T> exp(const Hermite<T>& a);
00300 template <typename T> Hermite<T> log(const Hermite<T>& a);
00301 template <typename T> Hermite<T> log10(const Hermite<T>& a);
00302 template <typename T> Hermite<T> sqrt(const Hermite<T>& a);
00303 template <typename T> Hermite<T> pow(const Hermite<T>& a,
00304 const Hermite<T>& b);
00305 template <typename T> Hermite<T> pow(const T& a,
00306 const Hermite<T>& b);
00307 template <typename T> Hermite<T> pow(const Hermite<T>& a,
00308 const T& b);
00309 template <typename T> void sincos(const Hermite<T>& a,
00310 Hermite<T>& s, Hermite<T>& c);
00311 template <typename T> Hermite<T> cos(const Hermite<T>& a);
00312 template <typename T> Hermite<T> sin(const Hermite<T>& a);
00313 template <typename T> Hermite<T> tan(const Hermite<T>& a);
00314 template <typename T> void sinhcosh(const Hermite<T>& a,
00315 Hermite<T>& s, Hermite<T>& c);
00316 template <typename T> Hermite<T> cosh(const Hermite<T>& a);
00317 template <typename T> Hermite<T> sinh(const Hermite<T>& a);
00318 template <typename T> Hermite<T> tanh(const Hermite<T>& a);
00319 template <typename T, typename OpT> Hermite<T> quad(const OpT& quad_func,
00320 const Hermite<T>& a,
00321 const Hermite<T>& b);
00322 template <typename T> Hermite<T> acos(const Hermite<T>& a);
00323 template <typename T> Hermite<T> asin(const Hermite<T>& a);
00324 template <typename T> Hermite<T> atan(const Hermite<T>& a);
00325 template <typename T> Hermite<T> atan2(const Hermite<T>& a,
00326 const Hermite<T>& b);
00327 template <typename T> Hermite<T> atan2(const T& a,
00328 const Hermite<T>& b);
00329 template <typename T> Hermite<T> atan2(const Hermite<T>& a,
00330 const T& b);
00331 template <typename T> Hermite<T> acosh(const Hermite<T>& a);
00332 template <typename T> Hermite<T> asinh(const Hermite<T>& a);
00333 template <typename T> Hermite<T> atanh(const Hermite<T>& a);
00334 template <typename T> Hermite<T> abs(const Hermite<T>& a);
00335 template <typename T> Hermite<T> fabs(const Hermite<T>& a);
00336
00337 template <typename T> Hermite<T> max(const Hermite<T>& a,
00338 const Hermite<T>& b);
00339 template <typename T> Hermite<T> max(const T& a,
00340 const Hermite<T>& b);
00341 template <typename T> Hermite<T> max(const Hermite<T>& a,
00342 const T& b);
00343 template <typename T> Hermite<T> min(const Hermite<T>& a,
00344 const Hermite<T>& b);
00345 template <typename T> Hermite<T> min(const T& a,
00346 const Hermite<T>& b);
00347 template <typename T> Hermite<T> min(const Hermite<T>& a,
00348 const T& b);
00349 template <typename T> bool operator==(const Hermite<T>& a,
00350 const Hermite<T>& b);
00351 template <typename T> bool operator==(const T& a,
00352 const Hermite<T>& b);
00353 template <typename T> bool operator==(const Hermite<T>& a,
00354 const T& b);
00355 template <typename T> bool operator!=(const Hermite<T>& a,
00356 const Hermite<T>& b);
00357 template <typename T> bool operator!=(const T& a,
00358 const Hermite<T>& b);
00359 template <typename T> bool operator!=(const Hermite<T>& a,
00360 const T& b);
00361 template <typename T> bool operator<=(const Hermite<T>& a,
00362 const Hermite<T>& b);
00363 template <typename T> bool operator<=(const T& a,
00364 const Hermite<T>& b);
00365 template <typename T> bool operator<=(const Hermite<T>& a,
00366 const T& b);
00367 template <typename T> bool operator>=(const Hermite<T>& a,
00368 const Hermite<T>& b);
00369 template <typename T> bool operator>=(const T& a,
00370 const Hermite<T>& b);
00371 template <typename T> bool operator>=(const Hermite<T>& a,
00372 const T& b);
00373 template <typename T> bool operator<(const Hermite<T>& a,
00374 const Hermite<T>& b);
00375 template <typename T> bool operator<(const T& a,
00376 const Hermite<T>& b);
00377 template <typename T> bool operator<(const Hermite<T>& a,
00378 const T& b);
00379 template <typename T> bool operator>(const Hermite<T>& a,
00380 const Hermite<T>& b);
00381 template <typename T> bool operator>(const T& a,
00382 const Hermite<T>& b);
00383 template <typename T> bool operator>(const Hermite<T>& a,
00384 const T& b);
00385 template <typename T> std::ostream& operator << (std::ostream& os,
00386 const Hermite<T>& a);
00387
00388 }
00389
00390 }
00391
00392 #include "Sacado_PCE_HermiteTraits.hpp"
00393 #include "Sacado_PCE_HermiteImp.hpp"
00394
00395 #endif // SACADO_PCE_HERMITE_HPP