Example #1
0
// NewSpline creates a new Spline struct
func New(s SplineType, xa, ya []float64) (*Spline, error) {

	// Check inputs
	nx := len(xa)
	ny := len(ya)
	if nx != ny {
		return nil, fmt.Errorf("Incompatible dimensions in NewSpline: x(%d) != y(%d)", nx, ny)
	}

	// Convert type of spline
	sptype, err := convertSplineType(s)
	if err != nil {
		return nil, err
	}

	// Create a new object
	sp := new(Spline)
	sp.sp = C.gsl_spline_alloc(sptype, C.size_t(nx))
	sp.acc = C.gsl_interp_accel_alloc()

	// Initialize the spline object
	ret := C.gsl_spline_init(sp.sp, (*C.double)(&xa[0]), (*C.double)(&ya[0]), C.size_t(nx))
	if ret != 0 {
		return nil, gsl.Errno(ret)
	}

	return sp, nil
}
Example #2
0
func AccelAlloc() *GslInterpAccel {
	_ref := C.gsl_interp_accel_alloc()
	_result := &GslInterpAccel{}
	gogsl.InitializeGslReference(_result, uintptr(unsafe.Pointer(_ref)))
	return _result
}