Sacado_MathFunctions.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 the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
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_MATHFUNCTIONS_HPP
00033 #define SACADO_MATHFUNCTIONS_HPP
00034 
00035 #define UNARYFUNC_MACRO(OP,FADOP)         \
00036 namespace Sacado {              \
00037                   \
00038   namespace Fad {             \
00039     template <typename T> class FADOP;          \
00040     template <typename T> class Expr;         \
00041     template <typename T>           \
00042     Expr< FADOP< Expr<T> > > OP (const Expr<T>&);     \
00043     template <typename T> class SimpleFad;        \
00044     template <typename T>           \
00045     SimpleFad<T> OP (const SimpleFad<T>&);        \
00046   }                 \
00047                   \
00048   namespace ELRFad {              \
00049     template <typename T> class FADOP;          \
00050     template <typename T> class Expr;         \
00051     template <typename T>           \
00052     Expr< FADOP< Expr<T> > > OP (const Expr<T>&);     \
00053   }                 \
00054                   \
00055   namespace CacheFad {              \
00056     template <typename T> class FADOP;          \
00057     template <typename T> class Expr;         \
00058     template <typename T>           \
00059     Expr< FADOP< Expr<T> > > OP (const Expr<T>&);     \
00060   }                 \
00061                   \
00062   namespace LFad {              \
00063     template <typename T> class FADOP;          \
00064     template <typename T> class Expr;         \
00065     template <typename T>           \
00066     Expr< FADOP< Expr<T> > > OP (const Expr<T>&);     \
00067   }                 \
00068                   \
00069   namespace Tay {             \
00070     template <typename T> class Taylor;         \
00071     template <typename T> Taylor<T> OP (const Taylor<T>&);    \
00072   }                 \
00073                   \
00074   namespace PCE {             \
00075     template <typename T> class OrthogPoly;       \
00076     template <typename T>           \
00077     OrthogPoly<T> OP (const OrthogPoly<T>&);        \
00078   }                 \
00079                   \
00080   namespace FlopCounterPack {           \
00081     template <typename T> class ScalarFlopCounter;      \
00082     template <typename T>           \
00083     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&);    \
00084   }                 \
00085                   \
00086   namespace Rad {             \
00087     template <typename T> class ADvari;         \
00088     template <typename T> class IndepADvar;       \
00089     template <typename T> ADvari<T>& OP (const ADvari<T>&);   \
00090     template <typename T> ADvari<T>& OP (const IndepADvar<T>&);   \
00091   }                 \
00092 }                                                                       \
00093                                                                         \
00094 namespace std {                                                         \
00095   using Sacado::Fad::OP;            \
00096   using Sacado::ELRFad::OP;           \
00097   using Sacado::CacheFad::OP;           \
00098   using Sacado::LFad::OP;           \
00099   using Sacado::Tay::OP;            \
00100   using Sacado::PCE::OP;            \
00101   using Sacado::FlopCounterPack::OP;          \
00102   using Sacado::Rad::OP;            \
00103 }
00104 
00105 UNARYFUNC_MACRO(exp, ExpOp)
00106 UNARYFUNC_MACRO(log, LogOp)
00107 UNARYFUNC_MACRO(log10, Log10Op)
00108 UNARYFUNC_MACRO(sqrt, SqrtOp)
00109 UNARYFUNC_MACRO(cos, CosOp)
00110 UNARYFUNC_MACRO(sin, SinOp)
00111 UNARYFUNC_MACRO(tan, TanOp)
00112 UNARYFUNC_MACRO(acos, ACosOp)
00113 UNARYFUNC_MACRO(asin, ASinOp)
00114 UNARYFUNC_MACRO(atan, ATanOp)
00115 UNARYFUNC_MACRO(cosh, CoshOp)
00116 UNARYFUNC_MACRO(sinh, SinhOp)
00117 UNARYFUNC_MACRO(tanh, TanhOp)
00118 UNARYFUNC_MACRO(acosh, ACoshOp)
00119 UNARYFUNC_MACRO(asinh, ASinhOp)
00120 UNARYFUNC_MACRO(atanh, ATanhOp)
00121 UNARYFUNC_MACRO(abs, AbsOp)
00122 UNARYFUNC_MACRO(fabs, FAbsOp)
00123 
00124 #undef UNARYFUNC_MACRO
00125 
00126 #define BINARYFUNC_MACRO(OP,FADOP)          \
00127 namespace Sacado {              \
00128                   \
00129   namespace Fad {             \
00130     template <typename T1, typename T2> class FADOP;      \
00131     template <typename T> class Expr;         \
00132                   \
00133     template <typename T1, typename T2>         \
00134     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00135     OP (const Expr<T1>&, const Expr<T2>&);        \
00136                   \
00137     template <typename T>           \
00138     Expr< FADOP< Expr<T>, Expr<T> > >         \
00139     OP (const Expr<T>&, const Expr<T>&);        \
00140                   \
00141     template <typename T>           \
00142     Expr< FADOP< typename Expr<T>::value_type, Expr<T> > >    \
00143     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00144                   \
00145     template <typename T>           \
00146     Expr< FADOP< Expr<T>, typename Expr<T>::value_type > >    \
00147     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00148                   \
00149     template <typename T> class SimpleFad;        \
00150     template <typename T>           \
00151     SimpleFad<T>              \
00152     OP (const SimpleFad<T>&, const SimpleFad<T>&);      \
00153                   \
00154     template <typename T>           \
00155     SimpleFad<T>              \
00156     OP (const SimpleFad<T>&,            \
00157   const typename SimpleFad<T>::value_type&);      \
00158                   \
00159     template <typename T>           \
00160     SimpleFad<T>              \
00161     OP (const typename SimpleFad<T>::value_type&,     \
00162   const SimpleFad<T>&);           \
00163   }                 \
00164                   \
00165   namespace ELRFad {              \
00166     template <typename T1, typename T2> class FADOP;      \
00167     template <typename T> class Expr;         \
00168     template <typename T> class ConstExpr;        \
00169     template <typename T1, typename T2>         \
00170     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00171     OP (const Expr<T1>&, const Expr<T2>&);        \
00172                   \
00173     template <typename T>           \
00174     Expr< FADOP< Expr<T>, Expr<T> > >         \
00175     OP (const Expr<T>&, const Expr<T>&);        \
00176                   \
00177     template <typename T>           \
00178     Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
00179     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00180                   \
00181     template <typename T>           \
00182     Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
00183     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00184   }                 \
00185                   \
00186   namespace CacheFad {              \
00187     template <typename T1, typename T2> class FADOP;      \
00188     template <typename T> class Expr;         \
00189     template <typename T> class ConstExpr;        \
00190     template <typename T1, typename T2>         \
00191     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00192     OP (const Expr<T1>&, const Expr<T2>&);        \
00193                   \
00194     template <typename T>           \
00195     Expr< FADOP< Expr<T>, Expr<T> > >         \
00196     OP (const Expr<T>&, const Expr<T>&);        \
00197                   \
00198     template <typename T>           \
00199     Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
00200     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00201                   \
00202     template <typename T>           \
00203     Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
00204     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00205   }                 \
00206                   \
00207   namespace LFad {              \
00208     template <typename T1, typename T2> class FADOP;      \
00209     template <typename T> class Expr;         \
00210                   \
00211     template <typename T1, typename T2>         \
00212     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00213     OP (const Expr<T1>&, const Expr<T2>&);        \
00214                   \
00215     template <typename T>           \
00216     Expr< FADOP< Expr<T>, Expr<T> > >         \
00217     OP (const Expr<T>&, const Expr<T>&);        \
00218                   \
00219     template <typename T>           \
00220     Expr< FADOP< typename Expr<T>::value_type, Expr<T> > >    \
00221     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00222                   \
00223     template <typename T>           \
00224     Expr< FADOP< Expr<T>, typename Expr<T>::value_type > >    \
00225     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00226   }                 \
00227                   \
00228   namespace Tay {             \
00229     template <typename T> class Taylor;         \
00230     template <typename T> Taylor<T> OP (const Taylor<T>&,   \
00231           const Taylor<T>&);    \
00232     template <typename T> Taylor<T> OP (const T&,     \
00233           const Taylor<T>&);    \
00234     template <typename T> Taylor<T> OP (const Taylor<T>&,   \
00235           const T&);      \
00236   }                 \
00237                   \
00238   namespace PCE {             \
00239     template <typename T> class OrthogPoly;       \
00240     template <typename T>           \
00241     OrthogPoly<T> OP (const OrthogPoly<T>&,       \
00242           const OrthogPoly<T>&);        \
00243     template <typename T>           \
00244     OrthogPoly<T> OP (const T&,           \
00245           const OrthogPoly<T>&);        \
00246     template <typename T>           \
00247     OrthogPoly<T> OP (const OrthogPoly<T>&,       \
00248           const T&);          \
00249   }                 \
00250                   \
00251   namespace FlopCounterPack {           \
00252     template <typename T> class ScalarFlopCounter;      \
00253     template <typename T>           \
00254     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&,   \
00255            const ScalarFlopCounter<T>&);    \
00256     template <typename T>           \
00257     ScalarFlopCounter<T> OP (const T&,          \
00258            const ScalarFlopCounter<T>);   \
00259     template <typename T>           \
00260     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&,   \
00261            const T&);         \
00262     template <typename T>           \
00263     ScalarFlopCounter<T> OP (const int&,        \
00264            const ScalarFlopCounter<T>);   \
00265     template <typename T>           \
00266     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&,   \
00267            const int&);       \
00268   }                 \
00269                   \
00270   namespace Rad {             \
00271     template <typename T> class ADvari;         \
00272     template <typename T> class IndepADvar;       \
00273     template <typename T> class DoubleAvoid;        \
00274     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00275            const ADvari<T>&);   \
00276     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00277            const ADvari<T>&);   \
00278     template <typename T> ADvari<T>& OP (T,       \
00279            const ADvari<T>&);   \
00280     template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype, \
00281            const ADvari<T>&);   \
00282     template <typename T> ADvari<T>& OP (int,       \
00283            const ADvari<T>&);   \
00284     template <typename T> ADvari<T>& OP (long,        \
00285            const ADvari<T>&);   \
00286     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00287            const IndepADvar<T>&);   \
00288     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00289            T);        \
00290     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00291            typename DoubleAvoid<T>::dtype); \
00292     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00293            int);        \
00294     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00295            long);       \
00296     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00297            const IndepADvar<T>&);   \
00298     template <typename T> ADvari<T>& OP (T,       \
00299            const IndepADvar<T>&);   \
00300     template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype, \
00301            const IndepADvar<T>&);   \
00302     template <typename T> ADvari<T>& OP (int,       \
00303            const IndepADvar<T>&);   \
00304     template <typename T> ADvari<T>& OP (long,        \
00305            const IndepADvar<T>&);   \
00306     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00307            T);        \
00308     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00309            typename DoubleAvoid<T>::dtype); \
00310     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00311            int);        \
00312     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00313            long);       \
00314   }                 \
00315                   \
00316 }                 \
00317                                                                         \
00318 namespace std {                                                         \
00319   using Sacado::Fad::OP;            \
00320   using Sacado::ELRFad::OP;           \
00321   using Sacado::CacheFad::OP;           \
00322   using Sacado::LFad::OP;           \
00323   using Sacado::Tay::OP;            \
00324   using Sacado::PCE::OP;            \
00325   using Sacado::FlopCounterPack::OP;          \
00326   using Sacado::Rad::OP;            \
00327 }
00328 
00329 BINARYFUNC_MACRO(atan2, Atan2Op)
00330 BINARYFUNC_MACRO(pow, PowerOp)
00331 BINARYFUNC_MACRO(max, MaxOp)
00332 BINARYFUNC_MACRO(min, MinOp)
00333 
00334 #undef BINARYFUNC_MACRO
00335 
00336 #endif // SACADO_MATHFUNCTIONS_HPP

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