Class: Numo::GSL::Spline

Inherits:
Object
  • Object
show all
Defined in:
ext/numo/gsl/interp/gsl_interp.c

Defined Under Namespace

Classes: Akima, AkimaPeriodic, Cspline, CsplinePeriodic, Linear, Polynomial, Steffen

Instance Method Summary collapse

Instance Method Details

#eval(x) ⇒ DFloat

These functions return the interpolated value of y for a given point x, using the interpolation object interp, data arrays xa and ya and the accelerator acc. When x is outside the range of xa, the error code GSL_EDOM is returned with a value of GSL_NAN for y.

Parameters:

  • x (DFloat)

Returns:

  • (DFloat)

    result



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'ext/numo/gsl/interp/gsl_interp.c', line 445

static VALUE
spline_eval(VALUE self, VALUE v1)
{
    ndfunc_arg_in_t ain[1] = {{cDF,0}};
    ndfunc_arg_out_t aout[1] = {{cDF,0}};
    ndfunc_t ndf = {iter_spline_eval, STRIDE_LOOP|NDF_EXTRACT, 1,1, ain,aout};
    gsl_spline *w;
    gsl_interp_accel *a;
    void *opts[2];
    VALUE vac, v;

    TypedData_Get_Struct(self, gsl_spline, &spline_data_type, w);
    opts[0] = w;

    vac = interp_accel_s_new(cInterpAccel);
    TypedData_Get_Struct(vac, gsl_interp_accel, &interp_accel_data_type, a);
    opts[1] = a;

    v = na_ndloop3(&ndf, opts, 1, v1);
    RB_GC_GUARD(vac);
    return v;
}

#eval_deriv(x) ⇒ DFloat

These functions return the derivative d of an interpolated function for a given point x, using the interpolation object interp, data arrays xa and ya and the accelerator acc.

Parameters:

  • x (DFloat)

Returns:

  • (DFloat)

    result



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'ext/numo/gsl/interp/gsl_interp.c', line 506

static VALUE
spline_eval_deriv(VALUE self, VALUE v1)
{
    ndfunc_arg_in_t ain[1] = {{cDF,0}};
    ndfunc_arg_out_t aout[1] = {{cDF,0}};
    ndfunc_t ndf = {iter_spline_eval_deriv, STRIDE_LOOP|NDF_EXTRACT, 1,1, ain,aout};
    gsl_spline *w;
    gsl_interp_accel *a;
    void *opts[2];
    VALUE vac, v;

    TypedData_Get_Struct(self, gsl_spline, &spline_data_type, w);
    opts[0] = w;

    vac = interp_accel_s_new(cInterpAccel);
    TypedData_Get_Struct(vac, gsl_interp_accel, &interp_accel_data_type, a);
    opts[1] = a;

    v = na_ndloop3(&ndf, opts, 1, v1);
    RB_GC_GUARD(vac);
    return v;
}

#eval_deriv2(x) ⇒ DFloat

These functions return the second derivative d2 of an interpolated function for a given point x, using the interpolation object interp, data arrays xa and ya and the accelerator acc.

Parameters:

  • x (DFloat)

Returns:

  • (DFloat)

    result



567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'ext/numo/gsl/interp/gsl_interp.c', line 567

static VALUE
spline_eval_deriv2(VALUE self, VALUE v1)
{
    ndfunc_arg_in_t ain[1] = {{cDF,0}};
    ndfunc_arg_out_t aout[1] = {{cDF,0}};
    ndfunc_t ndf = {iter_spline_eval_deriv2, STRIDE_LOOP|NDF_EXTRACT, 1,1, ain,aout};
    gsl_spline *w;
    gsl_interp_accel *a;
    void *opts[2];
    VALUE vac, v;

    TypedData_Get_Struct(self, gsl_spline, &spline_data_type, w);
    opts[0] = w;

    vac = interp_accel_s_new(cInterpAccel);
    TypedData_Get_Struct(vac, gsl_interp_accel, &interp_accel_data_type, a);
    opts[1] = a;

    v = na_ndloop3(&ndf, opts, 1, v1);
    RB_GC_GUARD(vac);
    return v;
}

#eval_integ(a, b) ⇒ DFloat

These functions return the numerical integral result of an interpolated function over the range [a, b], using the interpolation object interp, data arrays xa and ya and the accelerator acc.

Parameters:

  • a (DFloat)
  • b (DFloat)

Returns:

  • (DFloat)

    result



631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'ext/numo/gsl/interp/gsl_interp.c', line 631

static VALUE
spline_eval_integ(VALUE self, VALUE v1, VALUE v2)
{
    ndfunc_arg_in_t ain[2] = {{cDF,0},{cDF,0}};
    ndfunc_arg_out_t aout[1] = {{cDF,0}};
    ndfunc_t ndf = {iter_spline_eval_integ, STRIDE_LOOP|NDF_EXTRACT, 2,1, ain,aout};
    gsl_spline *w;
    gsl_interp_accel *a;
    void *opts[2];
    VALUE vac, v;

    TypedData_Get_Struct(self, gsl_spline, &spline_data_type, w);
    opts[0] = w;
    vac = interp_accel_s_new(cInterpAccel);
    TypedData_Get_Struct(vac, gsl_interp_accel, &interp_accel_data_type, a);
    opts[1] = a;
    v = na_ndloop3(&ndf, opts, 2, v1, v2);
    RB_GC_GUARD(vac);
    return v;
}

#min_sizeInteger

These functions return the minimum number of points required by the interpolation object interp or interpolation type T. For example, Akima spline interpolation requires a minimum of 5 points.

Returns:

  • (Integer)


395
396
397
398
399
400
401
402
403
# File 'ext/numo/gsl/interp/gsl_interp.c', line 395

static VALUE
spline_min_size(VALUE self)
{
    gsl_spline *w;

    TypedData_Get_Struct(self, gsl_spline, &spline_data_type, w);

    return UINT2NUM(gsl_spline_min_size(w));
}

#nameString

This function returns the name of the interpolation type used by interp. For example,

printf (“interp uses ‘%s’ interpolation.\n”, gsl_interp_name (interp));

would print something like,

interp uses ‘cspline’ interpolation.

Returns:

  • (String)


375
376
377
378
379
380
381
382
383
# File 'ext/numo/gsl/interp/gsl_interp.c', line 375

static VALUE
spline_name(VALUE self)
{
    gsl_spline *w;

    TypedData_Get_Struct(self, gsl_spline, &spline_data_type, w);

    return rb_str_new_cstr(gsl_spline_name(w));
}