Skip to content

Commit e9903fb

Browse files
committed
clean up unnecessary signatures and checks
1 parent dbd2df2 commit e9903fb

File tree

13 files changed

+19
-204
lines changed

13 files changed

+19
-204
lines changed

stan/math/prim/fun/acosh.hpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,8 @@ namespace math {
1919
* @throw std::domain_error If argument is less than 1.
2020
*/
2121
inline double acosh(double x) {
22-
if (is_nan(x)) {
23-
return x;
24-
} else {
25-
check_greater_or_equal("acosh", "x", x, 1.0);
26-
#ifdef _WIN32
27-
if (is_inf(x))
28-
return x;
29-
#endif
30-
return std::acosh(x);
31-
}
22+
check_greater_or_equal("acosh", "x", x, 1.0);
23+
return std::acosh(x);
3224
}
3325

3426
/**
@@ -39,16 +31,8 @@ inline double acosh(double x) {
3931
* @throw std::domain_error If argument is less than 1.
4032
*/
4133
inline double acosh(int x) {
42-
if (is_nan(x)) {
43-
return x;
44-
} else {
45-
check_greater_or_equal("acosh", "x", x, 1);
46-
#ifdef _WIN32
47-
if (is_inf(x))
48-
return x;
49-
#endif
50-
return std::acosh(x);
51-
}
34+
check_greater_or_equal("acosh", "x", x, 1);
35+
return std::acosh(x);
5236
}
5337

5438
/**

stan/math/prim/fun/asinh.hpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@
77
namespace stan {
88
namespace math {
99

10-
/**
11-
* Return the inverse hyperbolic sine of the specified value.
12-
* Returns infinity for infinity argument and -infinity for
13-
* -infinity argument.
14-
* Returns nan for nan argument.
15-
*
16-
* @param[in] x Argument.
17-
* @return Inverse hyperbolic sine of the argument.
18-
*/
19-
inline double asinh(double x) { return std::asinh(x); }
20-
21-
/**
22-
* Integer version of asinh.
23-
*
24-
* @param[in] x Argument.
25-
* @return Inverse hyperbolic sine of the argument.
26-
*/
27-
inline double asinh(int x) { return std::asinh(x); }
28-
2910
/**
3011
* Structure to wrap asinh() so it can be vectorized.
3112
*
@@ -36,6 +17,7 @@ inline double asinh(int x) { return std::asinh(x); }
3617
struct asinh_fun {
3718
template <typename T>
3819
static inline T fun(const T& x) {
20+
using std::asinh;
3921
return asinh(x);
4022
}
4123
};

stan/math/prim/fun/atanh.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ namespace math {
2020
* @throw std::domain_error If argument is not in [-1, 1].
2121
*/
2222
inline double atanh(double x) {
23-
if (is_nan(x)) {
24-
return x;
25-
} else {
26-
check_bounded("atanh", "x", x, -1.0, 1.0);
27-
return std::atanh(x);
28-
}
23+
check_bounded("atanh", "x", x, -1.0, 1.0);
24+
return std::atanh(x);
2925
}
3026

3127
/**
@@ -36,12 +32,8 @@ inline double atanh(double x) {
3632
* @throw std::domain_error If argument is less than 1.
3733
*/
3834
inline double atanh(int x) {
39-
if (is_nan(x)) {
40-
return x;
41-
} else {
42-
check_bounded("atanh", "x", x, -1, 1);
43-
return std::atanh(x);
44-
}
35+
check_bounded("atanh", "x", x, -1, 1);
36+
return std::atanh(x);
4537
}
4638

4739
/**

stan/math/prim/fun/cbrt.hpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@
77
namespace stan {
88
namespace math {
99

10-
/**
11-
* Return the cube root of the specified value
12-
*
13-
* @param[in] x Argument.
14-
* @return Cube root of the argument.
15-
* @throw std::domain_error If argument is negative.
16-
*/
17-
inline double cbrt(double x) { return std::cbrt(x); }
18-
19-
/**
20-
* Integer version of cbrt.
21-
*
22-
* @param[in] x Argument.
23-
* @return Cube root of the argument.
24-
* @throw std::domain_error If argument is less than 1.
25-
*/
26-
inline double cbrt(int x) { return std::cbrt(x); }
27-
2810
/**
2911
* Structure to wrap cbrt() so it can be vectorized.
3012
*
@@ -35,6 +17,7 @@ inline double cbrt(int x) { return std::cbrt(x); }
3517
struct cbrt_fun {
3618
template <typename T>
3719
static inline T fun(const T& x) {
20+
using std::cbrt;
3821
return cbrt(x);
3922
}
4023
};

stan/math/prim/fun/erf.hpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,6 @@
77
namespace stan {
88
namespace math {
99

10-
/**
11-
* Return the error function of the specified value.
12-
*
13-
* \f[
14-
* \mbox{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt
15-
* \f]
16-
*
17-
* @param[in] x Argument.
18-
* @return Error function of the argument.
19-
*/
20-
inline double erf(double x) { return std::erf(x); }
21-
22-
/**
23-
* Return the error function of the specified argument. This
24-
* version is required to disambiguate <code>erf(int)</code>.
25-
*
26-
* @param[in] x Argument.
27-
* @return Error function of the argument.
28-
*/
29-
inline double erf(int x) { return std::erf(x); }
30-
3110
/**
3211
* Structure to wrap erf() so it can be vectorized.
3312
*
@@ -38,6 +17,7 @@ inline double erf(int x) { return std::erf(x); }
3817
struct erf_fun {
3918
template <typename T>
4019
static inline T fun(const T& x) {
20+
using std::erf;
4121
return erf(x);
4222
}
4323
};

stan/math/prim/fun/erfc.hpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,6 @@
77
namespace stan {
88
namespace math {
99

10-
/**
11-
* Return the complementary error function of the specified value.
12-
*
13-
* \f[
14-
* \mbox{erfc}(x) = 1 - \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt
15-
* \f]
16-
*
17-
* @param[in] x Argument.
18-
* @return Complementary error function of the argument.
19-
*/
20-
inline double erfc(double x) { return std::erfc(x); }
21-
22-
/**
23-
* Return the error function of the specified argument. This
24-
* version is required to disambiguate <code>erfc(int)</code>.
25-
*
26-
* @param[in] x Argument.
27-
* @return Complementary error function value of the argument.
28-
*/
29-
inline double erfc(int x) { return std::erfc(x); }
30-
3110
/**
3211
* Structure to wrap erfc() so that it can be vectorized.
3312
*
@@ -38,6 +17,7 @@ inline double erfc(int x) { return std::erfc(x); }
3817
struct erfc_fun {
3918
template <typename T>
4019
static inline T fun(const T& x) {
20+
using std::erfc;
4121
return erfc(x);
4222
}
4323
};

stan/math/prim/fun/exp.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
namespace stan {
99
namespace math {
1010

11-
/**
12-
* Return the natural exponential of the specified argument. This
13-
* version is required to disambiguate <code>exp(int)</code>.
14-
*
15-
* @param[in] x Argument.
16-
* @return Natural exponential of argument.
17-
*/
18-
inline double exp(int x) { return std::exp(x); }
19-
2011
/**
2112
* Structure to wrap <code>exp()</code> so that it can be
2213
* vectorized.

stan/math/prim/fun/expm1.hpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@
77
namespace stan {
88
namespace math {
99

10-
/**
11-
* Return the natural exponentiation of x minus one.
12-
* Returns infinity for infinity argument and -infinity for
13-
* -infinity argument.
14-
*
15-
* @param[in] x Argument.
16-
* @return Natural exponentiation of argument minus one.
17-
*/
18-
inline double expm1(double x) { return std::expm1(x); }
19-
20-
/**
21-
* Integer version of expm1.
22-
*
23-
* @param[in] x Argument.
24-
* @return Natural exponentiation of argument minus one.
25-
*/
26-
inline double expm1(int x) { return std::expm1(x); }
27-
2810
/**
2911
* Structure to wrap expm1() so that it can be vectorized.
3012
*
@@ -35,6 +17,7 @@ inline double expm1(int x) { return std::expm1(x); }
3517
struct expm1_fun {
3618
template <typename T>
3719
static inline T fun(const T& x) {
20+
using std::expm1;
3821
return expm1(x);
3922
}
4023
};

stan/math/prim/fun/log.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99
namespace stan {
1010
namespace math {
1111

12-
/**
13-
* Return the natural log of the specified argument. This version
14-
* is required to disambiguate <code>log(int)</code>.
15-
*
16-
* @param[in] x Argument.
17-
* @return Natural log of argument.
18-
*/
19-
inline double log(int x) { return std::log(x); }
20-
2112
/**
2213
* Structure to wrap log() so that it can be vectorized.
2314
*/

stan/math/prim/fun/log1p.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ namespace math {
2727
* @throw std::domain_error If argument is less than -1.
2828
*/
2929
inline double log1p(double x) {
30-
if (is_nan(x)) {
31-
return x;
32-
} else {
33-
check_greater_or_equal("log1p", "x", x, -1.0);
34-
return std::log1p(x);
35-
}
30+
check_greater_or_equal("log1p", "x", x, -1.0);
31+
return std::log1p(x);
3632
}
3733

3834
/**
@@ -45,12 +41,8 @@ inline double log1p(double x) {
4541
* @throw std::domain_error If argument is less than -1.
4642
*/
4743
inline double log1p(int x) {
48-
if (is_nan(x)) {
49-
return x;
50-
} else {
51-
check_greater_or_equal("log1p", "x", x, -1);
52-
return std::log1p(x);
53-
}
44+
check_greater_or_equal("log1p", "x", x, -1);
45+
return std::log1p(x);
5446
}
5547

5648
/**

stan/math/prim/fun/round.hpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,6 @@
88
namespace stan {
99
namespace math {
1010

11-
/**
12-
* Return the closest integer to the specified argument, with
13-
* halfway cases rounded away from zero.
14-
*
15-
* @param x Argument.
16-
* @return The rounded value of the argument.
17-
*/
18-
inline double round(double x) { return std::round(x); }
19-
20-
/**
21-
* Return the closest integer to the specified argument, with
22-
* halfway cases rounded away from zero.
23-
*
24-
* @param x Argument.
25-
* @return The rounded value of the argument.
26-
*/
27-
inline double round(int x) { return std::round(x); }
28-
2911
/**
3012
* Structure to wrap round() so it can be vectorized.
3113
*
@@ -36,6 +18,7 @@ inline double round(int x) { return std::round(x); }
3618
struct round_fun {
3719
template <typename T>
3820
static inline T fun(const T& x) {
21+
using std::round;
3922
return round(x);
4023
}
4124
};

stan/math/prim/fun/sqrt.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
namespace stan {
99
namespace math {
1010

11-
/**
12-
* Return the square root of the specified argument. This
13-
* version is required to disambiguate <code>sqrt(int)</code>.
14-
*
15-
* @param[in] x Argument.
16-
* @return Natural exponential of argument.
17-
*/
18-
inline double sqrt(int x) { return std::sqrt(x); }
19-
2011
/**
2112
* Structure to wrap sqrt() so that it can be vectorized.
2213
*

stan/math/prim/fun/trunc.hpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,6 @@
77
namespace stan {
88
namespace math {
99

10-
/**
11-
* Return the nearest integral value that is not larger in
12-
* magnitude than the specified argument.
13-
*
14-
* @param[in] x Argument.
15-
* @return The truncated argument.
16-
*/
17-
inline double trunc(double x) { return std::trunc(x); }
18-
19-
/**
20-
* Return the nearest integral value that is not larger in
21-
* magnitude than the specified argument.
22-
*
23-
* @param[in] x Argument.
24-
* @return The truncated argument.
25-
*/
26-
inline double trunc(int x) { return std::trunc(x); }
27-
2810
/**
2911
* Structure to wrap trunc() so it can be vectorized.
3012
*/
@@ -39,6 +21,7 @@ struct trunc_fun {
3921
*/
4022
template <typename T>
4123
static inline T fun(const T& x) {
24+
using std::trunc;
4225
return trunc(x);
4326
}
4427
};

0 commit comments

Comments
 (0)