static VALUE rb_gsl_blas_dscal(int argc, VALUE *argv, VALUE obj) { double a; gsl_vector *x = NULL; switch (TYPE(obj)) { case T_MODULE: case T_CLASS: case T_OBJECT: if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc); Need_Float(argv[0]); CHECK_VECTOR(argv[1]); a = RFLOAT_VALUE(argv[0]); Data_Get_Struct(argv[1], gsl_vector, x); gsl_blas_dscal(a, x); return argv[1]; break; default: if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc); Need_Float(argv[0]); a = RFLOAT_VALUE(argv[0]); Data_Get_Struct(obj, gsl_vector, x); gsl_blas_dscal(a, x); return obj; break; } return Qnil; /* never reach here */ }
static VALUE rb_gsl_interp_eval_integ_e(VALUE obj, VALUE xxa, VALUE yya, VALUE aa, VALUE bb) { rb_gsl_interp *rgi = NULL; double *ptr1 = NULL, *ptr2 = NULL; size_t size, stridex, stridey; double y, a, b; int status; Need_Float(aa); Need_Float(bb); Data_Get_Struct(obj, rb_gsl_interp, rgi); ptr1 = get_vector_ptr(xxa, &stridex, &size); ptr2 = get_vector_ptr(yya, &stridey, &size); a = NUM2DBL(aa); b = NUM2DBL(bb); status = gsl_interp_eval_integ_e(rgi->p, ptr1, ptr2, a, b, rgi->a, &y); switch (status) { case GSL_EDOM: rb_gsl_error_handler("gsl_interp_eval_integ_e error", __FILE__, __LINE__, status); break; default: return rb_float_new(y); break; } return Qnil; }
static VALUE rb_gsl_blas_daxpy(int argc, VALUE *argv, VALUE obj) { double a; gsl_vector *x = NULL, *y = NULL; switch (TYPE(obj)) { case T_MODULE: case T_CLASS: case T_OBJECT: get_vector2(argc-1, argv+1, obj, &x, &y); Need_Float(argv[0]); // a = RFLOAT(argv[0])->value; a = NUM2DBL(argv[0]); break; default: Data_Get_Struct(obj, gsl_vector, x); if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc); Need_Float(argv[0]); // a = RFLOAT(argv[0])->value; a = NUM2DBL(argv[0]); Data_Get_Vector(argv[1], y); break; } gsl_blas_daxpy(a, x, y); return argv[argc-1]; }
static VALUE rb_gsl_sf_lngamma_complex_e(int argc, VALUE *argv, VALUE obj) { gsl_sf_result *lnr, *arg; gsl_complex *z; double re, im; VALUE vlnr, varg; int status; switch (argc) { case 1: CHECK_COMPLEX(argv[0]); Data_Get_Struct(argv[0], gsl_complex, z); re = GSL_REAL(*z); im = GSL_IMAG(*z); break; case 2: Need_Float(argv[0]); Need_Float(argv[1]); re = NUM2DBL(argv[0]); im = NUM2DBL(argv[1]); default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc); } vlnr = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, lnr); varg = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, arg); status = gsl_sf_lngamma_complex_e(re, im, lnr, arg); return rb_ary_new3(3, vlnr, varg, INT2FIX(status)); }
static VALUE rb_gsl_sf_complex_XXX_e(int argc, VALUE *argv, VALUE obj, int (*f)(double, double, gsl_sf_result*, gsl_sf_result*)) { gsl_sf_result *r1, *r2; gsl_complex *z; double re, im; VALUE v1, v2; // local variable "status" declared and set, but never used //int status; switch (argc) { case 1: CHECK_COMPLEX(argv[0]); Data_Get_Struct(argv[0], gsl_complex, z); re = GSL_REAL(*z); im = GSL_IMAG(*z); break; case 2: Need_Float(argv[0]); Need_Float(argv[1]); re = NUM2DBL(argv[0]); im = NUM2DBL(argv[1]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc); break; } v1 = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, r1); v2 = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, r2); /*status =*/ (*f)(re, im, r1, r2); return rb_ary_new3(2, v1, v2); }
static VALUE rb_gsl_sf_coulomb_wave_FGp_array(VALUE obj, VALUE Lmin, VALUE kmax, VALUE eta, VALUE x) { double F_exponent, G_exponent; int status; size_t size; gsl_vector *vf = NULL, *vg = NULL, *vfp = NULL, *vgp = NULL; VALUE fary, gary, fpary, gpary; CHECK_FIXNUM(kmax); Need_Float(Lmin); Need_Float(eta); Need_Float(x); size = FIX2INT(kmax); vf = gsl_vector_alloc(size); vfp = gsl_vector_alloc(size); vg = gsl_vector_alloc(size); vgp = gsl_vector_alloc(size); status = gsl_sf_coulomb_wave_FGp_array(NUM2DBL(Lmin), size, NUM2DBL(eta), NUM2DBL(x), vf->data, vfp->data, vg->data, vgp->data, &F_exponent, &G_exponent); fary = Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vf); fpary =Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vfp); gary = Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vg); gpary =Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, vgp); return rb_ary_new3(7, fary, fpary, gary, gpary, rb_float_new(F_exponent), rb_float_new(G_exponent), INT2FIX(status)); }
static VALUE rb_gsl_blas_zdscal2(int argc, VALUE *argv, VALUE obj) { double a; gsl_vector_complex *x = NULL, *xnew = NULL; switch (TYPE(obj)) { case T_MODULE: case T_CLASS: case T_OBJECT: if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc); Need_Float(argv[0]); CHECK_VECTOR_COMPLEX(argv[1]); a = NUM2DBL(argv[0]); Data_Get_Struct(argv[1], gsl_vector_complex, x); break; default: Data_Get_Struct(obj, gsl_vector_complex, x); if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc); Need_Float(argv[0]); a = NUM2DBL(argv[0]); break; } xnew = gsl_vector_complex_alloc(x->size); gsl_vector_complex_memcpy(xnew, x); gsl_blas_zdscal(a, xnew); return Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, xnew); }
static VALUE rb_gsl_fit_mul_est(int argc, VALUE *argv, VALUE obj) { double y, yerr, x, c1, c11; int status; switch (argc) { case 2: Need_Float(argv[0]); if (TYPE(argv[1]) == T_ARRAY) { c1 = NUM2DBL(rb_ary_entry(argv[1], 0)); c11 = NUM2DBL(rb_ary_entry(argv[1], 1)); } else { rb_raise(rb_eTypeError, "argv[1]: Array expected"); } x = NUM2DBL(argv[0]); break; case 3: Need_Float(argv[0]); Need_Float(argv[1]); Need_Float(argv[2]); x = NUM2DBL(argv[0]); c1 = NUM2DBL(argv[1]); c11 = NUM2DBL(argv[2]); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc); break; } status = gsl_fit_mul_est(x, c1, c11, &y, &yerr); return rb_ary_new3(3, rb_float_new(y), rb_float_new(yerr), INT2FIX(status)); }
static VALUE rb_gsl_hypot3(VALUE obj, VALUE x, VALUE y, VALUE z) { Need_Float(x); Need_Float(y); Need_Float(z); return rb_float_new(gsl_hypot3(NUM2DBL(x), NUM2DBL(y), NUM2DBL(z))); }
static VALUE rb_gsl_blas_zdscal(int argc, VALUE *argv, VALUE obj) { double a; gsl_vector_complex *x = NULL; switch (TYPE(obj)) { case T_MODULE: case T_CLASS: case T_OBJECT: if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc); Need_Float(argv[0]); CHECK_VECTOR_COMPLEX(argv[1]); // a = RFLOAT(argv[0])->value; a = NUM2DBL(argv[0]); Data_Get_Struct(argv[1], gsl_vector_complex, x); gsl_blas_zdscal(a, x); return argv[1]; break; default: Data_Get_Struct(obj, gsl_vector_complex, x); if (argc != 1) rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc); Need_Float(argv[0]); a = NUM2DBL(argv[0]); gsl_blas_zdscal(a, x); return obj; break; } }
static VALUE rb_gsl_blas_daxpy2(int argc, VALUE *argv, VALUE obj) { double a; gsl_vector *x = NULL, *y = NULL, *y2 = NULL; switch (TYPE(obj)) { case T_MODULE: case T_CLASS: case T_OBJECT: get_vector2(argc-1, argv+1, obj, &x, &y); Need_Float(argv[0]); // a = RFLOAT(argv[0])->value; a = NUM2DBL(argv[0]); break; default: Data_Get_Struct(obj, gsl_vector, x); if (argc != 2) rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc); Need_Float(argv[0]); CHECK_VECTOR(argv[1]); // a = RFLOAT(argv[0])->value; a = NUM2DBL(argv[0]); Data_Get_Struct(argv[1], gsl_vector, y); break; } y2 = gsl_vector_alloc(y->size); gsl_vector_memcpy(y2, y); gsl_blas_daxpy(a, x, y2); return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, y2); }
static VALUE rb_gsl_odeiv_control_yp_new(VALUE klass, VALUE epsabs, VALUE epsrel) { gsl_odeiv_control *c = NULL; Need_Float(epsabs); Need_Float(epsrel); c = gsl_odeiv_control_yp_new(NUM2DBL(epsabs), NUM2DBL(epsrel)); return Data_Wrap_Struct(klass, 0, gsl_odeiv_control_free, c); }
static VALUE rb_gsl_root_test_delta(VALUE obj, VALUE xl, VALUE xu, VALUE eabs, VALUE erel) { Need_Float(xl); Need_Float(xu); Need_Float(eabs); Need_Float(erel); return INT2FIX(gsl_root_test_delta(NUM2DBL(xl), NUM2DBL(xu), NUM2DBL(eabs), NUM2DBL(erel))); }
static VALUE rb_gsl_fsolver_test_interval(VALUE obj, VALUE eabs, VALUE erel) { gsl_root_fsolver *s = NULL; Need_Float(eabs); Need_Float(erel); Data_Get_Struct(obj, gsl_root_fsolver, s); return INT2FIX(gsl_root_test_interval(s->x_lower, s->x_upper, NUM2DBL(eabs), NUM2DBL(erel))); }
static VALUE rb_gsl_fminimizer_test_interval(VALUE obj, VALUE xl, VALUE xu, VALUE ea, VALUE er) { Need_Float(xl); Need_Float(xu); Need_Float(ea); Need_Float(er); return INT2FIX(gsl_min_test_interval(NUM2DBL(xl), NUM2DBL(xu), NUM2DBL(ea), NUM2DBL(er))); }
static VALUE rb_gsl_sf_gegenpoly_array(VALUE obj, VALUE nmax, VALUE lambda, VALUE x) { gsl_vector *v = NULL; CHECK_FIXNUM(nmax); Need_Float(lambda); Need_Float(x); v = gsl_vector_alloc(nmax); gsl_sf_gegenpoly_array(FIX2INT(nmax), NUM2DBL(lambda), NUM2DBL(x), v->data); return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, v); }
static gsl_odeiv_control* make_control_standard(VALUE epsabs, VALUE epsrel, VALUE ay, VALUE adydt) { Need_Float(epsabs); Need_Float(epsrel); Need_Float(ay); Need_Float(adydt); return gsl_odeiv_control_standard_new(NUM2DBL(epsabs), NUM2DBL(epsrel), NUM2DBL(ay), NUM2DBL(adydt)); }
static VALUE rb_gsl_sf_elljac_e(VALUE obj, VALUE n, VALUE m) { double sn, cn, dn; // local variable "status" declared and set, but never used //int status; Need_Float(n); Need_Float(m); /*status =*/ gsl_sf_elljac_e(NUM2DBL(n), NUM2DBL(m), &sn, &cn, &dn); return rb_ary_new3(3, rb_float_new(sn), rb_float_new(cn), rb_float_new(dn)); }
static VALUE rb_gsl_sf_multiply_e(VALUE obj, VALUE x, VALUE y) { gsl_sf_result *r; VALUE v; int status; Need_Float(x); Need_Float(y); v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, r); status = gsl_sf_multiply_e(NUM2DBL(x), NUM2DBL(y), r); return v; }
static VALUE rb_gsl_sf_legendre_H3d_array(VALUE obj, VALUE lmax, VALUE lambda, VALUE eta) { gsl_vector *v = NULL; CHECK_FIXNUM(lmax); Need_Float(lambda); Need_Float(eta); v = gsl_vector_alloc(FIX2INT(lmax) + 1); gsl_sf_legendre_H3d_array(FIX2INT(lmax), NUM2DBL(lambda), NUM2DBL(eta), v->data); return Data_Wrap_Struct(cgsl_vector, 0, gsl_vector_free, v); }
static VALUE rb_gsl_min_fminimizer_test_interval(VALUE obj, VALUE ea, VALUE er) { gsl_min_fminimizer *gmf = NULL; double xl, xu; Need_Float(ea); Need_Float(er); Data_Get_Struct(obj, gsl_min_fminimizer, gmf); xl = gsl_min_fminimizer_x_lower(gmf); xu = gsl_min_fminimizer_x_upper(gmf); return INT2FIX(gsl_min_test_interval(xl, xu, NUM2DBL(ea), NUM2DBL(er))); }
static VALUE rb_gsl_sf_lnpoch_sgn_e(VALUE obj, VALUE a, VALUE x) { gsl_sf_result *rslt = NULL; VALUE v; double sgn; int status; Need_Float(a); Need_Float(x); v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt); status = gsl_sf_lnpoch_sgn_e(NUM2DBL(a), NUM2DBL(x), rslt, &sgn); return rb_ary_new3(2, v, rb_float_new(sgn)); }
static VALUE rb_gsl_min_fminimizer_set(VALUE obj, VALUE ff, VALUE xmin, VALUE xl, VALUE xu) { gsl_min_fminimizer *gmf = NULL; gsl_function *f = NULL; Need_Float(xmin); Need_Float(xl); Need_Float(xu); CHECK_FUNCTION(ff); Data_Get_Struct(obj, gsl_min_fminimizer, gmf); Data_Get_Struct(ff, gsl_function, f); return INT2FIX(gsl_min_fminimizer_set(gmf, f, NUM2DBL(xmin), NUM2DBL(xl), NUM2DBL(xu))); }
static VALUE rb_gsl_sf_cos_err_e(VALUE obj, VALUE x, VALUE dx) { gsl_sf_result *rslt = NULL; VALUE v; // local variable "status" declared and set, but never used //int status; Need_Float(x); Need_Float(dx); v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt); /*status =*/ gsl_sf_cos_err_e(NUM2DBL(x), NUM2DBL(dx), rslt); return v; }
static VALUE rb_gsl_sf_laguerre_n_e(VALUE obj, VALUE n, VALUE a, VALUE x) { gsl_sf_result *rslt = NULL; VALUE v; // local variable "status" declared and set, but never used //int status; CHECK_FIXNUM(n); Need_Float(a); Need_Float(x); v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt); /*status =*/ gsl_sf_laguerre_n_e(FIX2INT(n), NUM2DBL(a), NUM2DBL(x), rslt); return v; }
static VALUE rb_gsl_sf_lnpoch_sgn_e(VALUE obj, VALUE a, VALUE x) { gsl_sf_result *rslt = NULL; VALUE v; double sgn; // local variable "status" declared and set, but never used //int status; Need_Float(a); Need_Float(x); v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt); /*status =*/ gsl_sf_lnpoch_sgn_e(NUM2DBL(a), NUM2DBL(x), rslt, &sgn); return rb_ary_new3(2, v, rb_float_new(sgn)); }
static VALUE rb_gsl_sf_complex_dilog_e(VALUE obj, VALUE r, VALUE theta) { gsl_sf_result *re, *im; VALUE vre, vim; // local variable "status" declared and set, but never used //int status; Need_Float(r); Need_Float(theta); vre = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, re); vim = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, im); /*status =*/ gsl_sf_complex_dilog_e(NUM2DBL(r), NUM2DBL(theta), re, im); return rb_ary_new3(2, vre, vim); }
static VALUE rb_gsl_interp_accel_find(VALUE obj, VALUE vv, VALUE xx) { gsl_interp_accel *a = NULL; double x, *ptr = NULL; size_t size, stride; Need_Float(xx); Data_Get_Struct(obj, gsl_interp_accel, a); ptr = get_vector_ptr(vv, &stride, &size); Need_Float(xx); x = NUM2DBL(xx); return INT2FIX(gsl_interp_accel_find(a, ptr, size, x)); }
static VALUE rb_gsl_odeiv_control_init(VALUE obj, VALUE epsabs, VALUE epsrel, VALUE ay, VALUE adydt) { gsl_odeiv_control *c = NULL; Need_Float(epsabs); Need_Float(epsrel); Need_Float(ay); Need_Float(adydt); Data_Get_Struct(obj, gsl_odeiv_control, c); gsl_odeiv_control_init(c, NUM2DBL(epsabs), NUM2DBL(epsrel), NUM2DBL(ay), NUM2DBL(adydt)); return obj; }
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; }