pinocchio  2.6.3
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
static-if.hpp
1 //
2 // Copyright (c) 2019-2020 INRIA
3 //
4 
5 #ifndef __pinocchio_autodiff_cppad_utils_static_if_hpp__
6 #define __pinocchio_autodiff_cppad_utils_static_if_hpp__
7 
8 #include "pinocchio/utils/static-if.hpp"
9 
10 namespace pinocchio
11 {
12  namespace internal
13  {
14  template<typename Scalar, typename ThenType, typename ElseType>
15  struct if_then_else_impl<CppAD::AD<Scalar>,CppAD::AD<Scalar>,ThenType,ElseType>
16  {
17  typedef typename internal::traits<if_then_else_impl>::ReturnType ReturnType;
18 
19  static inline ReturnType run(const ComparisonOperators op,
20  const CppAD::AD<Scalar> & lhs_value,
21  const CppAD::AD<Scalar> & rhs_value,
22  const ThenType & then_value,
23  const ElseType & else_value)
24  {
25  switch(op)
26  {
27  case LT:
28  return ::CppAD::CondExpLt<Scalar>(lhs_value,rhs_value,
29  then_value,else_value);
30  case LE:
31  return ::CppAD::CondExpLe<Scalar>(lhs_value,rhs_value,
32  then_value,else_value);
33  case EQ:
34  return ::CppAD::CondExpEq<Scalar>(lhs_value,rhs_value,
35  then_value,else_value);
36  case GE:
37  return ::CppAD::CondExpGe<Scalar>(lhs_value,rhs_value,
38  then_value,else_value);
39  case GT:
40  return ::CppAD::CondExpGt<Scalar>(lhs_value,rhs_value,
41  then_value,else_value);
42  }
43  }
44  };
45  } // namespace internal
46 } // namespace pinocchio
47 
48 #endif // ifndef __pinocchio_autodiff_cppad_utils_static_if_hpp__
49 
pinocchio
Main pinocchio namespace.
Definition: treeview.dox:24