SundanceStdMathOps.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
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 /** \relates Expr description */\
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   /** \name Elementary math functions */
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 /* DOXYGEN_DEVELOPER_ONLY */
00113 #endif

Site Contact