| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

fdim.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_FDIM_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_FDIM_HPP
3
4 #include <stan/math/prim/scal/fun/is_nan.hpp>
5 #include <boost/math/tools/promotion.hpp>
6 #include <math.h>
7 #include <cmath>
8 #include <limits>
9
10 namespace stan {
11 namespace math {
12
24 template <typename T1, typename T2>
25 inline typename boost::math::tools::promote_args<T1, T2>::type
26 fdim(T1 a, T2 b) {
27 using ::fdim;
28 using std::numeric_limits;
29 using boost::math::tools::promote_args;
30 if (is_nan(a) || is_nan(b))
31 return numeric_limits<typename promote_args<T1, T2>::type>::quiet_NaN();
32 return fdim(a, b);
33 }
34 }
35 }
36
37 #endif
stan::math::fdim
var fdim(const var &a, double b)
Return the positive difference between the first variable's value and the second value (C99)...
Definition: fdim.hpp:158
is_nan.hpp
stan
Definition: log_sum_exp.hpp:8
stan::math::fdim
fvar< T > fdim(const fvar< T > &x1, const fvar< T > &x2)
Definition: fdim.hpp:11
stan::math::is_nan
int is_nan(const fvar< T > &x)
Returns 1 if the input's value is NaN and 0 otherwise.
Definition: is_nan.hpp:21

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