Stan Math Library  2.20.0
reverse mode automatic differentiation
operands_and_partials.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_META_OPERANDS_AND_PARTIALS_HPP
2 #define STAN_MATH_PRIM_MAT_META_OPERANDS_AND_PARTIALS_HPP
3 
7 
9 #include <vector>
10 
11 namespace stan {
12 namespace math {
13 namespace internal {
14 
15 /* This class will be used for both multivariate (nested container)
16  operands_and_partials edges as well as for the univariate case.
17  */
18 template <typename Op, typename ViewElt, int R, int C>
19 class ops_partials_edge<ViewElt, Eigen::Matrix<Op, R, C>> {
20  public:
22  partials_t partials_;
25  explicit ops_partials_edge(const Eigen::Matrix<Op, R, C>& /* ops */) {}
26 
27  private:
28  template <typename, typename, typename, typename, typename, typename>
30 
31  void dump_partials(double* /* partials */) const {} // reverse mode
32  void dump_operands(void* /* operands */) const {} // reverse mode
33  double dx() const { return 0; } // used for fvars
34  int size() const { return 0; }
35 };
36 
37 template <typename Op, typename ViewElt, int R, int C>
38 class ops_partials_edge<ViewElt, std::vector<Eigen::Matrix<Op, R, C>>> {
39  public:
44  const std::vector<Eigen::Matrix<Op, R, C>>& /* ops */) {}
45 
46  private:
47  template <typename, typename, typename, typename, typename, typename>
49 
50  void dump_partials(double* /* partials */) const {} // reverse mode
51  void dump_operands(void* /* operands */) const {} // reverse mode
52  double dx() const { return 0; } // used for fvars
53  int size() const { return 0; }
54 };
55 
56 template <typename Op, typename ViewElt>
57 class ops_partials_edge<ViewElt, std::vector<std::vector<Op>>> {
58  public:
64  explicit ops_partials_edge(const std::vector<std::vector<Op>>& /* ops */) {}
65 
66  private:
67  template <typename, typename, typename, typename, typename, typename>
69 
70  void dump_partials(double* /* partials */) const {} // reverse mode
71  void dump_operands(void* /* operands */) const {} // reverse mode
72  double dx() const { return 0; } // used for fvars
73  int size() const { return 0; }
74 };
75 } // namespace internal
76 } // namespace math
77 } // namespace stan
78 #endif
An edge holds both the operands and its associated partial derivatives.
empty_broadcast_array< ViewElt, std::vector< std::vector< Op > > > partials_t
This template builds partial derivatives with respect to a set of operands.
(Expert) Numerical traits for algorithmic differentiation variables.
empty_broadcast_array< ViewElt, Eigen::Matrix< Op, R, C > > partials_t
empty_broadcast_array< partials_t, std::vector< std::vector< Op > > > partials_vec_
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
Definition: size.hpp:17
empty_broadcast_array< partials_t, Eigen::Matrix< Op, R, C > > partials_vec_

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