Exemplo n.º 1
0
func TestNumint(t *testing.T) {
	gogsl.SetErrorHandler(&gogsl.GslErrorHandler{
		Handler: func(reason string, file string, line int, gslError gogsl.GslError) {
			fmt.Println(reason + " : " + gslError.String())
		},
	})
	expected := -4.0
	alpha := 1.0
	F := gogsl.GslFunction{Function: F, Params: alpha}
	status, result, err := numint.Qags(&F, 0, 1, 0, 0.0001, 1000, w)
	fmt.Printf("status          =  %s\n", gogsl.GslError(status).String())
	fmt.Printf("result          = % .18f\n", result)
	fmt.Printf("exact result    = % .18f\n", expected)
	fmt.Printf("estimated error = % .18f\n", err)
	fmt.Printf("actual error    = % .18f\n", result-expected)
	fmt.Printf("intervals =  %d\n", w.IntervalCount())
}
Exemplo n.º 2
0
func TestVector(t *testing.T) {
	var stopDoingIt bool
	gogsl.SetErrorHandler(&gogsl.GslErrorHandler{
		Handler: func(reason string, file string, line int, gslError gogsl.GslError) {
			fmt.Println("Caught error: " + reason)
			stopDoingIt = true
		},
	})
	v := vector.VectorAlloc(3)
	for i := 0; i < 3; i++ {
		vector.Set(v, i, float64(1.23)+float64(i))
	}
	for i := 0; i < 100; i++ { // OUT OF RANGE ERROR
		fmt.Printf("v_%d = %g\n", i, vector.Get(v, i))
		if stopDoingIt {
			break
		}
	}
}