Sacado_PCE_OrthogPoly.hpp

Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
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 #include "Sacado_ConfigDefs.h"
00036 
00037 #ifdef HAVE_SACADO_STOKHOS
00038 
00039 #include "Teuchos_RCP.hpp"
00040 
00041 #include "Sacado_Handle.hpp"
00042 
00043 #include "Stokhos_OrthogPolyExpansion.hpp"
00044 #include "Stokhos_OrthogPolyApprox.hpp"
00045 
00046 #include <cmath>
00047 #include <algorithm>  // for std::min and std::max
00048 #include <ostream>  // for std::ostream
00049 
00050 namespace Sacado {
00051 
00053   namespace PCE {
00054 
00056 
00060     template <typename T> 
00061     class OrthogPoly {
00062     public:
00063 
00065       template <typename U> 
00066       struct apply {
00067   typedef OrthogPoly<U> type;
00068       };
00069 
00071       typedef T value_type;
00072 
00074       typedef int ordinal_type;
00075 
00077       typedef Stokhos::OrthogPolyBasis<ordinal_type,T> basis_type;
00078 
00080       typedef Stokhos::OrthogPolyExpansion<ordinal_type,T> expansion_type;
00081 
00083 
00086       OrthogPoly();
00087 
00089 
00092       OrthogPoly(const value_type& x);
00093 
00095 
00098       OrthogPoly(const Teuchos::RCP<expansion_type>& expansion);
00099 
00101       OrthogPoly(const OrthogPoly& x);
00102 
00104       ~OrthogPoly();
00105 
00107 
00110       void reset(const Teuchos::RCP<expansion_type>& expansion);
00111 
00113 
00122       void copyForWrite() { th.makeOwnCopy(); }
00123 
00125       value_type evaluate(const std::vector<value_type>& point) const;
00126 
00128       value_type evaluate(const std::vector<value_type>& point,
00129                           const std::vector<value_type>& bvals) const;
00130 
00135 
00137       OrthogPoly<T>& operator=(const value_type& val);
00138 
00140       OrthogPoly<T>& operator=(const OrthogPoly<T>& x);
00141 
00143 
00148 
00150       Teuchos::RCP<basis_type> basis() const { return th->basis(); }
00151 
00153       Teuchos::RCP<expansion_type> expansion() const { return expansion_; }
00154 
00156 
00161 
00163       const value_type& val() const { return (*th)[0]; }
00164 
00166       value_type& val() { return (*th)[0]; }
00167 
00169 
00174 
00176       ordinal_type size() const { return th->size();}
00177 
00179       bool hasFastAccess(ordinal_type sz) const { return th->size()>=sz;}
00180 
00182       const value_type* coeff() const { return th->coeff();}
00183 
00185       value_type* coeff() { return th->coeff();}
00186 
00188       value_type coeff(ordinal_type i) const { 
00189   value_type tmp= i<th->size() ? (*th)[i]:value_type(0.); return tmp;}
00190     
00192       value_type& fastAccessCoeff(ordinal_type i) { return (*th)[i];}
00193 
00195       value_type fastAccessCoeff(ordinal_type i) const { return (*th)[i];}
00196     
00198 
00203 
00205       OrthogPoly<T> operator + () const;
00206 
00208       OrthogPoly<T> operator - () const;
00209 
00211       OrthogPoly<T>& operator += (const value_type& x);
00212 
00214       OrthogPoly<T>& operator -= (const value_type& x);
00215 
00217       OrthogPoly<T>& operator *= (const value_type& x);
00218 
00220       OrthogPoly<T>& operator /= (const value_type& x);
00221 
00223       OrthogPoly<T>& operator += (const OrthogPoly<T>& x);
00224 
00226       OrthogPoly<T>& operator -= (const OrthogPoly<T>& x);
00227   
00229       OrthogPoly<T>& operator *= (const OrthogPoly<T>& x);
00230 
00232       OrthogPoly<T>& operator /= (const OrthogPoly<T>& x);
00233 
00235 
00237       const Stokhos::OrthogPolyApprox<int,value_type>& getOrthogPolyApprox() const 
00238       { return *th; }
00239 
00241       Stokhos::OrthogPolyApprox<int,value_type>& getOrthogPolyApprox() { 
00242   return *th; }
00243 
00244     protected:
00245 
00247       Teuchos::RCP<expansion_type> expansion_;
00248 
00249       Sacado::Handle< Stokhos::OrthogPolyApprox<int,value_type> > th;
00250 
00251     }; // class Hermite
00252 
00253     // Operations
00254     template <typename T> OrthogPoly<T> 
00255     operator+(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00256 
00257     template <typename T> OrthogPoly<T> 
00258     operator+(const typename OrthogPoly<T>::value_type& a, 
00259         const OrthogPoly<T>& b);
00260 
00261     template <typename T> OrthogPoly<T> 
00262     operator+(const OrthogPoly<T>& a, 
00263         const typename OrthogPoly<T>::value_type& b);
00264 
00265     template <typename T> OrthogPoly<T> 
00266     operator-(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00267 
00268     template <typename T> OrthogPoly<T> 
00269     operator-(const typename OrthogPoly<T>::value_type& a, 
00270         const OrthogPoly<T>& b);
00271 
00272     template <typename T> OrthogPoly<T> 
00273     operator-(const OrthogPoly<T>& a, 
00274         const typename OrthogPoly<T>::value_type& b);
00275 
00276     template <typename T> OrthogPoly<T> 
00277     operator*(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00278 
00279     template <typename T> OrthogPoly<T> 
00280     operator*(const typename OrthogPoly<T>::value_type& a, 
00281         const OrthogPoly<T>& b);
00282 
00283     template <typename T> OrthogPoly<T> 
00284     operator*(const OrthogPoly<T>& a, 
00285         const typename OrthogPoly<T>::value_type& b);
00286 
00287     template <typename T> OrthogPoly<T> 
00288     operator/(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00289 
00290     template <typename T> OrthogPoly<T> 
00291     operator/(const typename OrthogPoly<T>::value_type& a, 
00292         const OrthogPoly<T>& b);
00293 
00294     template <typename T> OrthogPoly<T> 
00295     operator/(const OrthogPoly<T>& a, 
00296         const typename OrthogPoly<T>::value_type& b);
00297 
00298     template <typename T> OrthogPoly<T> 
00299     exp(const OrthogPoly<T>& a);
00300 
00301     template <typename T> OrthogPoly<T> 
00302     log(const OrthogPoly<T>& a);
00303 
00304     template <typename T> OrthogPoly<T> 
00305     log10(const OrthogPoly<T>& a);
00306 
00307     template <typename T> OrthogPoly<T> 
00308     sqrt(const OrthogPoly<T>& a);
00309 
00310     template <typename T> OrthogPoly<T> 
00311     pow(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00312 
00313     template <typename T> OrthogPoly<T> 
00314     pow(const T& a, 
00315   const OrthogPoly<T>& b);
00316 
00317     template <typename T> OrthogPoly<T> 
00318     pow(const OrthogPoly<T>& a, 
00319   const T& b);
00320 
00321     template <typename T> OrthogPoly<T> 
00322     cos(const OrthogPoly<T>& a);
00323 
00324     template <typename T> OrthogPoly<T> 
00325     sin(const OrthogPoly<T>& a);
00326 
00327     template <typename T> OrthogPoly<T> 
00328     tan(const OrthogPoly<T>& a);
00329 
00330     template <typename T> OrthogPoly<T> 
00331     cosh(const OrthogPoly<T>& a);
00332 
00333     template <typename T> OrthogPoly<T>
00334     sinh(const OrthogPoly<T>& a);
00335 
00336     template <typename T> OrthogPoly<T> 
00337     tanh(const OrthogPoly<T>& a);
00338 
00339     template <typename T> OrthogPoly<T> 
00340     acos(const OrthogPoly<T>& a);
00341 
00342     template <typename T> OrthogPoly<T> 
00343     asin(const OrthogPoly<T>& a);
00344 
00345     template <typename T> OrthogPoly<T> 
00346     atan(const OrthogPoly<T>& a);
00347 
00348     template <typename T> OrthogPoly<T> 
00349     atan2(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00350 
00351     template <typename T> OrthogPoly<T> 
00352     atan2(const typename OrthogPoly<T>::value_type& a, 
00353     const OrthogPoly<T>& b);
00354 
00355     template <typename T> OrthogPoly<T> 
00356     atan2(const OrthogPoly<T>& a, 
00357     const typename OrthogPoly<T>::value_type& b);
00358 
00359     template <typename T> OrthogPoly<T> 
00360     acosh(const OrthogPoly<T>& a);
00361 
00362     template <typename T> OrthogPoly<T> 
00363     asinh(const OrthogPoly<T>& a);
00364 
00365     template <typename T> OrthogPoly<T> 
00366     atanh(const OrthogPoly<T>& a);
00367 
00368     template <typename T> OrthogPoly<T> 
00369     abs(const OrthogPoly<T>& a);
00370     
00371     template <typename T> OrthogPoly<T> 
00372     fabs(const OrthogPoly<T>& a);
00373 
00374     template <typename T> OrthogPoly<T> 
00375     max(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00376 
00377     template <typename T> OrthogPoly<T> 
00378     max(const typename OrthogPoly<T>::value_type& a, 
00379   const OrthogPoly<T>& b);
00380 
00381     template <typename T> OrthogPoly<T> 
00382     max(const OrthogPoly<T>& a, 
00383   const typename OrthogPoly<T>::value_type& b);
00384 
00385     template <typename T> OrthogPoly<T> 
00386     min(const OrthogPoly<T>& a, const OrthogPoly<T>& b);
00387 
00388     template <typename T> OrthogPoly<T> 
00389     min(const typename OrthogPoly<T>::value_type& a, 
00390   const OrthogPoly<T>& b);
00391 
00392     template <typename T> OrthogPoly<T> 
00393     min(const OrthogPoly<T>& a, 
00394   const typename OrthogPoly<T>::value_type& b);
00395 
00396     template <typename T> bool 
00397     operator==(const OrthogPoly<T>& a,
00398          const OrthogPoly<T>& b);
00399 
00400     template <typename T> bool 
00401     operator==(const typename OrthogPoly<T>::value_type& a,
00402          const OrthogPoly<T>& b);
00403 
00404     template <typename T> bool 
00405     operator==(const OrthogPoly<T>& a,
00406          const typename OrthogPoly<T>::value_type& b);
00407 
00408     template <typename T> bool 
00409     operator!=(const OrthogPoly<T>& a,
00410          const OrthogPoly<T>& b);
00411 
00412     template <typename T> bool 
00413     operator!=(const typename OrthogPoly<T>::value_type& a,
00414          const OrthogPoly<T>& b);
00415 
00416     template <typename T> bool 
00417     operator!=(const OrthogPoly<T>& a,
00418          const typename OrthogPoly<T>::value_type& b);
00419 
00420     template <typename T> bool 
00421     operator<=(const OrthogPoly<T>& a,
00422          const OrthogPoly<T>& b);
00423 
00424     template <typename T> bool 
00425     operator<=(const typename OrthogPoly<T>::value_type& a,
00426          const OrthogPoly<T>& b);
00427 
00428     template <typename T> bool 
00429     operator<=(const OrthogPoly<T>& a,
00430          const typename OrthogPoly<T>::value_type& b);
00431 
00432     template <typename T> bool 
00433     operator>=(const OrthogPoly<T>& a,
00434          const OrthogPoly<T>& b);
00435 
00436     template <typename T> bool 
00437     operator>=(const typename OrthogPoly<T>::value_type& a,
00438          const OrthogPoly<T>& b);
00439 
00440     template <typename T> bool 
00441     operator>=(const OrthogPoly<T>& a,
00442          const typename OrthogPoly<T>::value_type& b);
00443 
00444     template <typename T> bool 
00445     operator<(const OrthogPoly<T>& a,
00446         const OrthogPoly<T>& b);
00447 
00448     template <typename T> bool 
00449     operator<(const typename OrthogPoly<T>::value_type& a,
00450         const OrthogPoly<T>& b);
00451 
00452     template <typename T> bool 
00453     operator<(const OrthogPoly<T>& a,
00454         const typename OrthogPoly<T>::value_type& b);
00455 
00456     template <typename T> bool 
00457     operator>(const OrthogPoly<T>& a,
00458         const OrthogPoly<T>& b);
00459 
00460     template <typename T> bool 
00461     operator>(const typename OrthogPoly<T>::value_type& a,
00462         const OrthogPoly<T>& b);
00463 
00464     template <typename T> bool 
00465     operator>(const OrthogPoly<T>& a,
00466         const typename OrthogPoly<T>::value_type& b);
00467 
00468     template <typename T> std::ostream& 
00469     operator << (std::ostream& os, const OrthogPoly<T>& a);
00470 
00471   } // namespace PCE
00472 
00473 } // namespace Sacado
00474 
00475 #include "Sacado_PCE_OrthogPolyTraits.hpp"
00476 #include "Sacado_PCE_OrthogPolyImp.hpp"
00477 
00478 #endif // HAVE_SACADO_STOKHOS
00479 
00480 #endif // SACADO_PCE_UNIVARIATEHERMITE_HPP

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