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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef SUNDANCE_STDMATHOPS_H
00043 #define SUNDANCE_STDMATHOPS_H
00044
00045 #include "SundanceDefs.hpp"
00046 #include "PlayaExceptions.hpp"
00047 #include "SundanceExpr.hpp"
00048 #include "SundanceScalarExpr.hpp"
00049 #include "SundanceStdMathFunctors.hpp"
00050 #include "SundanceNonlinearUnaryOp.hpp"
00051
00052
00053
00054 #ifndef DOXYGEN_DEVELOPER_ONLY
00055
00056
00057 using namespace Sundance;
00058 using namespace Sundance;
00059 using namespace Sundance;
00060 using namespace Teuchos;
00061
00062 #define SUNDANCE_UNARY_OP(opName, functorName, description) \
00063 \
00064 inline Expr opName(const Expr& expr) \
00065 {\
00066 RCP<ScalarExpr> arg = rcp_dynamic_cast<ScalarExpr>(expr[0].ptr());\
00067 TEUCHOS_TEST_FOR_EXCEPTION(arg.get()==0, std::runtime_error,\
00068 "non-scalar argument in " #opName " function");\
00069 return new NonlinearUnaryOp(arg, rcp(new functorName()));\
00070 }
00071
00072 namespace Sundance
00073 {
00074 inline Expr pow(const Expr& expr, const double& p)
00075 {
00076 RCP<ScalarExpr> arg = rcp_dynamic_cast<ScalarExpr>(expr[0].ptr());
00077 TEUCHOS_TEST_FOR_EXCEPTION(arg.get()==0, std::runtime_error,
00078 "non-scalar argument in pow function");
00079 return new NonlinearUnaryOp(arg, rcp(new PowerFunctor(p)));
00080 }
00081
00082
00083
00084 SUNDANCE_UNARY_OP(reciprocal, StdReciprocal, "reciprocal function")
00085
00086 SUNDANCE_UNARY_OP(fabs, StdFabs, "absolute value")
00087
00088 SUNDANCE_UNARY_OP(sign, StdSign, "sign function")
00089
00090 SUNDANCE_UNARY_OP(exp, StdExp, "exponential function")
00091
00092 SUNDANCE_UNARY_OP(log, StdLog, "logarithm")
00093
00094 SUNDANCE_UNARY_OP(sqrt, StdSqrt, "square root"])
00095
00096 SUNDANCE_UNARY_OP(sin, StdSin, "sine function")
00097
00098 SUNDANCE_UNARY_OP(cos, StdCos, "cosine function")
00099
00100 SUNDANCE_UNARY_OP(tan, StdTan, "tangent function")
00101
00102 SUNDANCE_UNARY_OP(asin, StdASin, "inverse sine")
00103
00104 SUNDANCE_UNARY_OP(acos, StdACos, "inverse cosine")
00105
00106 SUNDANCE_UNARY_OP(atan, StdATan, "inverse tangent")
00107
00108 SUNDANCE_UNARY_OP(sinh, StdSinh, "hyperbolic sine")
00109
00110 SUNDANCE_UNARY_OP(cosh, StdCosh, "hyperbolic cosine")
00111
00112 SUNDANCE_UNARY_OP(tanh, StdTanh, "hyperbolic tangent")
00113
00114 SUNDANCE_UNARY_OP(asinh, StdASinh, "inverse hyperbolic sine")
00115
00116 SUNDANCE_UNARY_OP(acosh, StdACosh, "inverse hyperbolic cosine")
00117
00118 SUNDANCE_UNARY_OP(atanh, StdATanh, "inverse hyperbolic tangent")
00119
00120
00121 }
00122
00123 #endif
00124 #endif