<commit_before>#ifndef STAN_MATH_PRIM_SCAL_FUN_GAMMA_P_HPP
#define STAN_MATH_PRIM_SCAL_FUN_GAMMA_P_HPP

#include <boost/math/special_functions/gamma.hpp>
#include <stan/math/prim/scal/fun/boost_policy.hpp>
#include <exception>

namespace stan {
namespace math {

/**
 *
   \f[
   \mbox{gamma\_p}(a, z) =
   \begin{cases}
     \textrm{error} & \mbox{if } a\leq 0 \textrm{ or } z < 0\\
     P(a, z) & \mbox{if } a > 0, z \geq 0 \\[6pt]
     \textrm{NaN} & \mbox{if } a = \textrm{NaN or } z = \textrm{NaN}
   \end{cases}
   \f]

   \f[
   \frac{\partial\, \mbox{gamma\_p}(a, z)}{\partial a} =
   \begin{cases}
     \textrm{error} & \mbox{if } a\leq 0 \textrm{ or } z < 0\\
     \frac{\partial\, P(a, z)}{\partial a} & \mbox{if } a > 0, z \geq 0 \\[6pt]
     \textrm{NaN} & \mbox{if } a = \textrm{NaN or } z = \textrm{NaN}
   \end{cases}
   \f]

   \f[
   \frac{\partial\, \mbox{gamma\_p}(a, z)}{\partial z} =
   \begin{cases}
     \textrm{error} & \mbox{if } a\leq 0 \textrm{ or } z < 0\\
     \frac{\partial\, P(a, z)}{\partial z} & \mbox{if } a > 0, z \geq 0 \\[6pt]
     \textrm{NaN} & \mbox{if } a = \textrm{NaN or } z = \textrm{NaN}
   \end{cases}
   \f]

   \f[
   P(a, z)=\frac{1}{\Gamma(a)}\int_0^zt^{a-1}e^{-t}dt
   \f]

   \f[
   \frac{\partial \, P(a, z)}{\partial a} =
 -\frac{\Psi(a)}{\Gamma^2(a)}\int_0^zt^{a-1}e^{-t}dt
   + \frac{1}{\Gamma(a)}\int_0^z (a-1)t^{a-2}e^{-t}dt
   \f]

   \f[
   \frac{\partial \, P(a, z)}{\partial z} = \frac{z^{a-1}e^{-z}}{\Gamma(a)}
   \f]
   * @throws domain_error if x is at pole

 */
inline double gamma_p(double x, double a) {
  if (!(x > 0)) {
    std::stringstream s;
    s << "in gamma_p(x = " << x << ", a = " << a << ");"
      << " x must be positive.";
    std::string error_msg = s.str();
    throw std::domain_error(error_msg);
  }
  if (!(a > 0)) {
    std::stringstream s;
    s << "in gamma_p(x = " << x << ", a = " << a << ");"
      << " a must be positive.";
    std::string error_msg = s.str();
    throw std::domain_error(error_msg);
  }
  return boost::math::gamma_p(x, a, boost_policy_t());
}

}  // namespace math
}  // namespace stan
#endif<commit_msg>convert co comparison to built-in checks for gamma_p<commit_after>#ifndef STAN_MATH_PRIM_SCAL_FUN_GAMMA_P_HPP
#define STAN_MATH_PRIM_SCAL_FUN_GAMMA_P_HPP

#include <stan/math/prim/scal/err/check_positive.hpp>
#include <boost/math/special_functions/gamma.hpp>
#include <stan/math/prim/scal/fun/boost_policy.hpp>
// #include <exception>

namespace stan {
namespace math {

/**
 *
   \f[
   \mbox{gamma\_p}(a, z) =
   \begin{cases}
     \textrm{error} & \mbox{if } a\leq 0 \textrm{ or } z < 0\\
     P(a, z) & \mbox{if } a > 0, z \geq 0 \\[6pt]
     \textrm{NaN} & \mbox{if } a = \textrm{NaN or } z = \textrm{NaN}
   \end{cases}
   \f]

   \f[
   \frac{\partial\, \mbox{gamma\_p}(a, z)}{\partial a} =
   \begin{cases}
     \textrm{error} & \mbox{if } a\leq 0 \textrm{ or } z < 0\\
     \frac{\partial\, P(a, z)}{\partial a} & \mbox{if } a > 0, z \geq 0 \\[6pt]
     \textrm{NaN} & \mbox{if } a = \textrm{NaN or } z = \textrm{NaN}
   \end{cases}
   \f]

   \f[
   \frac{\partial\, \mbox{gamma\_p}(a, z)}{\partial z} =
   \begin{cases}
     \textrm{error} & \mbox{if } a\leq 0 \textrm{ or } z < 0\\
     \frac{\partial\, P(a, z)}{\partial z} & \mbox{if } a > 0, z \geq 0 \\[6pt]
     \textrm{NaN} & \mbox{if } a = \textrm{NaN or } z = \textrm{NaN}
   \end{cases}
   \f]

   \f[
   P(a, z)=\frac{1}{\Gamma(a)}\int_0^zt^{a-1}e^{-t}dt
   \f]

   \f[
   \frac{\partial \, P(a, z)}{\partial a} =
 -\frac{\Psi(a)}{\Gamma^2(a)}\int_0^zt^{a-1}e^{-t}dt
   + \frac{1}{\Gamma(a)}\int_0^z (a-1)t^{a-2}e^{-t}dt
   \f]

   \f[
   \frac{\partial \, P(a, z)}{\partial z} = \frac{z^{a-1}e^{-z}}{\Gamma(a)}
   \f]
   * @throws domain_error if x is at pole

 */
inline double gamma_p(double x, double a) {
  check_positive("gamma_p", "first argument (x)", x);
  check_positive("gamma_p", "second argument (a)", a);
  return boost::math::gamma_p(x, a, boost_policy_t());
}

}  // namespace math
}  // namespace stan
#endif
{'fraction_non_alphanumeric': 0.2315160567587752, 'fraction_numerical': 0.01344286781179985, 'mean_word_length': 2.59391771019678, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7539890', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1712, 'n_words': 366}