Beispiel #1
0
func Linear(x []float64, xstride int, y []float64, ystride int, n int) (int32, float64, float64, float64, float64, float64, float64) {
	var _outptr_5 C.double
	var _outptr_6 C.double
	var _outptr_7 C.double
	var _outptr_8 C.double
	var _outptr_9 C.double
	var _outptr_10 C.double
	_slice_header_0 := (*reflect.SliceHeader)(unsafe.Pointer(&x))
	_slice_header_2 := (*reflect.SliceHeader)(unsafe.Pointer(&y))
	_result := int32(C.gsl_fit_linear((*C.double)(unsafe.Pointer(_slice_header_0.Data)), C.size_t(xstride), (*C.double)(unsafe.Pointer(_slice_header_2.Data)), C.size_t(ystride), C.size_t(n), &_outptr_5, &_outptr_6, &_outptr_7, &_outptr_8, &_outptr_9, &_outptr_10))
	return _result, *(*float64)(unsafe.Pointer(&_outptr_5)), *(*float64)(unsafe.Pointer(&_outptr_6)), *(*float64)(unsafe.Pointer(&_outptr_7)), *(*float64)(unsafe.Pointer(&_outptr_8)), *(*float64)(unsafe.Pointer(&_outptr_9)), *(*float64)(unsafe.Pointer(&_outptr_10))
}
Beispiel #2
0
/* FitLinear wraps gsl_fit_linear from gsl_fit.h.
 * All of the parameters mentioned below are returned from the function
 * in a *LinearFit.
 * From the GSL manual:
 * This function computes the best-fit linear regression coefficients
 * (Y0,Slope) of the model Y = Y0 + Slope*X for the dataset (x, y), two
 * vectors
 * of identical length n with strides xstride and ystride. The errors
 * on y are assumed unknown so the variance-covariance matrix for the
 * parameters (Y0, Slope) is estimated from the scatter of the points
 * around the best-fit line and returned via the parameters
 * (Cov00, Cov01, Cov11).
 * The sum of squares of the residuals from the best-fit line is returned
 * in Sumsq.
 */
func FitLinear(x, y *[]float64, stridex, stridey uint) (f *LinearFit, e error) {
	f = &LinearFit{}
	xptr := (*C.double)(unsafe.Pointer(&(*x)[0]))
	yptr := (*C.double)(unsafe.Pointer(&(*y)[0]))
	er := C.gsl_fit_linear(
		xptr,
		(C.size_t)(stridex),
		yptr,
		(C.size_t)(stridey),
		(C.size_t)(len(*x)),
		(*C.double)(&f.Y0),
		(*C.double)(&f.Slope),
		(*C.double)(&f.Cov00),
		(*C.double)(&f.Cov01),
		(*C.double)(&f.Cov11),
		(*C.double)(&f.SumSq))
	if er == (C.int)(0) {
		e = nil
	} else {
		e = gsl.NewGSLError(int(er))
	}
	return
}