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_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 } \
00044 \
00045 namespace ELRFad { \
00046 template <typename T> class FADOP; \
00047 template <typename T> class Expr; \
00048 template <typename T> \
00049 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
00050 } \
00051 \
00052 namespace CacheFad { \
00053 template <typename T> class FADOP; \
00054 template <typename T> class Expr; \
00055 template <typename T> \
00056 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
00057 } \
00058 \
00059 namespace LFad { \
00060 template <typename T> class FADOP; \
00061 template <typename T> class Expr; \
00062 template <typename T> \
00063 Expr< FADOP< Expr<T> > > OP (const Expr<T>&); \
00064 } \
00065 \
00066 namespace Tay { \
00067 template <typename T> class Taylor; \
00068 template <typename T> Taylor<T> OP (const Taylor<T>&); \
00069 } \
00070 \
00071 namespace PCE { \
00072 template <typename T> class Hermite; \
00073 template <typename T> Hermite<T> OP (const Hermite<T>&); \
00074 \
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 \
00150 namespace ELRFad { \
00151 template <typename T1, typename T2> class FADOP; \
00152 template <typename T> class Expr; \
00153 template <typename T> class ConstExpr; \
00154 template <typename T1, typename T2> \
00155 Expr< FADOP< Expr<T1>, Expr<T2> > > \
00156 OP (const Expr<T1>&, const Expr<T2>&); \
00157 \
00158 template <typename T> \
00159 Expr< FADOP< Expr<T>, Expr<T> > > \
00160 OP (const Expr<T>&, const Expr<T>&); \
00161 \
00162 template <typename T> \
00163 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
00164 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
00165 \
00166 template <typename T> \
00167 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
00168 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
00169 } \
00170 \
00171 namespace CacheFad { \
00172 template <typename T1, typename T2> class FADOP; \
00173 template <typename T> class Expr; \
00174 template <typename T> class ConstExpr; \
00175 template <typename T1, typename T2> \
00176 Expr< FADOP< Expr<T1>, Expr<T2> > > \
00177 OP (const Expr<T1>&, const Expr<T2>&); \
00178 \
00179 template <typename T> \
00180 Expr< FADOP< Expr<T>, Expr<T> > > \
00181 OP (const Expr<T>&, const Expr<T>&); \
00182 \
00183 template <typename T> \
00184 Expr< FADOP< ConstExpr<typename Expr<T>::value_type>, Expr<T> > > \
00185 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
00186 \
00187 template <typename T> \
00188 Expr< FADOP< Expr<T>, ConstExpr<typename Expr<T>::value_type> > > \
00189 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
00190 } \
00191 \
00192 namespace LFad { \
00193 template <typename T1, typename T2> class FADOP; \
00194 template <typename T> class Expr; \
00195 \
00196 template <typename T1, typename T2> \
00197 Expr< FADOP< Expr<T1>, Expr<T2> > > \
00198 OP (const Expr<T1>&, const Expr<T2>&); \
00199 \
00200 template <typename T> \
00201 Expr< FADOP< Expr<T>, Expr<T> > > \
00202 OP (const Expr<T>&, const Expr<T>&); \
00203 \
00204 template <typename T> \
00205 Expr< FADOP< typename Expr<T>::value_type, Expr<T> > > \
00206 OP (const typename Expr<T>::value_type&, const Expr<T>&); \
00207 \
00208 template <typename T> \
00209 Expr< FADOP< Expr<T>, typename Expr<T>::value_type > > \
00210 OP (const Expr<T>&, const typename Expr<T>::value_type&); \
00211 } \
00212 \
00213 namespace Tay { \
00214 template <typename T> class Taylor; \
00215 template <typename T> Taylor<T> OP (const Taylor<T>&, \
00216 const Taylor<T>&); \
00217 template <typename T> Taylor<T> OP (const T&, \
00218 const Taylor<T>&); \
00219 template <typename T> Taylor<T> OP (const Taylor<T>&, \
00220 const T&); \
00221 } \
00222 \
00223 namespace PCE { \
00224 template <typename T> class Hermite; \
00225 template <typename T> Hermite<T> OP (const Hermite<T>&, \
00226 const Hermite<T>&); \
00227 template <typename T> Hermite<T> OP (const T&, \
00228 const Hermite<T>&); \
00229 template <typename T> Hermite<T> OP (const Hermite<T>&, \
00230 const T&); \
00231 \
00232 template <typename T> class OrthogPoly; \
00233 template <typename T> \
00234 OrthogPoly<T> OP (const OrthogPoly<T>&, \
00235 const OrthogPoly<T>&); \
00236 template <typename T> \
00237 OrthogPoly<T> OP (const T&, \
00238 const OrthogPoly<T>&); \
00239 template <typename T> \
00240 OrthogPoly<T> OP (const OrthogPoly<T>&, \
00241 const T&); \
00242 } \
00243 \
00244 namespace FlopCounterPack { \
00245 template <typename T> class ScalarFlopCounter; \
00246 template <typename T> \
00247 ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&, \
00248 const ScalarFlopCounter<T>&); \
00249 template <typename T> \
00250 ScalarFlopCounter<T> OP (const T&, \
00251 const ScalarFlopCounter<T>); \
00252 template <typename T> \
00253 ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&, \
00254 const T&); \
00255 template <typename T> \
00256 ScalarFlopCounter<T> OP (const int&, \
00257 const ScalarFlopCounter<T>); \
00258 template <typename T> \
00259 ScalarFlopCounter<T> OP (const ScalarFlopCounter<T>&, \
00260 const int&); \
00261 } \
00262 \
00263 namespace Rad { \
00264 template <typename T> class ADvari; \
00265 template <typename T> class IndepADvar; \
00266 template <typename T> class DoubleAvoid; \
00267 template <typename T> ADvari<T>& OP (const ADvari<T>&, \
00268 const ADvari<T>&); \
00269 template <typename T> ADvari<T>& OP (const IndepADvar<T>&, \
00270 const ADvari<T>&); \
00271 template <typename T> ADvari<T>& OP (T, \
00272 const ADvari<T>&); \
00273 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype, \
00274 const ADvari<T>&); \
00275 template <typename T> ADvari<T>& OP (int, \
00276 const ADvari<T>&); \
00277 template <typename T> ADvari<T>& OP (long, \
00278 const ADvari<T>&); \
00279 template <typename T> ADvari<T>& OP (const ADvari<T>&, \
00280 const IndepADvar<T>&); \
00281 template <typename T> ADvari<T>& OP (const ADvari<T>&, \
00282 T); \
00283 template <typename T> ADvari<T>& OP (const ADvari<T>&, \
00284 typename DoubleAvoid<T>::dtype); \
00285 template <typename T> ADvari<T>& OP (const ADvari<T>&, \
00286 int); \
00287 template <typename T> ADvari<T>& OP (const ADvari<T>&, \
00288 long); \
00289 template <typename T> ADvari<T>& OP (const IndepADvar<T>&, \
00290 const IndepADvar<T>&); \
00291 template <typename T> ADvari<T>& OP (T, \
00292 const IndepADvar<T>&); \
00293 template <typename T> ADvari<T>& OP (typename DoubleAvoid<T>::dtype, \
00294 const IndepADvar<T>&); \
00295 template <typename T> ADvari<T>& OP (int, \
00296 const IndepADvar<T>&); \
00297 template <typename T> ADvari<T>& OP (long, \
00298 const IndepADvar<T>&); \
00299 template <typename T> ADvari<T>& OP (const IndepADvar<T>&, \
00300 T); \
00301 template <typename T> ADvari<T>& OP (const IndepADvar<T>&, \
00302 typename DoubleAvoid<T>::dtype); \
00303 template <typename T> ADvari<T>& OP (const IndepADvar<T>&, \
00304 int); \
00305 template <typename T> ADvari<T>& OP (const IndepADvar<T>&, \
00306 long); \
00307 } \
00308 \
00309 } \
00310 \
00311 namespace std { \
00312 using Sacado::Fad::OP; \
00313 using Sacado::ELRFad::OP; \
00314 using Sacado::CacheFad::OP; \
00315 using Sacado::LFad::OP; \
00316 using Sacado::Tay::OP; \
00317 using Sacado::PCE::OP; \
00318 using Sacado::FlopCounterPack::OP; \
00319 using Sacado::Rad::OP; \
00320 }
00321
00322 BINARYFUNC_MACRO(atan2, Atan2Op)
00323 BINARYFUNC_MACRO(pow, PowerOp)
00324 BINARYFUNC_MACRO(max, MaxOp)
00325 BINARYFUNC_MACRO(min, MinOp)
00326
00327 #undef BINARYFUNC_MACRO
00328
00329 #endif // SACADO_MATHFUNCTIONS_HPP