Stan Math Library: stan/math/mix/mat/functor/partial_derivative.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

partial_derivative.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_MIX_MAT_FUNCTOR_PARTIAL_DERIVATIVE_HPP
2 #define STAN_MATH_MIX_MAT_FUNCTOR_PARTIAL_DERIVATIVE_HPP
3
4 #include <stan/math/fwd/core.hpp>
5 #include <stan/math/prim/mat/fun/Eigen.hpp>
6 #include <stan/math/rev/core.hpp>
7 #include <vector>
8
9 namespace stan {
10
11 namespace math {
12
25 template <typename T, typename F>
26 void
27 partial_derivative(const F& f,
28 const Eigen::Matrix<T, Eigen::Dynamic, 1>& x,
29 int n,
30 T& fx,
31 T& dfx_dxn) {
32 Eigen::Matrix<fvar<T>, Eigen::Dynamic, 1> x_fvar(x.size());
33 for (int i = 0; i < x.size(); ++i)
34 x_fvar(i) = fvar<T>(x(i), i == n);
35 fvar<T> fx_fvar = f(x_fvar);
36 fx = fx_fvar.val_;
37 dfx_dxn = fx_fvar.d_;
38 }
39
40 } // namespace math
41 } // namespace stan
42 #endif
core.hpp
core.hpp
stan::math::fvar::d_
T d_
Definition: fvar.hpp:15
stan
Definition: log_sum_exp.hpp:8
stan::math::fvar::val_
T val_
Definition: fvar.hpp:14
Eigen.hpp
stan::math::fvar
Definition: fvar.hpp:13
stan::math::partial_derivative
void partial_derivative(const F &f, const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x, int n, T &fx, T &dfx_dxn)
Return the partial derivative of the specified multiivariate function at the specified argument...
Definition: partial_derivative.hpp:27

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