scalar sasfit_ff_gauss_generalized_3(scalar q, sasfit_param * param) { scalar u,i0, v, na, beta; SASFIT_ASSERT_PTR(param); SASFIT_CHECK_COND1((q < 0.0), param, "q(%lg) < 0",q); SASFIT_CHECK_COND1((RG <= 0.0), param, "RG(%lg) < 0",RG); SASFIT_CHECK_COND1((NU <= 0.0), param, "nu(%lg) <= 0",NU); SASFIT_CHECK_COND1((NU > 1.0), param, "nu(%lg) > 1",NU); u = (2.0*NU+1.0)*(2.0*NU+2.0)*q*q*RG*RG/6.0; na = 6.0221415e23; v = MW/RHO_P/na; beta = B_P - v*ETA_S; i0 = beta*beta; if (q*RG<0.1) return i0*exp(-q*q*RG*RG/3); // if (u>1000.0){ // return i0*( // gsl_sf_gamma(1.0/(2.*NU))/(NU*pow(u,1.0/(2.0*NU))) // - gsl_sf_gamma(1.0/NU) /(NU*pow(u,1.0/NU)) // ); // } else { return i0* (pow(u,1/(2.*NU)) * gsl_sf_gamma(1.0/(2.*NU)) - gsl_sf_gamma(1.0/NU) - pow(u,1/(2.*NU)) * gsl_sf_gamma_inc(1.0/(2.*NU),u) + gsl_sf_gamma_inc(1.0/NU,u) )/(NU*pow(u,1/NU)); // } }
int main() { # include "igamma_med_data.ipp" # include "igamma_small_data.ipp" # include "igamma_big_data.ipp" # include "igamma_int_data.ipp" add_data(igamma_med_data); add_data(igamma_small_data); add_data(igamma_big_data); add_data(igamma_int_data); unsigned data_total = data.size(); screen_data([](const std::vector<double>& v){ return boost::math::tgamma(v[0], v[1]); }, [](const std::vector<double>& v){ return v[2]; }); #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES) screen_data([](const std::vector<double>& v){ return gsl_sf_gamma_inc(v[0], v[1]); }, [](const std::vector<double>& v){ return v[2]; }); #endif unsigned data_used = data.size(); std::string function = "tgamma (incomplete)[br](" + boost::lexical_cast<std::string>(data_used) + "/" + boost::lexical_cast<std::string>(data_total) + " tests selected)"; std::string function_short = "tgamma (incomplete)"; double time; time = exec_timed_test([](const std::vector<double>& v){ return boost::math::tgamma(v[0], v[1]); }); std::cout << time << std::endl; #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH)) report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name()); #endif report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name()); // // Boost again, but with promotion to long double turned off: // #if !defined(COMPILER_COMPARISON_TABLES) if(sizeof(long double) != sizeof(double)) { time = exec_timed_test([](const std::vector<double>& v){ return boost::math::tgamma(v[0], v[1], boost::math::policies::make_policy(boost::math::policies::promote_double<false>())); }); std::cout << time << std::endl; #if !defined(COMPILER_COMPARISON_TABLES) && (defined(TEST_GSL) || defined(TEST_RMATH)) report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, boost_name() + "[br]promote_double<false>"); #endif report_execution_time(time, std::string("Compiler Comparison on ") + std::string(platform_name()), function_short, compiler_name() + std::string("[br]") + boost_name() + "[br]promote_double<false>"); } #endif #if defined(TEST_GSL) && !defined(COMPILER_COMPARISON_TABLES) time = exec_timed_test([](const std::vector<double>& v){ return gsl_sf_gamma_inc(v[0], v[1]); }); std::cout << time << std::endl; report_execution_time(time, std::string("Library Comparison with ") + std::string(compiler_name()) + std::string(" on ") + platform_name(), function, "GSL " GSL_VERSION); #endif return 0; }
// // // /// @param [in] a A real number. // /// @param [in] b A real number, where @f$ b \geq 0.0 @f$. // /// @brief Calls the GSL library to calculate the incomplete /// gamma function. // /// @return @f[ := \int_{b}^{\infty} t^{a - 1} \exp(-t)dt @f] /// If @f$ b @f$ is out of range, the function /// returns zero. // inline double incomplete_gamma_function(const double &a, const double &b) { switch(b >= 0.0) { case false: return 0.0; break; case true: return gsl_sf_gamma_inc(a, b); break; } };
double nest::sinusoidal_gamma_generator::hazard_( port tgt_idx ) const { // Note: We compute Lambda for the entire interval since the last spike/ // parameter change each time for better accuracy. const double Lambda = B_.Lambda_t0_[ tgt_idx ] + deltaLambda_( P_, B_.t0_ms_[ tgt_idx ], V_.t_ms_ ); return V_.h_ * P_.order_ * S_.rate_ * std::pow( Lambda, P_.order_ - 1 ) * std::exp( -Lambda ) / gsl_sf_gamma_inc( P_.order_, Lambda ); }