Stan Math Library  2.20.0
reverse mode automatic differentiation
fmin.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_FMIN_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_FMIN_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 fmin(
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 y > x ? x : y;
27 }
28 
29 } // namespace math
30 } // namespace stan
31 #endif
fvar< T > fmin(const fvar< T > &x1, const fvar< T > &x2)
Definition: fmin.hpp:14
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

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