Sacado Package Browser (Single Doxygen Collection) Version of the Day
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 ELRCacheFad {           \
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 LFad {              \
00070     template <typename T> class FADOP;          \
00071     template <typename T> class Expr;         \
00072     template <typename T>           \
00073     Expr< FADOP< Expr<T> > > OP (const Expr<T>&);     \
00074   }                 \
00075                   \
00076   namespace Tay {             \
00077     template <typename T> class Taylor;         \
00078     template <typename T> Taylor<T> OP (const Taylor<T>&);    \
00079   }                 \
00080                   \
00081   namespace PCE {             \
00082     template <typename T> class OrthogPoly;       \
00083     template <typename T>           \
00084     OrthogPoly<T> OP (const OrthogPoly<T>&);        \
00085   }                 \
00086                   \
00087   namespace FlopCounterPack {           \
00088     template <typename T> class ScalarFlopCounter;      \
00089     template <typename T>           \
00090     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&);    \
00091   }                 \
00092                   \
00093   namespace Rad {             \
00094     template <typename T> class ADvari;         \
00095     template <typename T> class IndepADvar;       \
00096     template <typename T> ADvari<T>& OP (const ADvari<T>&);   \
00097     template <typename T> ADvari<T>& OP (const IndepADvar<T>&);   \
00098   }                 \
00099 }                                                                       \
00100                                                                         \
00101 namespace std {                                                         \
00102   using Sacado::Fad::OP;            \
00103   using Sacado::ELRFad::OP;           \
00104   using Sacado::CacheFad::OP;           \
00105   using Sacado::ELRCacheFad::OP;          \
00106   using Sacado::LFad::OP;           \
00107   using Sacado::Tay::OP;            \
00108   using Sacado::PCE::OP;            \
00109   using Sacado::FlopCounterPack::OP;          \
00110   using Sacado::Rad::OP;            \
00111 }
00112 
00113 UNARYFUNC_MACRO(exp, ExpOp)
00114 UNARYFUNC_MACRO(log, LogOp)
00115 UNARYFUNC_MACRO(log10, Log10Op)
00116 UNARYFUNC_MACRO(sqrt, SqrtOp)
00117 UNARYFUNC_MACRO(cos, CosOp)
00118 UNARYFUNC_MACRO(sin, SinOp)
00119 UNARYFUNC_MACRO(tan, TanOp)
00120 UNARYFUNC_MACRO(acos, ACosOp)
00121 UNARYFUNC_MACRO(asin, ASinOp)
00122 UNARYFUNC_MACRO(atan, ATanOp)
00123 UNARYFUNC_MACRO(cosh, CoshOp)
00124 UNARYFUNC_MACRO(sinh, SinhOp)
00125 UNARYFUNC_MACRO(tanh, TanhOp)
00126 UNARYFUNC_MACRO(acosh, ACoshOp)
00127 UNARYFUNC_MACRO(asinh, ASinhOp)
00128 UNARYFUNC_MACRO(atanh, ATanhOp)
00129 UNARYFUNC_MACRO(abs, AbsOp)
00130 UNARYFUNC_MACRO(fabs, FAbsOp)
00131 
00132 #undef UNARYFUNC_MACRO
00133 
00134 #define BINARYFUNC_MACRO(OP,FADOP)          \
00135 namespace Sacado {              \
00136                   \
00137   namespace Fad {             \
00138     template <typename T1, typename T2> class FADOP;      \
00139     template <typename T> class Expr;         \
00140                   \
00141     template <typename T1, typename T2>         \
00142     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00143     OP (const Expr<T1>&, const Expr<T2>&);        \
00144                   \
00145     template <typename T>           \
00146     Expr< FADOP< Expr<T>, Expr<T> > >         \
00147     OP (const Expr<T>&, const Expr<T>&);        \
00148                   \
00149     template <typename T>           \
00150     Expr< FADOP< typename Expr<T>::value_type, Expr<T> > >    \
00151     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00152                   \
00153     template <typename T>           \
00154     Expr< FADOP< Expr<T>, typename Expr<T>::value_type > >    \
00155     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00156                   \
00157     template <typename T> class SimpleFad;        \
00158     template <typename T>           \
00159     SimpleFad<T>              \
00160     OP (const SimpleFad<T>&, const SimpleFad<T>&);      \
00161                   \
00162     template <typename T>           \
00163     SimpleFad<T>              \
00164     OP (const SimpleFad<T>&,            \
00165   const typename SimpleFad<T>::value_type&);      \
00166                   \
00167     template <typename T>           \
00168     SimpleFad<T>              \
00169     OP (const typename SimpleFad<T>::value_type&,     \
00170   const SimpleFad<T>&);           \
00171   }                 \
00172                   \
00173   namespace ELRFad {              \
00174     template <typename T1, typename T2> class FADOP;      \
00175     template <typename T> class Expr;         \
00176     template <typename T> class ConstExpr;        \
00177     template <typename T1, typename T2>         \
00178     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00179     OP (const Expr<T1>&, const Expr<T2>&);        \
00180                   \
00181     template <typename T>           \
00182     Expr< FADOP< Expr<T>, Expr<T> > >         \
00183     OP (const Expr<T>&, const Expr<T>&);        \
00184                   \
00185     template <typename T>           \
00186     Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
00187     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00188                   \
00189     template <typename T>           \
00190     Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
00191     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00192   }                 \
00193                   \
00194   namespace CacheFad {              \
00195     template <typename T1, typename T2> class FADOP;      \
00196     template <typename T> class Expr;         \
00197     template <typename T> class ConstExpr;        \
00198     template <typename T1, typename T2>         \
00199     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00200     OP (const Expr<T1>&, const Expr<T2>&);        \
00201                   \
00202     template <typename T>           \
00203     Expr< FADOP< Expr<T>, Expr<T> > >         \
00204     OP (const Expr<T>&, const Expr<T>&);        \
00205                   \
00206     template <typename T>           \
00207     Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
00208     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00209                   \
00210     template <typename T>           \
00211     Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
00212     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00213   }                 \
00214                   \
00215   namespace ELRCacheFad {           \
00216     template <typename T1, typename T2> class FADOP;      \
00217     template <typename T> class Expr;         \
00218     template <typename T> class ConstExpr;        \
00219     template <typename T1, typename T2>         \
00220     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00221     OP (const Expr<T1>&, const Expr<T2>&);        \
00222                   \
00223     template <typename T>           \
00224     Expr< FADOP< Expr<T>, Expr<T> > >         \
00225     OP (const Expr<T>&, const Expr<T>&);        \
00226                   \
00227     template <typename T>           \
00228     Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
00229     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00230                   \
00231     template <typename T>           \
00232     Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
00233     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00234   }                 \
00235                   \
00236   namespace LFad {              \
00237     template <typename T1, typename T2> class FADOP;      \
00238     template <typename T> class Expr;         \
00239                   \
00240     template <typename T1, typename T2>         \
00241     Expr< FADOP< Expr<T1>, Expr<T2> > >         \
00242     OP (const Expr<T1>&, const Expr<T2>&);        \
00243                   \
00244     template <typename T>           \
00245     Expr< FADOP< Expr<T>, Expr<T> > >         \
00246     OP (const Expr<T>&, const Expr<T>&);        \
00247                   \
00248     template <typename T>           \
00249     Expr< FADOP< typename Expr<T>::value_type, Expr<T> > >    \
00250     OP (const typename Expr<T>::value_type&, const Expr<T>&);   \
00251                   \
00252     template <typename T>           \
00253     Expr< FADOP< Expr<T>, typename Expr<T>::value_type > >    \
00254     OP (const Expr<T>&, const typename Expr<T>::value_type&);   \
00255   }                 \
00256                   \
00257   namespace Tay {             \
00258     template <typename T> class Taylor;         \
00259     template <typename T> Taylor<T> OP (const Taylor<T>&,   \
00260           const Taylor<T>&);    \
00261     template <typename T> Taylor<T> OP (const T&,     \
00262           const Taylor<T>&);    \
00263     template <typename T> Taylor<T> OP (const Taylor<T>&,   \
00264           const T&);      \
00265   }                 \
00266                   \
00267   namespace PCE {             \
00268     template <typename T> class OrthogPoly;       \
00269     template <typename T>           \
00270     OrthogPoly<T> OP (const OrthogPoly<T>&,       \
00271           const OrthogPoly<T>&);        \
00272     template <typename T>           \
00273     OrthogPoly<T> OP (const T&,           \
00274           const OrthogPoly<T>&);        \
00275     template <typename T>           \
00276     OrthogPoly<T> OP (const OrthogPoly<T>&,       \
00277           const T&);          \
00278   }                 \
00279                   \
00280   namespace FlopCounterPack {           \
00281     template <typename T> class ScalarFlopCounter;      \
00282     template <typename T>           \
00283     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&,   \
00284            const ScalarFlopCounter<T>&);    \
00285     template <typename T>           \
00286     ScalarFlopCounter<T> OP (const T&,          \
00287            const ScalarFlopCounter<T>);   \
00288     template <typename T>           \
00289     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&,   \
00290            const T&);         \
00291     template <typename T>           \
00292     ScalarFlopCounter<T> OP (const int&,        \
00293            const ScalarFlopCounter<T>);   \
00294     template <typename T>           \
00295     ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&,   \
00296            const int&);       \
00297   }                 \
00298                   \
00299   namespace Rad {             \
00300     template <typename T> class ADvari;         \
00301     template <typename T> class IndepADvar;       \
00302     template <typename T> class DoubleAvoid;        \
00303     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00304            const ADvari<T>&);   \
00305     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00306            const ADvari<T>&);   \
00307     template <typename T> ADvari<T>& OP (T,       \
00308            const ADvari<T>&);   \
00309     template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype, \
00310            const ADvari<T>&);   \
00311     template <typename T> ADvari<T>& OP (int,       \
00312            const ADvari<T>&);   \
00313     template <typename T> ADvari<T>& OP (long,        \
00314            const ADvari<T>&);   \
00315     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00316            const IndepADvar<T>&);   \
00317     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00318            T);        \
00319     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00320            typename DoubleAvoid<T>::dtype); \
00321     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00322            int);        \
00323     template <typename T> ADvari<T>& OP (const ADvari<T>&,    \
00324            long);       \
00325     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00326            const IndepADvar<T>&);   \
00327     template <typename T> ADvari<T>& OP (T,       \
00328            const IndepADvar<T>&);   \
00329     template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype, \
00330            const IndepADvar<T>&);   \
00331     template <typename T> ADvari<T>& OP (int,       \
00332            const IndepADvar<T>&);   \
00333     template <typename T> ADvari<T>& OP (long,        \
00334            const IndepADvar<T>&);   \
00335     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00336            T);        \
00337     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00338            typename DoubleAvoid<T>::dtype); \
00339     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00340            int);        \
00341     template <typename T> ADvari<T>& OP (const IndepADvar<T>&,    \
00342            long);       \
00343   }                 \
00344                   \
00345 }                 \
00346                                                                         \
00347 namespace std {                                                         \
00348   using Sacado::Fad::OP;            \
00349   using Sacado::ELRFad::OP;           \
00350   using Sacado::CacheFad::OP;           \
00351   using Sacado::ELRCacheFad::OP;          \
00352   using Sacado::LFad::OP;           \
00353   using Sacado::Tay::OP;            \
00354   using Sacado::PCE::OP;            \
00355   using Sacado::FlopCounterPack::OP;          \
00356   using Sacado::Rad::OP;            \
00357 }
00358 
00359 BINARYFUNC_MACRO(atan2, Atan2Op)
00360 BINARYFUNC_MACRO(pow, PowerOp)
00361 BINARYFUNC_MACRO(max, MaxOp)
00362 BINARYFUNC_MACRO(min, MinOp)
00363 
00364 #undef BINARYFUNC_MACRO
00365 
00366 #endif // SACADO_MATHFUNCTIONS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines