// 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 }
func SplineInit(spline *GslSpline, xa []float64, ya []float64, size int) int32 { _slice_header_1 := (*reflect.SliceHeader)(unsafe.Pointer(&xa)) _slice_header_2 := (*reflect.SliceHeader)(unsafe.Pointer(&ya)) return int32(C.gsl_spline_init((*C.gsl_spline)(unsafe.Pointer(spline.Ptr())), (*C.double)(unsafe.Pointer(_slice_header_1.Data)), (*C.double)(unsafe.Pointer(_slice_header_2.Data)), C.size_t(size))) }