autodiff/casadi/utils/static-if.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2020 INRIA
3 //
4 
5 #ifndef __pinocchio_autodiff_casadi_utils_static_if_hpp__
6 #define __pinocchio_autodiff_casadi_utils_static_if_hpp__
7 
9 
10 namespace pinocchio
11 {
12  namespace internal
13  {
14 
15  template<typename Scalar, typename ThenType, typename ElseType>
16  struct if_then_else_impl<::casadi::Matrix<Scalar>, ::casadi::Matrix<Scalar>, ThenType, ElseType>
17  {
19 
20  typedef ::casadi::Matrix<Scalar> CasadiType;
21 
22  static inline ReturnType run(
23  const ComparisonOperators op,
24  const CasadiType & lhs_value,
25  const CasadiType & rhs_value,
26  const ThenType & then_value,
27  const ElseType & else_value)
28  {
29  switch (op)
30  {
31  case LT:
32  return ::casadi::Matrix<Scalar>::if_else(lhs_value < rhs_value, then_value, else_value);
33  break;
34  case LE:
35  return ::casadi::Matrix<Scalar>::if_else(lhs_value <= rhs_value, then_value, else_value);
36  break;
37  case EQ:
38  return ::casadi::Matrix<Scalar>::if_else(lhs_value == rhs_value, then_value, else_value);
39  break;
40  case GE:
41  return ::casadi::Matrix<Scalar>::if_else(lhs_value >= rhs_value, then_value, else_value);
42  break;
43  case GT:
44  return ::casadi::Matrix<Scalar>::if_else(lhs_value > rhs_value, then_value, else_value);
45  break;
46  }
47  }
48  };
49 
50  template<typename Scalar>
51  struct comparison_eq_impl<::casadi::Matrix<Scalar>, ::casadi::Matrix<Scalar>>
52  {
53  typedef ::casadi::Matrix<Scalar> CasadiType;
54 
55  static inline bool run(const CasadiType & lhs_value, const CasadiType & rhs_value)
56  {
57  return (lhs_value == rhs_value).is_zero();
58  }
59  };
60 
61  } // namespace internal
62 } // namespace pinocchio
63 
64 namespace std
65 {
66 
67  template<typename Scalar>
68  struct equal_to<::casadi::Matrix<Scalar>>
69  {
70  bool operator()(
71  const ::casadi::Matrix<Scalar> & lhs_value, const ::casadi::Matrix<Scalar> & rhs_value) const
72  {
73  return (lhs_value == rhs_value).is_zero();
74  }
75  };
76 } // namespace std
77 
78 #endif // ifndef __pinocchio_autodiff_casadi_utils_static_if_hpp__
static-if.hpp
pinocchio::internal::ComparisonOperators
ComparisonOperators
Definition: utils/static-if.hpp:15
pinocchio::internal::GT
@ GT
Definition: utils/static-if.hpp:21
pinocchio::internal::if_then_else_impl
Definition: utils/static-if.hpp:25
pinocchio::internal::if_then_else_impl<::casadi::Matrix< Scalar >, ::casadi::Matrix< Scalar >, ThenType, ElseType >::run
static ReturnType run(const ComparisonOperators op, const CasadiType &lhs_value, const CasadiType &rhs_value, const ThenType &then_value, const ElseType &else_value)
Definition: autodiff/casadi/utils/static-if.hpp:22
pinocchio::internal::comparison_eq_impl
Definition: utils/static-if.hpp:28
std::equal_to<::casadi::Matrix< Scalar > >::operator()
bool operator()(const ::casadi::Matrix< Scalar > &lhs_value, const ::casadi::Matrix< Scalar > &rhs_value) const
Definition: autodiff/casadi/utils/static-if.hpp:70
pinocchio::internal::if_then_else_impl<::casadi::Matrix< Scalar >, ::casadi::Matrix< Scalar >, ThenType, ElseType >::CasadiType
::casadi::Matrix< Scalar > CasadiType
Definition: autodiff/casadi/utils/static-if.hpp:20
pinocchio::internal::EQ
@ EQ
Definition: utils/static-if.hpp:19
pinocchio::internal::traits
Definition: fwd.hpp:83
pinocchio::internal::comparison_eq_impl<::casadi::Matrix< Scalar >, ::casadi::Matrix< Scalar > >::run
static bool run(const CasadiType &lhs_value, const CasadiType &rhs_value)
Definition: autodiff/casadi/utils/static-if.hpp:55
std
Definition: autodiff/casadi/utils/static-if.hpp:64
pinocchio::internal::LT
@ LT
Definition: utils/static-if.hpp:17
pinocchio::internal::GE
@ GE
Definition: utils/static-if.hpp:20
pinocchio::internal::LE
@ LE
Definition: utils/static-if.hpp:18
pinocchio::internal::if_then_else_impl<::casadi::Matrix< Scalar >, ::casadi::Matrix< Scalar >, ThenType, ElseType >::ReturnType
internal::traits< if_then_else_impl >::ReturnType ReturnType
Definition: autodiff/casadi/utils/static-if.hpp:18
pinocchio::internal::comparison_eq_impl<::casadi::Matrix< Scalar >, ::casadi::Matrix< Scalar > >::CasadiType
::casadi::Matrix< Scalar > CasadiType
Definition: autodiff/casadi/utils/static-if.hpp:53
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:48