Sacado_PCE_OrthogPoly.hpp

Go to the documentation of this file.
00001 // $Id: Sacado_PCE_OrthogPoly.hpp,v 1.4 2008/08/01 23:00:54 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/src/pce/Sacado_PCE_OrthogPoly.hpp,v $ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 // license for use of this work by or on behalf of the U.S. Government.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #ifndef SACADO_PCE_ORTHOGPOLY_HPP
00033 #define SACADO_PCE_ORTHOGPOLY_HPP
00034 
00035 #ifdef HAVE_SACADO_STOKHOS
00036 
00037 #include "Teuchos_RCP.hpp"
00038 
00039 #include "Sacado_Handle.hpp"
00040 
00041 #include "Stokhos_OrthogPolyExpansion.hpp"
00042 #include "Stokhos_TayOrthogPolyExpansion.hpp"
00043 #include "Stokhos_OrthogPolyApprox.hpp"
00044 
00045 #include <cmath>
00046 #include <algorithm>  // for std::min and std::max
00047 #include <ostream>  // for std::ostream
00048 
00049 namespace Sacado {
00050 
00052   namespace PCE {
00053 
00055 
00059     template <typename T> 
00060     class OrthogPoly {
00061     public:
00062 
00064       typedef T value_type;
00065 
00067       typedef Stokhos::OrthogPolyBasis<T> basis_type;
00068 
00070       //typedef Stokhos::TayOrthogPolyExpansion<T> expansion_type;
00071       typedef Stokhos::OrthogPolyExpansion<T> expansion_type;
00072 
00074       OrthogPoly();
00075 
00077 
00080       OrthogPoly(const value_type& x);
00081 
00083 
00086       OrthogPoly(unsigned int sz, const value_type& x);
00087 
00089 
00092       OrthogPoly(unsigned int sz);
00093 
00095       OrthogPoly(const OrthogPoly& x);
00096 
00098       ~OrthogPoly();
00099 
00101 
00104       void resize(unsigned int sz);
00105 
00107 
00110       void reserve(unsigned int sz);
00111 
00113 
00122       void copyForWrite() { th.makeOwnCopy(); }
00123 
00125 
00128       static void initExpansion(const Teuchos::RCP<expansion_type>& e);
00129 
00131       Stokhos::Polynomial<value_type> toStandardBasis() const;
00132 
00134       value_type evaluate(const std::vector<value_type>& point) const;
00135 
00140 
00142       OrthogPoly<T>& operator=(const value_type& val);
00143 
00145       OrthogPoly<T>& operator=(const OrthogPoly<T>& x);
00146 
00148 
00153 
00155       const value_type& val() const { return th->coeff_[0];}
00156 
00158       value_type& val() { return th->coeff_[0];}
00159 
00161 
00166 
00168       unsigned int size() const { return th->size();}
00169 
00171       bool hasFastAccess(unsigned int sz) const { return th->size()>=sz;}
00172 
00174       const value_type* coeff() const { return th->coeff();}
00175 
00177       value_type* coeff() { return th->coeff();}
00178 
00180       value_type coeff(unsigned int i) const { 
00181   value_type tmp= i<th->size() ? (*th)[i]:value_type(0.); return tmp;}
00182     
00184       value_type& fastAccessCoeff(unsigned int i) { return (*th)[i];}
00185 
00187       value_type fastAccessCoeff(unsigned int i) const { return (*th)[i];}
00188     
00190 
00195 
00197       OrthogPoly<T> operator + () const;
00198 
00200       OrthogPoly<T> operator - () const;
00201 
00203       OrthogPoly<T>& operator += (const value_type& x);
00204 
00206       OrthogPoly<T>& operator -= (const value_type& x);
00207 
00209       OrthogPoly<T>& operator *= (const value_type& x);
00210 
00212       OrthogPoly<T>& operator /= (const value_type& x);
00213 
00215       OrthogPoly<T>& operator += (const OrthogPoly<T>& x);
00216 
00218       OrthogPoly<T>& operator -= (const OrthogPoly<T>& x);
00219   
00221       OrthogPoly<T>& operator *= (const OrthogPoly<T>& x);
00222 
00224       OrthogPoly<T>& operator /= (const OrthogPoly<T>& x);
00225 
00227 
00229       const Stokhos::OrthogPolyApprox<value_type>& getOrthogPolyApprox() const 
00230       { return *th; }
00231 
00233       Stokhos::OrthogPolyApprox<value_type>& getOrthogPolyApprox() { 
00234   return *th; }
00235 
00236     public:
00237 
00239       static Teuchos::RCP<expansion_type> expansion;
00240 
00241     protected:
00242 
00243       Sacado::Handle< Stokhos::OrthogPolyApprox<value_type> > th;
00244 
00245     }; // class Hermite
00246 
00247     // Operations
00248     template <typename T> OrthogPoly<T> 
00249     operator+(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00250 
00251     template <typename T> OrthogPoly<T> 
00252     operator+(const typename OrthogPoly<T>::value_type& a, 
00253         const OrthogPoly<T>& b);
00254 
00255     template <typename T> OrthogPoly<T> 
00256     operator+(const OrthogPoly<T>& a, 
00257         const typename OrthogPoly<T>::value_type& b);
00258 
00259     template <typename T> OrthogPoly<T> 
00260     operator-(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00261 
00262     template <typename T> OrthogPoly<T> 
00263     operator-(const typename OrthogPoly<T>::value_type& a, 
00264         const OrthogPoly<T>& b);
00265 
00266     template <typename T> OrthogPoly<T> 
00267     operator-(const OrthogPoly<T>& a, 
00268         const typename OrthogPoly<T>::value_type& b);
00269 
00270     template <typename T> OrthogPoly<T> 
00271     operator*(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00272 
00273     template <typename T> OrthogPoly<T> 
00274     operator*(const typename OrthogPoly<T>::value_type& a, 
00275         const OrthogPoly<T>& b);
00276 
00277     template <typename T> OrthogPoly<T> 
00278     operator*(const OrthogPoly<T>& a, 
00279         const typename OrthogPoly<T>::value_type& b);
00280 
00281     template <typename T> OrthogPoly<T> 
00282     operator/(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00283 
00284     template <typename T> OrthogPoly<T> 
00285     operator/(const typename OrthogPoly<T>::value_type& a, 
00286         const OrthogPoly<T>& b);
00287 
00288     template <typename T> OrthogPoly<T> 
00289     operator/(const OrthogPoly<T>& a, 
00290         const typename OrthogPoly<T>::value_type& b);
00291 
00292     template <typename T> OrthogPoly<T> 
00293     exp(const OrthogPoly<T>& a);
00294 
00295     template <typename T> OrthogPoly<T> 
00296     log(const OrthogPoly<T>& a);
00297 
00298     template <typename T> OrthogPoly<T> 
00299     log10(const OrthogPoly<T>& a);
00300 
00301     template <typename T> OrthogPoly<T> 
00302     sqrt(const OrthogPoly<T>& a);
00303 
00304     template <typename T> OrthogPoly<T> 
00305     pow(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00306 
00307     template <typename T> OrthogPoly<T> 
00308     pow(const T& a, 
00309   const OrthogPoly<T>& b);
00310 
00311     template <typename T> OrthogPoly<T> 
00312     pow(const OrthogPoly<T>& a, 
00313   const T& b);
00314 
00315     template <typename T> OrthogPoly<T> 
00316     cos(const OrthogPoly<T>& a);
00317 
00318     template <typename T> OrthogPoly<T> 
00319     sin(const OrthogPoly<T>& a);
00320 
00321     template <typename T> OrthogPoly<T> 
00322     tan(const OrthogPoly<T>& a);
00323 
00324     template <typename T> OrthogPoly<T> 
00325     cosh(const OrthogPoly<T>& a);
00326 
00327     template <typename T> OrthogPoly<T>
00328     sinh(const OrthogPoly<T>& a);
00329 
00330     template <typename T> OrthogPoly<T> 
00331     tanh(const OrthogPoly<T>& a);
00332 
00333     template <typename T> OrthogPoly<T> 
00334     acos(const OrthogPoly<T>& a);
00335 
00336     template <typename T> OrthogPoly<T> 
00337     asin(const OrthogPoly<T>& a);
00338 
00339     template <typename T> OrthogPoly<T> 
00340     atan(const OrthogPoly<T>& a);
00341 
00342     template <typename T> OrthogPoly<T> 
00343     atan2(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00344 
00345     template <typename T> OrthogPoly<T> 
00346     atan2(const typename OrthogPoly<T>::value_type& a, 
00347     const OrthogPoly<T>& b);
00348 
00349     template <typename T> OrthogPoly<T> 
00350     atan2(const OrthogPoly<T>& a, 
00351     const typename OrthogPoly<T>::value_type& b);
00352 
00353     template <typename T> OrthogPoly<T> 
00354     acosh(const OrthogPoly<T>& a);
00355 
00356     template <typename T> OrthogPoly<T> 
00357     asinh(const OrthogPoly<T>& a);
00358 
00359     template <typename T> OrthogPoly<T> 
00360     atanh(const OrthogPoly<T>& a);
00361 
00362     template <typename T> OrthogPoly<T> 
00363     abs(const OrthogPoly<T>& a);
00364     
00365     template <typename T> OrthogPoly<T> 
00366     fabs(const OrthogPoly<T>& a);
00367 
00368     template <typename T> OrthogPoly<T> 
00369     max(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00370 
00371     template <typename T> OrthogPoly<T> 
00372     max(const typename OrthogPoly<T>::value_type& a, 
00373   const OrthogPoly<T>& b);
00374 
00375     template <typename T> OrthogPoly<T> 
00376     max(const OrthogPoly<T>& a, 
00377   const typename OrthogPoly<T>::value_type& b);
00378 
00379     template <typename T> OrthogPoly<T> 
00380     min(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00381 
00382     template <typename T> OrthogPoly<T> 
00383     min(const typename OrthogPoly<T>::value_type& a, 
00384   const OrthogPoly<T>& b);
00385 
00386     template <typename T> OrthogPoly<T> 
00387     min(const OrthogPoly<T>& a, 
00388   const typename OrthogPoly<T>::value_type& b);
00389 
00390     template <typename T> bool 
00391     operator==(const OrthogPoly<T>& a,
00392          const OrthogPoly<T>& b);
00393 
00394     template <typename T> bool 
00395     operator==(const typename OrthogPoly<T>::value_type& a,
00396          const OrthogPoly<T>& b);
00397 
00398     template <typename T> bool 
00399     operator==(const OrthogPoly<T>& a,
00400          const typename OrthogPoly<T>::value_type& b);
00401 
00402     template <typename T> bool 
00403     operator!=(const OrthogPoly<T>& a,
00404          const OrthogPoly<T>& b);
00405 
00406     template <typename T> bool 
00407     operator!=(const typename OrthogPoly<T>::value_type& a,
00408          const OrthogPoly<T>& b);
00409 
00410     template <typename T> bool 
00411     operator!=(const OrthogPoly<T>& a,
00412          const typename OrthogPoly<T>::value_type& b);
00413 
00414     template <typename T> bool 
00415     operator<=(const OrthogPoly<T>& a,
00416          const OrthogPoly<T>& b);
00417 
00418     template <typename T> bool 
00419     operator<=(const typename OrthogPoly<T>::value_type& a,
00420          const OrthogPoly<T>& b);
00421 
00422     template <typename T> bool 
00423     operator<=(const OrthogPoly<T>& a,
00424          const typename OrthogPoly<T>::value_type& b);
00425 
00426     template <typename T> bool 
00427     operator>=(const OrthogPoly<T>& a,
00428          const OrthogPoly<T>& b);
00429 
00430     template <typename T> bool 
00431     operator>=(const typename OrthogPoly<T>::value_type& a,
00432          const OrthogPoly<T>& b);
00433 
00434     template <typename T> bool 
00435     operator>=(const OrthogPoly<T>& a,
00436          const typename OrthogPoly<T>::value_type& b);
00437 
00438     template <typename T> bool 
00439     operator<(const OrthogPoly<T>& a,
00440         const OrthogPoly<T>& b);
00441 
00442     template <typename T> bool 
00443     operator<(const typename OrthogPoly<T>::value_type& a,
00444         const OrthogPoly<T>& b);
00445 
00446     template <typename T> bool 
00447     operator<(const OrthogPoly<T>& a,
00448         const typename OrthogPoly<T>::value_type& b);
00449 
00450     template <typename T> bool 
00451     operator>(const OrthogPoly<T>& a,
00452         const OrthogPoly<T>& b);
00453 
00454     template <typename T> bool 
00455     operator>(const typename OrthogPoly<T>::value_type& a,
00456         const OrthogPoly<T>& b);
00457 
00458     template <typename T> bool 
00459     operator>(const OrthogPoly<T>& a,
00460         const typename OrthogPoly<T>::value_type& b);
00461 
00462     template <typename T> std::ostream& 
00463     operator << (std::ostream& os, const OrthogPoly<T>& a);
00464 
00465   } // namespace PCE
00466 
00467 } // namespace Sacado
00468 
00469 #include "Sacado_PCE_OrthogPolyTraits.hpp"
00470 #include "Sacado_PCE_OrthogPolyImp.hpp"
00471 
00472 #endif // HAVE_SACADO_STOKHOS
00473 
00474 #endif // SACADO_PCE_UNIVARIATEHERMITE_HPP

Generated on Wed May 12 21:59:04 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7