Commit 9c17e4ba authored by Andrew Johnson's avatar Andrew Johnson
Browse files

Revert pull to only replace Boost functions not needing error checking

parent 7319007d
No related merge requests found
Showing with 42 additions and 58 deletions
+42 -58
......@@ -54,7 +54,6 @@
#include <stan/math/fwd/scal/fun/is_inf.hpp>
#include <stan/math/fwd/scal/fun/is_nan.hpp>
#include <stan/math/fwd/scal/fun/lbeta.hpp>
#include <stan/math/fwd/scal/fun/ldexp.hpp>
#include <stan/math/fwd/scal/fun/lgamma.hpp>
#include <stan/math/fwd/scal/fun/lmgamma.hpp>
#include <stan/math/fwd/scal/fun/log.hpp>
......
......@@ -6,7 +6,6 @@
#include <stan/math/prim/scal/err/domain_error.hpp>
#include <stan/math/prim/scal/fun/gamma_p.hpp>
#include <stan/math/prim/scal/fun/grad_reg_lower_inc_gamma.hpp>
#include <stan/math/prim/scal/fun/lgamma.hpp>
#include <limits>
namespace stan {
......@@ -15,7 +14,7 @@ namespace math {
template <typename T>
inline fvar<T> gamma_p(const fvar<T> &x1, const fvar<T> &x2) {
using boost::math::digamma;
using stan::math::lgamma;
using boost::math::lgamma;
using std::exp;
using std::fabs;
using std::log;
......@@ -61,7 +60,7 @@ inline fvar<T> gamma_p(double x1, const fvar<T> &x2) {
if (is_inf(x1))
return fvar<T>(u, std::numeric_limits<double>::quiet_NaN());
T der2 = exp(-x2.val_ + (x1 - 1.0) * log(x2.val_) - stan::math::lgamma(x1));
T der2 = exp(-x2.val_ + (x1 - 1.0) * log(x2.val_) - boost::math::lgamma(x1));
return fvar<T>(u, x2.d_ * der2);
}
......
......@@ -2,7 +2,7 @@
#define STAN_MATH_FWD_SCAL_FUN_GAMMA_Q_HPP
#include <stan/math/fwd/core.hpp>
#include <stan/math/prim/scal/fun/tgamma.hpp>
#include <stan/math/prim/scal/fun/gamma_q.hpp>
namespace stan {
......@@ -11,7 +11,7 @@ namespace math {
template <typename T>
inline fvar<T> gamma_q(const fvar<T>& x1, const fvar<T>& x2) {
using boost::math::digamma;
using stan::math::tgamma;
using boost::math::tgamma;
using std::exp;
using std::fabs;
using std::log;
......@@ -44,7 +44,7 @@ inline fvar<T> gamma_q(const fvar<T>& x1, const fvar<T>& x2) {
template <typename T>
inline fvar<T> gamma_q(const fvar<T>& x1, double x2) {
using boost::math::digamma;
using stan::math::tgamma;
using boost::math::tgamma;
using std::exp;
using std::fabs;
using std::log;
......@@ -80,7 +80,7 @@ inline fvar<T> gamma_q(double x1, const fvar<T>& x2) {
T u = gamma_q(x1, x2.val_);
double g = stan::math::tgamma(x1);
double g = boost::math::tgamma(x1);
T der2 = -exp(-x2.val_) * pow(x2.val_, x1 - 1.0) / g;
......
......@@ -23,6 +23,7 @@ namespace math {
*/
template <typename T>
inline fvar<T> hypot(const fvar<T>& x1, const fvar<T>& x2) {
using std::sqrt;
T u = hypot(x1.val_, x2.val_);
return fvar<T>(u, (x1.d_ * x1.val_ + x2.d_ * x2.val_) / u);
}
......@@ -40,8 +41,9 @@ inline fvar<T> hypot(const fvar<T>& x1, const fvar<T>& x2) {
* @return Length of hypoteneuse of right triangle with opposite
* and adjacent side lengths x1 and x2.
*/
template <typename T, typename T1>
inline fvar<T> hypot(const fvar<T>& x1, const T1& x2) {
template <typename T>
inline fvar<T> hypot(const fvar<T>& x1, double x2) {
using std::sqrt;
T u = hypot(x1.val_, x2);
return fvar<T>(u, (x1.d_ * x1.val_) / u);
}
......@@ -59,8 +61,9 @@ inline fvar<T> hypot(const fvar<T>& x1, const T1& x2) {
* @return Length of hypoteneuse of right triangle with opposite
* and adjacent side lengths x1 and x2.
*/
template <typename T, typename T1>
inline fvar<T> hypot(const T1& x1, const fvar<T>& x2) {
template <typename T>
inline fvar<T> hypot(double x1, const fvar<T>& x2) {
using std::sqrt;
T u = hypot(x1, x2.val_);
return fvar<T>(u, (x2.d_ * x2.val_) / u);
}
......
......@@ -5,7 +5,7 @@
#include <stan/math/prim/scal/err/check_finite.hpp>
#include <stan/math/prim/mat/fun/value_of.hpp>
#include <Eigen/Dense>
#include <cmath>
#include <boost/math/special_functions/fpclassify.hpp>
namespace stan {
namespace math {
......@@ -16,7 +16,7 @@ struct finite<Eigen::Matrix<T, R, C>, true> {
const Eigen::Matrix<T, R, C>& y) {
if (!value_of(y).allFinite()) {
for (int n = 0; n < y.size(); ++n) {
if (!(std::isfinite)(value_of_rec(stan::get(y, n))))
if (!(boost::math::isfinite)(y(n)))
domain_error_vec(function, name, y, n, "is ",
", but must be finite!");
}
......
......@@ -16,7 +16,6 @@ namespace math {
struct cbrt_fun {
template <typename T>
static inline T fun(const T& x) {
using stan::math::cbrt;
return cbrt(x);
}
};
......
......@@ -17,7 +17,6 @@ namespace math {
struct erf_fun {
template <typename T>
static inline T fun(const T& x) {
using stan::math::erf;
return erf(x);
}
};
......
......@@ -16,7 +16,6 @@ namespace math {
struct erfc_fun {
template <typename T>
static inline T fun(const T& x) {
using stan::math::erfc;
return erfc(x);
}
};
......
......@@ -16,7 +16,6 @@ namespace math {
struct expm1_fun {
template <typename T>
static inline T fun(const T& x) {
using stan::math::expm1;
return expm1(x);
}
};
......
#ifndef STAN_MATH_PRIM_MAT_FUN_LOG_MIX_HPP
#define STAN_MATH_PRIM_MAT_FUN_LOG_MIX_HPP
#include <stan/math/prim/arr/meta/get.hpp>
#include <stan/math/prim/arr/meta/length.hpp>
#include <stan/math/prim/mat/meta/is_vector.hpp>
#include <stan/math/prim/mat/meta/get.hpp>
#include <stan/math/prim/mat/meta/length.hpp>
......@@ -12,6 +10,8 @@
#include <stan/math/prim/mat/meta/vector_seq_view.hpp>
#include <stan/math/prim/mat/meta/broadcast_array.hpp>
#include <stan/math/prim/mat/meta/operands_and_partials.hpp>
#include <stan/math/prim/arr/meta/get.hpp>
#include <stan/math/prim/arr/meta/length.hpp>
#include <stan/math/prim/scal/err/check_bounded.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
......
......@@ -2,7 +2,7 @@
#define STAN_MATH_PRIM_MAT_FUN_TGAMMA_HPP
#include <stan/math/prim/mat/vectorize/apply_scalar_unary.hpp>
#include <stan/math/prim/scal/fun/tgamma.hpp>
#include <boost/math/special_functions/gamma.hpp>
namespace stan {
namespace math {
......@@ -17,7 +17,7 @@ namespace math {
struct tgamma_fun {
template <typename T>
static inline T fun(const T& x) {
using stan::math::tgamma;
using boost::math::tgamma;
return tgamma(x);
}
};
......
......@@ -15,7 +15,6 @@
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/is_inf.hpp>
#include <stan/math/prim/scal/fun/log1p.hpp>
#include <stan/math/prim/scal/fun/lgamma.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <boost/random/variate_generator.hpp>
......@@ -37,7 +36,7 @@ typename return_type<T_y, T_dof, T_loc, T_scale>::type multi_student_t_lpdf(
const T_y& y, const T_dof& nu, const T_loc& mu, const T_scale& Sigma) {
static const char* function = "multi_student_t";
using stan::math::lgamma;
using boost::math::lgamma;
using std::log;
typedef typename scalar_type<T_scale>::type T_scale_elem;
......
#ifndef STAN_MATH_PRIM_MAT_PROB_MULTINOMIAL_LPMF_HPP
#define STAN_MATH_PRIM_MAT_PROB_MULTINOMIAL_LPMF_HPP
#include <boost/math/special_functions/gamma.hpp>
#include <boost/random/uniform_01.hpp>
#include <boost/random/variate_generator.hpp>
#include <stan/math/prim/mat/err/check_simplex.hpp>
......@@ -9,7 +10,6 @@
#include <stan/math/prim/scal/err/check_positive.hpp>
#include <stan/math/prim/scal/fun/multiply_log.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/lgamma.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
#include <vector>
......@@ -23,8 +23,8 @@ typename boost::math::tools::promote_args<T_prob>::type multinomial_lpmf(
const Eigen::Matrix<T_prob, Eigen::Dynamic, 1>& theta) {
static const char* function = "multinomial_lpmf";
using boost::math::lgamma;
using boost::math::tools::promote_args;
using stan::math::lgamma;
typename promote_args<T_prob>::type lp(0.0);
check_nonnegative(function, "Number of trials variable", ns);
......
......@@ -186,10 +186,10 @@ typename return_type<T_loc, T_cut>::type ordered_probit_lpmf(
check_bounded(function, "Random variable", y[i], 1, K);
check_greater(function, "Size of cut points parameter", c[i].size(), 0);
check_ordered(function, "Cut-points", c[i]);
check_finite(function, "Cut-points", c[i]);
}
check_finite(function, "Location parameter", lambda);
check_finite(function, "Cut-points", c);
typename return_type<T_loc, T_cut>::type logp_n(0.0);
......
......@@ -6,7 +6,7 @@
#include <stan/math/prim/scal/meta/length.hpp>
#include <stan/math/prim/scal/meta/is_vector_like.hpp>
#include <stan/math/prim/scal/fun/value_of_rec.hpp>
#include <cmath>
#include <boost/math/special_functions/fpclassify.hpp>
namespace stan {
namespace math {
......@@ -15,7 +15,7 @@ namespace {
template <typename T_y, bool is_vec>
struct finite {
static void check(const char* function, const char* name, const T_y& y) {
if (!(std::isfinite)(value_of_rec(y)))
if (!(boost::math::isfinite)(value_of_rec(y)))
domain_error(function, name, y, "is ", ", but must be finite!");
}
};
......@@ -25,7 +25,7 @@ struct finite<T_y, true> {
static void check(const char* function, const char* name, const T_y& y) {
using stan::length;
for (size_t n = 0; n < length(y); n++) {
if (!(std::isfinite)(value_of_rec(stan::get(y, n))))
if (!(boost::math::isfinite)(value_of_rec(stan::get(y, n))))
domain_error_vec(function, name, y, n, "is ", ", but must be finite!");
}
}
......
......@@ -31,11 +31,11 @@ inline double Phi(double x) {
if (x < -37.5)
return 0;
else if (x < -5.0)
return 0.5 * stan::math::erfc(-INV_SQRT_2 * x);
return 0.5 * erfc(-INV_SQRT_2 * x);
else if (x > 8.25)
return 1;
else
return 0.5 * (1.0 + stan::math::erf(INV_SQRT_2 * x));
return 0.5 * (1.0 + erf(INV_SQRT_2 * x));
}
} // namespace math
......
......@@ -4,8 +4,8 @@
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/is_nan.hpp>
#include <stan/math/prim/scal/meta/likely.hpp>
#include <stan/math/prim/scal/err/check_greater_or_equal.hpp>
#include <cmath>
#include <stan/math/prim/scal/fun/boost_policy.hpp>
#include <boost/math/special_functions/acosh.hpp>
namespace stan {
namespace math {
......@@ -19,12 +19,10 @@ namespace math {
* @throw std::domain_error If argument is less than 1.
*/
inline double acosh(double x) {
if (unlikely(is_nan(x))) {
if (unlikely(is_nan(x)))
return x;
} else {
check_greater_or_equal("acosh", "x", x, 1.0);
return std::acosh(x);
}
else
return boost::math::acosh(x, boost_policy_t());
}
/**
......
#ifndef STAN_MATH_PRIM_SCAL_FUN_ASINH_HPP
#define STAN_MATH_PRIM_SCAL_FUN_ASINH_HPP
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/is_nan.hpp>
#include <stan/math/prim/scal/meta/likely.hpp>
#include <cmath>
namespace stan {
......@@ -18,12 +15,7 @@ namespace math {
* @param[in] x Argument.
* @return Inverse hyperbolic sine of the argument.
*/
inline double asinh(double x) {
if (unlikely(is_nan(x)))
return x;
else
return std::asinh(x);
}
inline double asinh(double x) { return std::asinh(x); }
/**
* Integer version of asinh.
......@@ -31,7 +23,7 @@ inline double asinh(double x) {
* @param[in] x Argument.
* @return Inverse hyperbolic sine of the argument.
*/
inline double asinh(int x) { return asinh(static_cast<double>(x)); }
inline double asinh(int x) { return std::asinh(x); }
} // namespace math
} // namespace stan
......
......@@ -4,8 +4,8 @@
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/is_nan.hpp>
#include <stan/math/prim/scal/meta/likely.hpp>
#include <stan/math/prim/scal/err/check_bounded.hpp>
#include <cmath>
#include <stan/math/prim/scal/fun/boost_policy.hpp>
#include <boost/math/special_functions/atanh.hpp>
namespace stan {
namespace math {
......@@ -21,12 +21,10 @@ namespace math {
* @throw std::domain_error If argument is not in [-1, 1].
*/
inline double atanh(double x) {
if (unlikely(is_nan(x))) {
if (unlikely(is_nan(x)))
return x;
} else {
check_bounded("atanh", "x", x, -1.0, 1.0);
return std::atanh(x);
}
else
return boost::math::atanh(x, boost_policy_t());
}
/**
......
#ifndef STAN_MATH_PRIM_SCAL_FUN_BINOMIAL_COEFFICIENT_LOG_HPP
#define STAN_MATH_PRIM_SCAL_FUN_BINOMIAL_COEFFICIENT_LOG_HPP
#include <stan/math/prim/scal/fun/lgamma.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <boost/math/tools/promotion.hpp>
namespace stan {
......@@ -59,7 +59,7 @@ namespace math {
template <typename T_N, typename T_n>
inline typename boost::math::tools::promote_args<T_N, T_n>::type
binomial_coefficient_log(const T_N N, const T_n n) {
using stan::math::lgamma;
using boost::math::lgamma;
using std::log;
const double CUTOFF = 1000;
if (N - n < CUTOFF) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment