예제 #1
0
파일: integ.go 프로젝트: npadmana/npgo
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

}
예제 #2
0
파일: numint.go 프로젝트: postfix/gsl-1
func Qags(f *gogsl.GslFunction, a float64, b float64, epsabs float64, epsrel float64, limit int, workspace *GslIntegrationWorkspace) (int32, float64, float64) {
	var _outptr_7 C.double
	var _outptr_8 C.double
	gogsl.InitializeGslFunction(f)
	_result := int32(C.gsl_integration_qags((*C.gsl_function)(unsafe.Pointer(f.CPtr())), C.double(a), C.double(b), C.double(epsabs), C.double(epsrel), C.size_t(limit), (*C.gsl_integration_workspace)(unsafe.Pointer(workspace.Ptr())), &_outptr_7, &_outptr_8))
	return _result, *(*float64)(unsafe.Pointer(&_outptr_7)), *(*float64)(unsafe.Pointer(&_outptr_8))
}