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); } }
static VALUE rb_gsl_sf_legendre_H3d_e(VALUE obj,VALUE l, VALUE lambda, VALUE eta) { gsl_sf_result *rslt = NULL; VALUE v; // local variable "status" declared and set, but never used //int status; CHECK_FIXNUM(l); Need_Float(lambda); Need_Float(eta); v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt); /*status =*/ gsl_sf_legendre_H3d_e(FIX2INT(l), NUM2DBL(lambda), NUM2DBL(eta), rslt); return v; }
double gsl_sf_legendre_H3d(const int l, const double lambda, const double eta) { EVAL_RESULT(gsl_sf_legendre_H3d_e(l, lambda, eta, &result)); }