29 template <
class Expr>
class @NAME@
32 enum { nvar = Expr::nvar };
33 typedef typename Expr::value_type value_type;
40 @NAME@ (
const Expr & expr ) : expr_( expr )
46 template<
int isFundamental,
typename Expr_>
50 typedef typename Expr_::value_type value_type;
51 static value_type signum( value_type a )
53 if ( abs( a ) < std::numeric_limits<value_type>::epsilon() )
54 return value_type( 0 );
58 static value_type value( Expr_
const& expr_ )
60 return @FCT@( expr_.value() );
62 static value_type grad( Expr_
const& expr_,
int __i )
66 static value_type
hessian( Expr_
const& expr_,
int __i,
int __j )
71 template<
typename Expr_>
72 struct Value<true, Expr_>
74 typedef typename Expr_::value_type value_type;
75 static value_type signum( value_type a )
77 if ( std::abs( a ) < std::numeric_limits<value_type>::epsilon() )
78 return value_type( 0 );
80 return a/std::abs( a );
82 static value_type value( Expr_
const& expr_ )
84 return std::@FCT@( expr_.value() );
86 static value_type grad( Expr_
const& expr_,
int __i )
90 static value_type
hessian( Expr_
const& expr_,
int __i,
int __j )
96 inline value_type value()
const
98 return Value<
true,Expr>::value( expr_ );
100 inline value_type grad(
int __i )
const
102 return Value<
true,Expr>::grad( expr_, __i );
104 inline value_type
hessian(
int __i,
int __j )
const
106 return Value<
true,Expr>
::hessian( expr_, __i, __j );
108 inline bool deps(
int __i )
const
110 return expr_.deps( __i ) ;
114 template <
class Expr>
inline ADExpr< @NAME@< ADExpr<Expr> > >
115 @FCT@ (
const ADExpr<Expr>& expr )
117 typedef @NAME@< ADExpr<Expr> > expr_t;
118 return ADExpr< expr_t >( expr_t( expr ) );
121 template <
class T,
int Nvar,
int Order,
int Var>
inline ADExpr< @NAME@< ADType<T, Nvar, Order, Var> > >
122 @FCT@ (
const ADType<T, Nvar, Order, Var>& x )
124 typedef @NAME@< ADType<T, Nvar, Order, Var> > expr_t;
125 return ADExpr< expr_t >( expr_t( x ) );