| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/err/domain_error.hpp>
5 #include <stan/math/prim/scal/meta/likely.hpp>
6 #include <stan/math/prim/scal/meta/return_type.hpp>
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
stan
Definition: log_sum_exp.hpp:8
return_type.hpp
stan::return_type::type
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
unlikely
#define unlikely(x)
Definition: likely.hpp:9
stan::math::divide
Eigen::Matrix< fvar< T >, R, C > divide(const Eigen::Matrix< fvar< T >, R, C > &v, const fvar< T > &c)
Definition: divide.hpp:16
likely.hpp
stan::math::domain_error
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.
Definition: domain_error.hpp:32
domain_error.hpp

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