本文整理汇总了C++中Need_Float函数的典型用法代码示例。如果您正苦于以下问题:C++ Need_Float函数的具体用法?C++ Need_Float怎么用?C++ Need_Float使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Need_Float函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_gsl_blas_dscal
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 */
}
示例2: rb_gsl_interp_eval_integ_e
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;
}
示例3: rb_gsl_sf_lngamma_complex_e
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));
}
示例4: rb_gsl_sf_complex_XXX_e
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);
}
示例5: rb_gsl_sf_coulomb_wave_FGp_array
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));
}
示例6: rb_gsl_fit_mul_est
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));
}
示例7: rb_gsl_hypot3
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)));
}
示例8: rb_gsl_odeiv_control_yp_new
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);
}
示例9: rb_gsl_root_test_delta
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)));
}
示例10: rb_gsl_fsolver_test_interval
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)));
}
示例11: rb_gsl_fminimizer_test_interval
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)));
}
示例12: rb_gsl_sf_gegenpoly_array
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);
}
示例13: make_control_standard
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));
}
示例14: rb_gsl_sf_elljac_e
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));
}
示例15: rb_gsl_sf_multiply_e
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;
}