Drake
gradient.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Eigen/Dense>
4 
5 namespace drake {
6 namespace math {
7 
8 /*
9  * Recursively defined template specifying a matrix type of the correct size for
10  * a gradient of a matrix function with respect to Nq variables, of any order.
11  */
12 template <typename Derived, int Nq, int DerivativeOrder = 1>
13 struct Gradient {
14  typedef typename Eigen::Matrix<
15  typename Derived::Scalar,
16  ((Derived::SizeAtCompileTime == Eigen::Dynamic || Nq == Eigen::Dynamic)
17  ? Eigen::Dynamic
18  : Gradient<Derived, Nq,
19  DerivativeOrder - 1>::type::SizeAtCompileTime),
20  Nq> type;
21 };
22 
23 /*
24  * Base case for recursively defined gradient template.
25  */
26 template <typename Derived, int Nq>
27 struct Gradient<Derived, Nq, 1> {
28  typedef typename Eigen::Matrix<typename Derived::Scalar,
29  Derived::SizeAtCompileTime, Nq> type;
30 };
31 
32 } // namespace math
33 } // namespace drake
Definition: constants.h:3
Eigen::Matrix< typename Derived::Scalar, Derived::SizeAtCompileTime, Nq > type
Definition: gradient.h:29
Eigen::Matrix< typename Derived::Scalar,((Derived::SizeAtCompileTime==Eigen::Dynamic||Nq==Eigen::Dynamic)?Eigen::Dynamic:Gradient< Derived, Nq, DerivativeOrder-1 >::type::SizeAtCompileTime), Nq > type
Definition: gradient.h:20
Definition: gradient.h:13