Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
scal
fun
log1p.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_PRIM_SCAL_FUN_LOG1P_HPP
2
#define STAN_MATH_PRIM_SCAL_FUN_LOG1P_HPP
3
4
#include <
stan/math/prim/meta.hpp
>
5
#include <
stan/math/prim/scal/err/check_greater_or_equal.hpp
>
6
#include <
stan/math/prim/scal/fun/is_nan.hpp
>
7
#include <cmath>
8
9
namespace
stan
{
10
namespace
math {
11
27
inline
double
log1p
(
double
x) {
28
if
(
is_nan
(x)) {
29
return
x;
30
}
else
{
31
check_greater_or_equal
(
"log1p"
,
"x"
, x, -1.0);
32
return
std::log1p
(x);
33
}
34
}
35
45
inline
double
log1p
(
int
x) {
46
if
(
is_nan
(x)) {
47
return
x;
48
}
else
{
49
check_greater_or_equal
(
"log1p"
,
"x"
, x, -1);
50
return
std::log1p
(x);
51
}
52
}
53
54
}
// namespace math
55
}
// namespace stan
56
#endif
is_nan.hpp
stan
Definition:
log_sum_exp.hpp:8
meta.hpp
stan::math::check_greater_or_equal
void check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low)
Check if y is greater or equal than low.
Definition:
check_greater_or_equal.hpp:62
stan::math::log1p
var log1p(const var &a)
The log (1 + x) function for variables (C99).
Definition:
log1p.hpp:29
stan::math::log1p
fvar< T > log1p(const fvar< T > &x)
Definition:
log1p.hpp:12
check_greater_or_equal.hpp
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:20
[
Stan Home Page
]
© 2011–2018, Stan Development Team.