Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
derivative.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_MIX_MAT_FUNCTOR_DERIVATIVE_HPP
2 #define STAN_MATH_MIX_MAT_FUNCTOR_DERIVATIVE_HPP
3 
4 #include <stan/math/fwd/core.hpp>
6 #include <stan/math/rev/core.hpp>
7 #include <vector>
8 
9 namespace stan {
10 
11  namespace math {
12 
13  using Eigen::Dynamic;
14 
26  template <typename T, typename F>
27  void
28  derivative(const F& f,
29  const T& x,
30  T& fx,
31  T& dfx_dx) {
32  fvar<T> x_fvar = fvar<T>(x, 1.0);
33  fvar<T> fx_fvar = f(x_fvar);
34  fx = fx_fvar.val_;
35  dfx_dx = fx_fvar.d_;
36  }
37 
38  } // namespace math
39 } // namespace stan
40 #endif
void derivative(const F &f, const T &x, T &fx, T &dfx_dx)
Return the derivative of the specified univariate function at the specified argument.
Definition: derivative.hpp:28

     [ Stan Home Page ] © 2011–2015, Stan Development Team.