int gsl_spline_eval_e (const gsl_spline * spline, double x, gsl_interp_accel * a, double *y) { return gsl_interp_eval_e (spline->interp, spline->x, spline->y, x, a, y); }
double z( const double &t ) const { if (t > params.n_cycl * data[0](data[0].size()-1)) return 0.; double z; auto status = gsl_interp_eval_e( intp, data[0].data(), data[1].data(), fmod(t, data[0](data[0].size()-1)), accl, &z ); assert(status == GSL_SUCCESS); return z; }
static int test_interp ( const xy_table * data_table, const gsl_interp_type * T, xy_table * test_table, xy_table * test_d_table, xy_table * test_i_table ) { int status = 0; size_t i; gsl_interp_accel *a = gsl_interp_accel_alloc (); gsl_interp *interp = gsl_interp_alloc (T, data_table->n); gsl_interp_init (interp, data_table->x, data_table->y, data_table->n); for (i = 0; i < test_table->n; i++) { double x = test_table->x[i]; double y; double deriv; double integ; double diff_y, diff_deriv, diff_integ; gsl_interp_eval_e (interp, data_table->x, data_table->y, x, a, &y); gsl_interp_eval_deriv_e (interp, data_table->x, data_table->y, x, a, &deriv); gsl_interp_eval_integ_e (interp, data_table->x, data_table->y, 0.0, x, a, &integ); diff_y = y - test_table->y[i]; diff_deriv = deriv - test_d_table->y[i]; diff_integ = integ - test_i_table->y[i]; if (fabs (diff_y) > 1.e-10 || fabs(diff_deriv) > 1.0e-10 || fabs(diff_integ) > 1.0e-10) { status++; } } gsl_interp_accel_free (a); gsl_interp_free (interp); return status; }
static VALUE rb_gsl_interp_eval_e(VALUE obj, VALUE xxa, VALUE yya, VALUE xx) { rb_gsl_interp *rgi = NULL; double *ptr1 = NULL, *ptr2 = NULL; size_t size, stridex, stridey; double x, y; int status; Need_Float(xx); Data_Get_Struct(obj, rb_gsl_interp, rgi); ptr1 = get_vector_ptr(xxa, &stridex, &size); ptr2 = get_vector_ptr(yya, &stridey, &size); x = NUM2DBL(xx); status = gsl_interp_eval_e(rgi->p, ptr1, ptr2, x, rgi->a, &y); switch (status) { case GSL_EDOM: rb_gsl_error_handler("gsl_interp_eval_e error", __FILE__, __LINE__, status); break; default: return rb_float_new(y); break; } return Qnil; }