29 #ifndef __AdBinaryFunctions_H
30 #define __AdBinaryFunctions_H 1
33 # include <boost/preprocessor/comparison/less.hpp>
34 # include <boost/preprocessor/logical/and.hpp>
35 # include <boost/preprocessor/control/if.hpp>
36 # include <boost/preprocessor/list/at.hpp>
37 # include <boost/preprocessor/list/cat.hpp>
38 # include <boost/preprocessor/list/for_each_product.hpp>
39 # include <boost/preprocessor/logical/or.hpp>
40 # include <boost/preprocessor/tuple/to_list.hpp>
41 # include <boost/preprocessor/tuple/eat.hpp>
42 # include <boost/preprocessor/facilities/empty.hpp>
43 # include <boost/preprocessor/punctuation/comma.hpp>
44 # include <boost/preprocessor/facilities/identity.hpp>
45 # include <boost/preprocessor/stringize.hpp>
51 # define AD_BINARY_FUNCTION_NAME(O) BOOST_PP_TUPLE_ELEM(5, 0, O)
52 # define AD_BINARY_FUNCTION_SYMBOL(O) BOOST_PP_TUPLE_ELEM(5, 1, O)
53 # define AD_BINARY_FUNCTION_COMMENT(O) BOOST_PP_TUPLE_ELEM(5, 2, O)
54 # define AD_BINARY_FUNCTION_GRAD(O) BOOST_PP_TUPLE_ELEM(5, 3, O)
55 # define AD_BINARY_FUNCTION_HESS(O) BOOST_PP_TUPLE_ELEM(5, 4, O)
58 # define AD_BINARY_FUNCTIONS \
59 BOOST_PP_TUPLE_TO_LIST( \
62 ( ADBinFunPow , pow, "Power function", (expr2_.value() * expr1_.grad(__i) * math::pow(expr1_.value(),expr2_.value()-1)), (expr2_.value() * ( (expr2_.value()-1) * expr1_.grad(__i) * expr1_.grad(__j) * math::pow(expr1_.value(),expr2_.value()-2) + expr1_.hessian(__i,__j) * math::pow(expr1_.value(),expr2_.value()-1))) ) \
75 template <
class Expr1,
class Expr2>
class @
NAME@
79 enum { nvar = Expr1::nvar };
82 typedef typename Expr1::value_type value_type;
92 @
NAME@ (
const Expr1 & expr1,
const Expr2& expr2 ) : expr1_( expr1 ), expr2_( expr2 )
98 template<
int isFundamental,
typename Expr1_,
typename Expr2_>
102 typedef typename Expr1_::value_type value_type;
104 static value_type value( Expr1_
const& expr1_, Expr2_
const& expr2_ )
106 return @FCT@( expr1_.value(), expr2_.value() );
108 static value_type grad( Expr1_
const& expr1_, Expr2_
const& expr2_,
int __i )
112 static value_type
hessian( Expr1_
const& expr1_, Expr2_
const& expr2_,
int __i,
int __j )
117 template<
typename Expr1_,
typename Expr2_>
118 struct Value<true, Expr1_, Expr2_>
120 typedef typename Expr1_::value_type value_type;
122 static value_type value( Expr1_
const& expr1_, Expr2_
const& expr2_ )
124 return std::@FCT@( expr1_.value(), expr2_.value() );
126 static value_type grad( Expr1_
const& expr1_, Expr2_
const& expr2_,
int __i )
130 static value_type
hessian( Expr1_
const& expr1_, Expr2_
const& expr2_,
int __i,
int __j )
136 inline value_type value()
const
138 return Value<
true,Expr1,Expr2>::value( expr1_, expr2_ );
140 inline value_type grad(
int __i )
const
142 return Value<
true,Expr1,Expr2>::grad( expr1_, expr2_, __i );
144 inline value_type hessian(
int __i,
int __j )
const
146 return Value<
true,Expr1, Expr2>::hessian( expr1_, expr2_, __i, __j );
148 inline bool deps(
int __i )
const
150 return expr1_.deps( __i ) || expr2_.deps( __i );
154 template <
class Expr1,
class Expr2>
163 template <
class T,
int Nvar,
int Order,
int Var>
172 template <
class W,
class T,
int Nvar,
int Order,
int Var>
174 ADExpr< AdFuncPow< ADType<T, Nvar, Order, Var>, ADCst<W> > >
175 pow (
const ADType<T, Nvar, Order, Var>& x, W y )
177 typedef AdFuncPow< ADType<T, Nvar, Order, Var>, ADCst<W> > expr_t;
179 return ADExpr< expr_t >( expr_t( x, y1 ) );
PolynomialSet< Poly, Tensor2 > hessian(PolynomialSet< Poly, Scalar > const &p)
compute the gradient of a vectorial polynomial set
Definition: operations.hpp:231
Automatically Diffentiated Numerical Type.
Definition: adtype.hpp:92
brief description
Definition: adexpr.hpp:44
brief description
Definition: adbinaryfunctions.tmpl.hpp:75