Stan Math Library  2.20.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 
6 #include <cstddef>
7 #include <cstdlib>
8 
9 namespace stan {
10 namespace math {
11 
19 template <typename T1, typename T2>
20 inline typename stan::return_type<T1, T2>::type divide(const T1& x,
21  const T2& y) {
22  return x / y;
23 }
24 
25 inline int divide(int x, int y) {
26  if (unlikely(y == 0))
27  domain_error("divide", "denominator is", y, "");
28  return x / y;
29 }
30 
31 } // namespace math
32 } // namespace stan
33 #endif
#define unlikely(x)
Definition: likely.hpp:9
boost::math::tools::promote_args< double, typename scalar_type< T >::type, typename return_type< Types_pack... >::type >::type type
Definition: return_type.hpp:36
Eigen::Matrix< fvar< T >, R, C > divide(const Eigen::Matrix< fvar< T >, R, C > &v, const fvar< T > &c)
Definition: divide.hpp:11
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–2018, Stan Development Team.