Stan Math Library  2.14.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 
5 #include <boost/math/tools/promotion.hpp>
6 
7 namespace stan {
8  namespace math {
9 
18  template <typename T1, typename T2>
19  inline typename boost::math::tools::promote_args<T1, T2>::type
20  fmax(const T1& x, const T2& y) {
21  if (is_nan(x)) return y;
22  if (is_nan(y)) return x;
23  return x > y ? x : y;
24  }
25 
26  }
27 }
28 #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:21
fvar< T > fmax(const fvar< T > &x1, const fvar< T > &x2)
Return the greater of the two specified arguments.
Definition: fmax.hpp:23

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