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