Stan Math Library  2.11.0
reverse mode automatic differentiation
divide.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_DIVIDE_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_DIVIDE_HPP
3 
7 #include <cstddef>
8 #include <cstdlib>
9 
10 namespace stan {
11  namespace math {
12 
20  template<typename T1, typename T2>
21  inline typename stan::return_type<T1, T2>::type
22  divide(const T1& x, const T2& y) {
23  return x / y;
24  }
25 
26  inline int divide(const int x, const int y) {
27  if (unlikely(y == 0))
28  domain_error("divide", "denominator is", y, "");
29  return std::div(x, y).quot;
30  }
31 
32 
33  }
34 }
35 
36 #endif
boost::math::tools::promote_args< typename scalar_type< T1 >::type, typename scalar_type< T2 >::type, typename scalar_type< T3 >::type, typename scalar_type< T4 >::type, typename scalar_type< T5 >::type, typename scalar_type< T6 >::type >::type type
Definition: return_type.hpp:27
#define unlikely(x)
Definition: likely.hpp:9
Eigen::Matrix< fvar< T >, R, C > divide(const Eigen::Matrix< fvar< T >, R, C > &v, const fvar< T > &c)
Definition: divide.hpp:16
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.

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