Drake
double_overloads.h
Go to the documentation of this file.
1 /// @file
2 /// Provides necessary operations on double to have it as a ScalarType in drake.
3 
4 #pragma once
5 
6 namespace drake {
7 /// Provides if-then-else expression for double. The value returned by the
8 /// if-then-else expression is @p v_then if @p f_cond is @c true. Otherwise, it
9 /// returns @p v_else.
10 
11 /// The semantics is similar but not exactly the same as C++'s conditional
12 /// expression constructed by its ternary operator, @c ?:. In
13 /// <tt>if_then_else(f_cond, v_then, v_else)</tt>, both of @p v_then and @p
14 /// v_else are evaluated regardless of the evaluation of @p f_cond. In contrast,
15 /// only one of @p v_then or @p v_else is evaluated in C++'s conditional
16 /// expression <tt>f_cond ? v_then : v_else</tt>.
17 inline double if_then_else(bool f_cond, double v_then, double v_else) {
18  return f_cond ? v_then : v_else;
19 }
20 
21 } // namespace drake
Definition: automotive_demo.cc:88
Eigen::AutoDiffScalar< typename Eigen::internal::remove_all< DerType1 >::type::PlainObject > if_then_else(bool f_cond, const Eigen::AutoDiffScalar< DerType1 > &x, const Eigen::AutoDiffScalar< DerType2 > &y)
Provides if-then-else expression for Eigen::AutoDiffScalar type.
Definition: autodiff_overloads.h:168