Example #1
0
func Qags(ff gsl.F, ab gsl.Interval, eps gsl.Eps, w *WorkSpace) (gsl.Result, error) {
	// Make a gsl_function
	var gf C.gsl_function
	data := gsl.GSLFuncWrapper{ff}
	gf = C.mkintegCB(unsafe.Pointer(&data))

	// Check to see if we have a positive/-negative infinity
	pinf := math.IsInf(ab.Hi, 1)
	ninf := math.IsInf(ab.Lo, -1)

	var ret C.int
	var y, err C.double
	// Switch on options
	switch {
	case pinf && ninf:
		ret = C.gsl_integration_qagi(&gf, C.double(eps.Abs), C.double(eps.Rel), C.size_t(w.n), w.w, &y, &err)
	case pinf:
		ret = C.gsl_integration_qagiu(&gf, C.double(ab.Lo), C.double(eps.Abs), C.double(eps.Rel), C.size_t(w.n), w.w, &y, &err)
	case ninf:
		ret = C.gsl_integration_qagil(&gf, C.double(ab.Hi), C.double(eps.Abs), C.double(eps.Rel), C.size_t(w.n), w.w, &y, &err)
	default:
		ret = C.gsl_integration_qags(&gf, C.double(ab.Lo), C.double(ab.Hi), C.double(eps.Abs), C.double(eps.Rel), C.size_t(w.n), w.w, &y, &err)
	}
	if ret != 0 {
		return gsl.Result{float64(y), float64(err)}, gsl.Errno(ret)
	}
	return gsl.Result{float64(y), float64(err)}, nil

}
Example #2
0
func Qagil(f *gogsl.GslFunction, b float64, epsabs float64, epsrel float64, limit int, workspace *GslIntegrationWorkspace) (int32, float64, float64) {
	var _outptr_6 C.double
	var _outptr_7 C.double
	gogsl.InitializeGslFunction(f)
	_result := int32(C.gsl_integration_qagil((*C.gsl_function)(unsafe.Pointer(f.CPtr())), C.double(b), C.double(epsabs), C.double(epsrel), C.size_t(limit), (*C.gsl_integration_workspace)(unsafe.Pointer(workspace.Ptr())), &_outptr_6, &_outptr_7))
	return _result, *(*float64)(unsafe.Pointer(&_outptr_6)), *(*float64)(unsafe.Pointer(&_outptr_7))
}