本文整理汇总了C++中GSL_ERROR_SELECT_2函数的典型用法代码示例。如果您正苦于以下问题:C++ GSL_ERROR_SELECT_2函数的具体用法?C++ GSL_ERROR_SELECT_2怎么用?C++ GSL_ERROR_SELECT_2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GSL_ERROR_SELECT_2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gsl_sf_legendre_H3d_array
int
gsl_sf_legendre_H3d_array(const int lmax, const double lambda, const double eta, double * result_array)
{
/* CHECK_POINTER(result_array) */
if(eta < 0.0 || lmax < 0) {
int ell;
for(ell=0; ell<=lmax; ell++) result_array[ell] = 0.0;
GSL_ERROR ("domain error", GSL_EDOM);
}
else if(eta > GSL_LOG_DBL_MAX) {
/* cosh(eta) is too big. */
int ell;
for(ell=0; ell<=lmax; ell++) result_array[ell] = 0.0;
GSL_ERROR ("overflow", GSL_EOVRFLW);
}
else if(lmax == 0) {
gsl_sf_result H0;
int stat = gsl_sf_legendre_H3d_e(0, lambda, eta, &H0);
result_array[0] = H0.val;
return stat;
}
else {
/* Not the most efficient method. But what the hell... it's simple.
*/
gsl_sf_result r_Hlp1;
gsl_sf_result r_Hl;
int stat_lmax = gsl_sf_legendre_H3d_e(lmax, lambda, eta, &r_Hlp1);
int stat_lmaxm1 = gsl_sf_legendre_H3d_e(lmax-1, lambda, eta, &r_Hl);
int stat_max = GSL_ERROR_SELECT_2(stat_lmax, stat_lmaxm1);
const double coth_eta = 1.0/tanh(eta);
int stat_recursion = GSL_SUCCESS;
double Hlp1 = r_Hlp1.val;
double Hl = r_Hl.val;
double Hlm1;
int ell;
result_array[lmax] = Hlp1;
result_array[lmax-1] = Hl;
for(ell=lmax-1; ell>0; ell--) {
double root_term_0 = sqrt(lambda*lambda + (double)ell*ell);
double root_term_1 = sqrt(lambda*lambda + (ell+1.0)*(ell+1.0));
Hlm1 = ((2.0*ell + 1.0)*coth_eta*Hl - root_term_1 * Hlp1)/root_term_0;
result_array[ell-1] = Hlm1;
if(!(Hlm1 < GSL_DBL_MAX)) stat_recursion = GSL_EOVRFLW;
Hlp1 = Hl;
Hl = Hlm1;
}
return GSL_ERROR_SELECT_2(stat_recursion, stat_max);
}
}
开发者ID:nchaimov,项目名称:m3l-af,代码行数:54,代码来源:legendre_H3d.c
示例2: gsl_sf_hyperg_2F1_renorm_e
int
gsl_sf_hyperg_2F1_renorm_e(const double a, const double b, const double c,
const double x,
gsl_sf_result * result
)
{
const double rinta = floor(a + 0.5);
const double rintb = floor(b + 0.5);
const double rintc = floor(c + 0.5);
const int a_neg_integer = ( a < 0.0 && fabs(a - rinta) < locEPS );
const int b_neg_integer = ( b < 0.0 && fabs(b - rintb) < locEPS );
const int c_neg_integer = ( c < 0.0 && fabs(c - rintc) < locEPS );
if(c_neg_integer) {
if((a_neg_integer && a > c+0.1) || (b_neg_integer && b > c+0.1)) {
/* 2F1 terminates early */
result->val = 0.0;
result->err = 0.0;
return GSL_SUCCESS;
}
else {
/* 2F1 does not terminate early enough, so something survives */
/* [Abramowitz+Stegun, 15.1.2] */
gsl_sf_result g1, g2, g3, g4, g5;
double s1, s2, s3, s4, s5;
int stat = 0;
stat += gsl_sf_lngamma_sgn_e(a-c+1, &g1, &s1);
stat += gsl_sf_lngamma_sgn_e(b-c+1, &g2, &s2);
stat += gsl_sf_lngamma_sgn_e(a, &g3, &s3);
stat += gsl_sf_lngamma_sgn_e(b, &g4, &s4);
stat += gsl_sf_lngamma_sgn_e(-c+2, &g5, &s5);
if(stat != 0) {
DOMAIN_ERROR(result);
}
else {
gsl_sf_result F;
int stat_F = gsl_sf_hyperg_2F1_e(a-c+1, b-c+1, -c+2, x, &F);
double ln_pre_val = g1.val + g2.val - g3.val - g4.val - g5.val;
double ln_pre_err = g1.err + g2.err + g3.err + g4.err + g5.err;
double sg = s1 * s2 * s3 * s4 * s5;
int stat_e = gsl_sf_exp_mult_err_e(ln_pre_val, ln_pre_err,
sg * F.val, F.err,
result);
return GSL_ERROR_SELECT_2(stat_e, stat_F);
}
}
}
else {
/* generic c */
gsl_sf_result F;
gsl_sf_result lng;
double sgn;
int stat_g = gsl_sf_lngamma_sgn_e(c, &lng, &sgn);
int stat_F = gsl_sf_hyperg_2F1_e(a, b, c, x, &F);
int stat_e = gsl_sf_exp_mult_err_e(-lng.val, lng.err,
sgn*F.val, F.err,
result);
return GSL_ERROR_SELECT_3(stat_e, stat_F, stat_g);
}
}
开发者ID:Ayato-Harashima,项目名称:CMVS-PMVS,代码行数:60,代码来源:hyperg_2F1.c
示例3: bessel_J_recur_asymp
static
int
bessel_J_recur_asymp(const double nu, const double x,
gsl_sf_result * Jnu, gsl_sf_result * Jnup1)
{
const double nu_cut = 25.0;
int n;
int steps = ceil(nu_cut - nu) + 1;
gsl_sf_result r_Jnp1;
gsl_sf_result r_Jn;
int stat_O1 = gsl_sf_bessel_Jnu_asymp_Olver_e(nu + steps + 1.0, x, &r_Jnp1);
int stat_O2 = gsl_sf_bessel_Jnu_asymp_Olver_e(nu + steps, x, &r_Jn);
double r_fe = fabs(r_Jnp1.err/r_Jnp1.val) + fabs(r_Jn.err/r_Jn.val);
double Jnp1 = r_Jnp1.val;
double Jn = r_Jn.val;
double Jnm1;
double Jnp1_save;
for(n=steps; n>0; n--) {
Jnm1 = 2.0*(nu+n)/x * Jn - Jnp1;
Jnp1 = Jn;
Jnp1_save = Jn;
Jn = Jnm1;
}
Jnu->val = Jn;
Jnu->err = (r_fe + GSL_DBL_EPSILON * (steps + 1.0)) * fabs(Jn);
Jnup1->val = Jnp1_save;
Jnup1->err = (r_fe + GSL_DBL_EPSILON * (steps + 1.0)) * fabs(Jnp1_save);
return GSL_ERROR_SELECT_2(stat_O1, stat_O2);
}
开发者ID:nchaimov,项目名称:m3l-af,代码行数:33,代码来源:bessel_Jnu.c
示例4: gsl_sf_bessel_yl_array
int gsl_sf_bessel_yl_array(const int lmax, const double x, double * result_array)
{
/* CHECK_POINTER(result_array) */
if(lmax < 0 || x <= 0.0) {
GSL_ERROR ("error", GSL_EDOM);
} else if (lmax == 0) {
gsl_sf_result result;
int stat = gsl_sf_bessel_y0_e(x, &result);
result_array[0] = result.val;
return stat;
} else {
gsl_sf_result r_yell;
gsl_sf_result r_yellm1;
int stat_1 = gsl_sf_bessel_y1_e(x, &r_yell);
int stat_0 = gsl_sf_bessel_y0_e(x, &r_yellm1);
double yellp1;
double yell = r_yell.val;
double yellm1 = r_yellm1.val;
int ell;
result_array[0] = yellm1;
result_array[1] = yell;
for(ell = 1; ell < lmax; ell++) {
yellp1 = (2*ell+1)/x * yell - yellm1;
result_array[ell+1] = yellp1;
yellm1 = yell;
yell = yellp1;
}
return GSL_ERROR_SELECT_2(stat_0, stat_1);
}
}
开发者ID:connorimes,项目名称:parsec-3.0,代码行数:34,代码来源:bessel_y.c
示例5: hyperg_0F1_bessel_I
/* Evaluate bessel_I(nu, x), allowing nu < 0.
* This is fine here because we do not not allow
* nu to be a negative integer.
* x > 0.
*/
static
int
hyperg_0F1_bessel_I(const double nu, const double x, gsl_sf_result * result)
{
if(x > GSL_LOG_DBL_MAX) {
OVERFLOW_ERROR(result);
}
if(nu < 0.0) {
const double anu = -nu;
const double s = 2.0/M_PI * sin(anu*M_PI);
const double ex = exp(x);
gsl_sf_result I;
gsl_sf_result K;
int stat_I = gsl_sf_bessel_Inu_scaled_e(anu, x, &I);
int stat_K = gsl_sf_bessel_Knu_scaled_e(anu, x, &K);
result->val = ex * I.val + s * (K.val / ex);
result->err = ex * I.err + fabs(s * K.err/ex);
result->err += fabs(s * (K.val/ex)) * GSL_DBL_EPSILON * anu * M_PI;
return GSL_ERROR_SELECT_2(stat_K, stat_I);
}
else {
const double ex = exp(x);
gsl_sf_result I;
int stat_I = gsl_sf_bessel_Inu_scaled_e(nu, x, &I);
result->val = ex * I.val;
result->err = ex * I.err + GSL_DBL_EPSILON * fabs(result->val);
return stat_I;
}
}
开发者ID:ICML14MoMCompare,项目名称:spectral-learn,代码行数:35,代码来源:hyperg_0F1.c
示例6: gsl_sf_hydrogenicR_e
int
gsl_sf_hydrogenicR_e(const int n, const int l,
const double Z, const double r,
gsl_sf_result * result)
{
if(n < 1 || l > n-1 || Z <= 0.0 || r < 0.0) {
DOMAIN_ERROR(result);
}
else {
double A = 2.0*Z/n;
gsl_sf_result norm;
int stat_norm = R_norm(n, l, Z, &norm);
double rho = A*r;
double ea = exp(-0.5*rho);
double pp = gsl_sf_pow_int(rho, l);
gsl_sf_result lag;
int stat_lag = gsl_sf_laguerre_n_e(n-l-1, 2*l+1, rho, &lag);
double W_val = norm.val * ea * pp;
double W_err = norm.err * ea * pp;
W_err += norm.val * ((0.5*rho + 1.0) * GSL_DBL_EPSILON) * ea * pp;
W_err += norm.val * ea * ((l+1.0) * GSL_DBL_EPSILON) * pp;
result->val = W_val * lag.val;
result->err = W_val * lag.err + W_err * fabs(lag.val);
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
if ((l == 0 || (r > 0 && l > 0)) && lag.val != 0.0
&& stat_lag == GSL_SUCCESS && stat_norm == GSL_SUCCESS) {
CHECK_UNDERFLOW(result);
};
return GSL_ERROR_SELECT_2(stat_lag, stat_norm);
}
}
开发者ID:CNMAT,项目名称:CNMAT-Externs,代码行数:31,代码来源:coulomb_bound.c
示例7: gsl_sf_bessel_K1_e
int gsl_sf_bessel_K1_e(const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(x < 2.0*GSL_DBL_MIN) {
OVERFLOW_ERROR(result);
}
else if(x <= 2.0) {
const double lx = log(x);
int stat_I1;
gsl_sf_result I1;
gsl_sf_result c;
cheb_eval_e(&bk1_cs, 0.5*x*x-1.0, &c);
stat_I1 = gsl_sf_bessel_I1_e(x, &I1);
result->val = (lx-M_LN2)*I1.val + (0.75 + c.val)/x;
result->err = c.err/x + fabs(lx)*I1.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return stat_I1;
}
else {
gsl_sf_result K1_scaled;
int stat_K1 = gsl_sf_bessel_K1_scaled_e(x, &K1_scaled);
int stat_e = gsl_sf_exp_mult_err_e(-x, 0.0,
K1_scaled.val, K1_scaled.err,
result);
result->err = fabs(result->val) * (GSL_DBL_EPSILON*fabs(x) + K1_scaled.err/K1_scaled.val);
return GSL_ERROR_SELECT_2(stat_e, stat_K1);
}
}
开发者ID:ICML14MoMCompare,项目名称:spectral-learn,代码行数:32,代码来源:bessel_K1.c
示例8: gsl_sf_bessel_Ynu_asympx_e
/* x >> nu*nu+1
*/
int
gsl_sf_bessel_Ynu_asympx_e(const double nu, const double x, gsl_sf_result * result)
{
double ampl;
double theta;
double alpha = x;
double beta = -0.5*nu*M_PI;
int stat_a = gsl_sf_bessel_asymp_Mnu_e(nu, x, &l);
int stat_t = gsl_sf_bessel_asymp_thetanu_corr_e(nu, x, &theta);
double sin_alpha = sin(alpha);
double cos_alpha = cos(alpha);
double sin_chi = sin(beta + theta);
double cos_chi = cos(beta + theta);
double sin_term = sin_alpha * cos_chi + sin_chi * cos_alpha;
double sin_term_mag = fabs(sin_alpha * cos_chi) + fabs(sin_chi * cos_alpha);
result->val = ampl * sin_term;
result->err = fabs(ampl) * GSL_DBL_EPSILON * sin_term_mag;
result->err += fabs(result->val) * 2.0 * GSL_DBL_EPSILON;
if(fabs(alpha) > 1.0/GSL_DBL_EPSILON) {
result->err *= 0.5 * fabs(alpha);
}
else if(fabs(alpha) > 1.0/GSL_SQRT_DBL_EPSILON) {
result->err *= 256.0 * fabs(alpha) * GSL_SQRT_DBL_EPSILON;
}
return GSL_ERROR_SELECT_2(stat_t, stat_a);
}
开发者ID:ICML14MoMCompare,项目名称:spectral-learn,代码行数:30,代码来源:bessel.c
示例9: gsl_sf_ellint_Ecomp_e
/* [Carlson, Numer. Math. 33 (1979) 1, (4.6)] */
int
gsl_sf_ellint_Ecomp_e(double k, gsl_mode_t mode, gsl_sf_result * result)
{
if(k*k >= 1.0) {
DOMAIN_ERROR(result);
}
else if(k*k >= 1.0 - GSL_SQRT_DBL_EPSILON) {
/* [Abramowitz+Stegun, 17.3.36] */
const double y = 1.0 - k*k;
const double a[] = { 0.44325141463, 0.06260601220, 0.04757383546 };
const double b[] = { 0.24998368310, 0.09200180037, 0.04069697526 };
const double ta = 1.0 + y*(a[0] + y*(a[1] + a[2]*y));
const double tb = -y*log(y) * (b[0] + y*(b[1] + b[2]*y));
result->val = ta + tb;
result->err = 2.0 * GSL_DBL_EPSILON * result->val;
return GSL_SUCCESS;
}
else {
gsl_sf_result rf;
gsl_sf_result rd;
const double y = 1.0 - k*k;
const int rfstatus = gsl_sf_ellint_RF_e(0.0, y, 1.0, mode, &rf);
const int rdstatus = gsl_sf_ellint_RD_e(0.0, y, 1.0, mode, &rd);
result->val = rf.val - k*k/3.0 * rd.val;
result->err = rf.err + k*k/3.0 * rd.err;
return GSL_ERROR_SELECT_2(rfstatus, rdstatus);
}
}
开发者ID:tommyliu,项目名称:visionPJ1,代码行数:29,代码来源:ellint.c
示例10: gsl_sf_bessel_K0_e
int gsl_sf_bessel_K0_e(const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(x <= 2.0) {
const double lx = log(x);
int stat_I0;
gsl_sf_result I0;
gsl_sf_result c;
cheb_eval_e(&bk0_cs, 0.5*x*x-1.0, &c);
stat_I0 = gsl_sf_bessel_I0_e(x, &I0);
result->val = (-lx+M_LN2)*I0.val - 0.25 + c.val;
result->err = (fabs(lx) + M_LN2) * I0.err + c.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return stat_I0;
}
else {
gsl_sf_result K0_scaled;
int stat_K0 = gsl_sf_bessel_K0_scaled_e(x, &K0_scaled);
int stat_e = gsl_sf_exp_mult_err_e(-x, GSL_DBL_EPSILON*fabs(x),
K0_scaled.val, K0_scaled.err,
result);
return GSL_ERROR_SELECT_2(stat_e, stat_K0);
}
}
开发者ID:ICML14MoMCompare,项目名称:spectral-learn,代码行数:28,代码来源:bessel_K0.c
示例11: gamma_inc_Q_CF_protected
/* See note above for gamma_inc_Q_CF(). */
static
int
gamma_inc_Q_CF_protected(const double a, const double x, gsl_sf_result * result)
{
if(fabs(1.0 - a + x) < 2.0*GSL_DBL_EPSILON) {
/*
* This is a problem region because when
* 1.0 - a + x = 0 the first term of the
* CF recursion is undefined.
*
* I missed this condition when I first
* implemented gamma_inc_Q_CF() function,
* so now I have to fix it by side-stepping
* this point, using the recursion relation
* Q(a,x) = Q(a-1,x) + x^(a-1) e^(-z) / Gamma(a)
* = Q(a-1,x) + D(a-1,x)
* to lower 'a' by one, giving an a=x point,
* which is fine.
*/
gsl_sf_result D;
gsl_sf_result tmp_CF;
const int stat_tmp_CF = gamma_inc_Q_CF(a-1.0, x, &tmp_CF);
const int stat_D = gamma_inc_D(a-1.0, x, &D);
result->val = tmp_CF.val + D.val;
result->err = tmp_CF.err + D.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_ERROR_SELECT_2(stat_tmp_CF, stat_D);
}
else {
return gamma_inc_Q_CF(a, x, result);
}
}
开发者ID:ICML14MoMCompare,项目名称:spectral-learn,代码行数:35,代码来源:gamma_inc.c
示例12: gsl_sf_bessel_il_scaled_array
int gsl_sf_bessel_il_scaled_array(const int lmax, const double x, double * result_array)
{
if(x == 0.0) {
int ell;
result_array[0] = 1.0;
for (ell = lmax; ell >= 1; ell--) {
result_array[ell] = 0.0;
};
return GSL_SUCCESS;
} else {
int ell;
gsl_sf_result r_iellp1;
gsl_sf_result r_iell;
int stat_0 = gsl_sf_bessel_il_scaled_e(lmax+1, x, &r_iellp1);
int stat_1 = gsl_sf_bessel_il_scaled_e(lmax, x, &r_iell);
double iellp1 = r_iellp1.val;
double iell = r_iell.val;
double iellm1;
result_array[lmax] = iell;
for(ell = lmax; ell >= 1; ell--) {
iellm1 = iellp1 + (2*ell + 1)/x * iell;
iellp1 = iell;
iell = iellm1;
result_array[ell-1] = iellm1;
}
return GSL_ERROR_SELECT_2(stat_0, stat_1);
}
}
开发者ID:Ayato-Harashima,项目名称:CMVS-PMVS,代码行数:28,代码来源:bessel_i.c
示例13: gsl_sf_Ci_e
int gsl_sf_Ci_e(const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(x <= 4.0) {
const double lx = log(x);
const double y = (x*x-8.0)*0.125;
gsl_sf_result result_c;
cheb_eval_e(&ci_cs, y, &result_c);
result->val = lx - 0.5 + result_c.val;
result->err = 2.0 * GSL_DBL_EPSILON * (fabs(lx) + 0.5) + result_c.err;
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_SUCCESS;
}
else {
gsl_sf_result sin_result;
gsl_sf_result cos_result;
int stat_sin = gsl_sf_sin_e(x, &sin_result);
int stat_cos = gsl_sf_cos_e(x, &cos_result);
gsl_sf_result f;
gsl_sf_result g;
fg_asymp(x, &f, &g);
result->val = f.val*sin_result.val - g.val*cos_result.val;
result->err = fabs(f.err*sin_result.val);
result->err += fabs(g.err*cos_result.val);
result->err += fabs(f.val*sin_result.err);
result->err += fabs(g.val*cos_result.err);
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_ERROR_SELECT_2(stat_sin, stat_cos);
}
}
开发者ID:tommyliu,项目名称:visionPJ1,代码行数:34,代码来源:sinint.c
示例14: gsl_sf_bessel_Knu_e
int
gsl_sf_bessel_Knu_e(const double nu, const double x, gsl_sf_result * result)
{
gsl_sf_result b;
int stat_K = gsl_sf_bessel_Knu_scaled_e(nu, x, &b);
int stat_e = gsl_sf_exp_mult_err_e(-x, 0.0, b.val, b.err, result);
return GSL_ERROR_SELECT_2(stat_e, stat_K);
}
开发者ID:Ayato-Harashima,项目名称:CMVS-PMVS,代码行数:8,代码来源:bessel_Knu.c
示例15: gsl_sf_hyperg_2F1_conj_renorm_e
int
gsl_sf_hyperg_2F1_conj_renorm_e(const double aR, const double aI, const double c,
const double x,
gsl_sf_result * result
)
{
const double rintc = floor(c + 0.5);
const double rinta = floor(aR + 0.5);
const int a_neg_integer = ( aR < 0.0 && fabs(aR-rinta) < locEPS && aI == 0.0);
const int c_neg_integer = ( c < 0.0 && fabs(c - rintc) < locEPS );
if(c_neg_integer) {
if(a_neg_integer && aR > c+0.1) {
/* 2F1 terminates early */
result->val = 0.0;
result->err = 0.0;
return GSL_SUCCESS;
}
else {
/* 2F1 does not terminate early enough, so something survives */
/* [Abramowitz+Stegun, 15.1.2] */
gsl_sf_result g1, g2;
gsl_sf_result g3;
gsl_sf_result a1, a2;
int stat = 0;
stat += gsl_sf_lngamma_complex_e(aR-c+1, aI, &g1, &a1);
stat += gsl_sf_lngamma_complex_e(aR, aI, &g2, &a2);
stat += gsl_sf_lngamma_e(-c+2.0, &g3);
if(stat != 0) {
DOMAIN_ERROR(result);
}
else {
gsl_sf_result F;
int stat_F = gsl_sf_hyperg_2F1_conj_e(aR-c+1, aI, -c+2, x, &F);
double ln_pre_val = 2.0*(g1.val - g2.val) - g3.val;
double ln_pre_err = 2.0 * (g1.err + g2.err) + g3.err;
int stat_e = gsl_sf_exp_mult_err_e(ln_pre_val, ln_pre_err,
F.val, F.err,
result);
return GSL_ERROR_SELECT_2(stat_e, stat_F);
}
}
}
else {
/* generic c */
gsl_sf_result F;
gsl_sf_result lng;
double sgn;
int stat_g = gsl_sf_lngamma_sgn_e(c, &lng, &sgn);
int stat_F = gsl_sf_hyperg_2F1_conj_e(aR, aI, c, x, &F);
int stat_e = gsl_sf_exp_mult_err_e(-lng.val, lng.err,
sgn*F.val, F.err,
result);
return GSL_ERROR_SELECT_3(stat_e, stat_F, stat_g);
}
}
开发者ID:Ayato-Harashima,项目名称:CMVS-PMVS,代码行数:56,代码来源:hyperg_2F1.c
示例16: gsl_sf_bessel_yl_e
int gsl_sf_bessel_yl_e(int l, const double x, gsl_sf_result * result)
{
/* CHECK_POINTER(result) */
if(l < 0 || x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(l == 0) {
return gsl_sf_bessel_y0_e(x, result);
}
else if(l == 1) {
return gsl_sf_bessel_y1_e(x, result);
}
else if(l == 2) {
return gsl_sf_bessel_y2_e(x, result);
}
else if(x < 3.0) {
return bessel_yl_small_x(l, x, result);
}
else if(GSL_ROOT3_DBL_EPSILON * x > (l*l + l + 1.0)) {
int status = gsl_sf_bessel_Ynu_asympx_e(l + 0.5, x, result);
double pre = sqrt((0.5*M_PI)/x);
result->val *= pre;
result->err *= pre;
return status;
}
else if(l > 40) {
int status = gsl_sf_bessel_Ynu_asymp_Olver_e(l + 0.5, x, result);
double pre = sqrt((0.5*M_PI)/x);
result->val *= pre;
result->err *= pre;
return status;
}
else {
/* recurse upward */
gsl_sf_result r_by;
gsl_sf_result r_bym;
int stat_1 = gsl_sf_bessel_y1_e(x, &r_by);
int stat_0 = gsl_sf_bessel_y0_e(x, &r_bym);
double bym = r_bym.val;
double by = r_by.val;
double byp;
int j;
for(j=1; j<l; j++) {
byp = (2*j+1)/x*by - bym;
bym = by;
by = byp;
}
result->val = by;
result->err = fabs(result->val) * (GSL_DBL_EPSILON + fabs(r_by.err/r_by.val) + fabs(r_bym.err/r_bym.val));
return GSL_ERROR_SELECT_2(stat_1, stat_0);
}
}
开发者ID:connorimes,项目名称:parsec-3.0,代码行数:54,代码来源:bessel_y.c
示例17: gsl_sf_bessel_kl_scaled_e
int gsl_sf_bessel_kl_scaled_e(int l, const double x, gsl_sf_result * result)
{
if(l < 0 || x <= 0.0) {
DOMAIN_ERROR(result);
}
else if(l == 0) {
return gsl_sf_bessel_k0_scaled_e(x, result);
}
else if(l == 1) {
return gsl_sf_bessel_k1_scaled_e(x, result);
}
else if(l == 2) {
return gsl_sf_bessel_k2_scaled_e(x, result);
}
else if(x < 3.0) {
return bessel_kl_scaled_small_x(l, x, result);
}
else if(GSL_ROOT3_DBL_EPSILON * x > (l*l + l + 1)) {
int status = gsl_sf_bessel_Knu_scaled_asympx_e(l + 0.5, x, result);
double pre = sqrt((0.5*M_PI)/x);
result->val *= pre;
result->err *= pre;
return status;
}
else if(GSL_MIN(0.29/(l*l+1.0), 0.5/(l*l+1.0+x*x)) < GSL_ROOT3_DBL_EPSILON) {
int status = gsl_sf_bessel_Knu_scaled_asymp_unif_e(l + 0.5, x, result);
double pre = sqrt((0.5*M_PI)/x);
result->val *= pre;
result->err *= pre;
return status;
}
else {
/* recurse upward */
gsl_sf_result r_bk;
gsl_sf_result r_bkm;
int stat_1 = gsl_sf_bessel_k1_scaled_e(x, &r_bk);
int stat_0 = gsl_sf_bessel_k0_scaled_e(x, &r_bkm);
double bkp;
double bk = r_bk.val;
double bkm = r_bkm.val;
int j;
for(j=1; j<l; j++) {
bkp = (2*j+1)/x*bk + bkm;
bkm = bk;
bk = bkp;
}
result->val = bk;
result->err = fabs(bk) * (fabs(r_bk.err/r_bk.val) + fabs(r_bkm.err/r_bkm.val));
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_ERROR_SELECT_2(stat_1, stat_0);
}
}
开发者ID:nchaimov,项目名称:m3l-af,代码行数:53,代码来源:bessel_k.c
示例18: gsl_sf_bessel_K_scaled_temme
int
gsl_sf_bessel_K_scaled_temme(const double nu, const double x,
double * K_nu, double * K_nup1, double * Kp_nu)
{
const int max_iter = 15000;
const double half_x = 0.5 * x;
const double ln_half_x = log(half_x);
const double half_x_nu = exp(nu*ln_half_x);
const double pi_nu = M_PI * nu;
const double sigma = -nu * ln_half_x;
const double sinrat = (fabs(pi_nu) < GSL_DBL_EPSILON ? 1.0 : pi_nu/sin(pi_nu));
const double sinhrat = (fabs(sigma) < GSL_DBL_EPSILON ? 1.0 : sinh(sigma)/sigma);
const double ex = exp(x);
double sum0, sum1;
double fk, pk, qk, hk, ck;
int k = 0;
int stat_iter;
double g_1pnu, g_1mnu, g1, g2;
int stat_g = gsl_sf_temme_gamma(nu, &g_1pnu, &g_1mnu, &g1, &g2);
fk = sinrat * (cosh(sigma)*g1 - sinhrat*ln_half_x*g2);
pk = 0.5/half_x_nu * g_1pnu;
qk = 0.5*half_x_nu * g_1mnu;
hk = pk;
ck = 1.0;
sum0 = fk;
sum1 = hk;
while(k < max_iter) {
double del0;
double del1;
k++;
fk = (k*fk + pk + qk)/(k*k-nu*nu);
ck *= half_x*half_x/k;
pk /= (k - nu);
qk /= (k + nu);
hk = -k*fk + pk;
del0 = ck * fk;
del1 = ck * hk;
sum0 += del0;
sum1 += del1;
if(fabs(del0) < 0.5*fabs(sum0)*GSL_DBL_EPSILON) break;
}
*K_nu = sum0 * ex;
*K_nup1 = sum1 * 2.0/x * ex;
*Kp_nu = - *K_nup1 + nu/x * *K_nu;
stat_iter = ( k == max_iter ? GSL_EMAXITER : GSL_SUCCESS );
return GSL_ERROR_SELECT_2(stat_iter, stat_g);
}
开发者ID:ICML14MoMCompare,项目名称:spectral-learn,代码行数:53,代码来源:bessel_temme.c
示例19: gsl_sf_bessel_In_scaled_array
int
gsl_sf_bessel_In_scaled_array(const int nmin, const int nmax, const double x, double * result_array)
{
/* CHECK_POINTER(result_array) */
if(nmax < nmin || nmin < 0) {
int j;
for(j=0; j<=nmax-nmin; j++) result_array[j] = 0.0;
GSL_ERROR ("domain error", GSL_EDOM);
}
else if(x == 0.0) {
int j;
for(j=0; j<=nmax-nmin; j++) result_array[j] = 0.0;
if(nmin == 0) result_array[0] = 1.0;
return GSL_SUCCESS;
}
else if(nmax == 0) {
gsl_sf_result I0_scaled;
int stat = gsl_sf_bessel_I0_scaled_e(x, &I0_scaled);
result_array[0] = I0_scaled.val;
return stat;
}
else {
const double ax = fabs(x);
const double two_over_x = 2.0/ax;
/* starting values */
gsl_sf_result r_Inp1;
gsl_sf_result r_In;
int stat_0 = gsl_sf_bessel_In_scaled_e(nmax+1, ax, &r_Inp1);
int stat_1 = gsl_sf_bessel_In_scaled_e(nmax, ax, &r_In);
double Inp1 = r_Inp1.val;
double In = r_In.val;
double Inm1;
int n;
for(n=nmax; n>=nmin; n--) {
result_array[n-nmin] = In;
Inm1 = Inp1 + n * two_over_x * In;
Inp1 = In;
In = Inm1;
}
/* deal with signs */
if(x < 0.0) {
for(n=nmin; n<=nmax; n++) {
if(GSL_IS_ODD(n)) result_array[n-nmin] = -result_array[n-nmin];
}
}
return GSL_ERROR_SELECT_2(stat_0, stat_1);
}
}
开发者ID:Ayato-Harashima,项目名称:CMVS-PMVS,代码行数:53,代码来源:bessel_In.c
示例20: gamma_inc_series
/* series for small a and x, but not defined for a == 0 */
static int
gamma_inc_series(double a, double x, gsl_sf_result * result)
{
gsl_sf_result Q;
gsl_sf_result G;
const int stat_Q = gamma_inc_Q_series(a, x, &Q);
const int stat_G = gsl_sf_gamma_e(a, &G);
result->val = Q.val * G.val;
result->err = fabs(Q.val * G.err) + fabs(Q.err * G.val);
result->err += 2.0 * GSL_DBL_EPSILON * fabs(result->val);
return GSL_ERROR_SELECT_2(stat_Q, stat_G);
}
开发者ID:altoplano,项目名称:RICO,代码行数:14,代码来源:gamma_inc.c
注:本文中的GSL_ERROR_SELECT_2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论