Stan Math Library  2.20.0
reverse mode automatic differentiation
fmax.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_FMAX_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_FMAX_HPP
3 
6 #include <boost/math/tools/promotion.hpp>
7 
8 namespace stan {
9 namespace math {
10 
19 template <typename T1, typename T2>
20 inline typename boost::math::tools::promote_args<T1, T2>::type fmax(
21  const T1& x, const T2& y) {
22  if (is_nan(x))
23  return y;
24  if (is_nan(y))
25  return x;
26  return x > y ? x : y;
27 }
28 
29 } // namespace math
30 } // namespace stan
31 #endif
int is_nan(const fvar< T > &x)
Returns 1 if the input&#39;s value is NaN and 0 otherwise.
Definition: is_nan.hpp:20
fvar< T > fmax(const fvar< T > &x1, const fvar< T > &x2)
Return the greater of the two specified arguments.
Definition: fmax.hpp:22

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