示例#1
0
func TestMean(t *testing.T) {
	var mean float64
	var correct bool
	// test float
	mean = Mean(igroupa.group, igroupa.stride, igroupa.n)
	correct = assert.EqualFloat(mean, igroupa.mean, delta64)
	if !correct {
		t.Errorf("Int mean: %f, expected: %f\n", mean, igroupa.mean)
	}
	// test int
	mean = Mean(fgroupa.group, fgroupa.stride, fgroupa.n)
	correct = assert.EqualFloat(mean, fgroupa.mean, delta64)
	if !correct {
		t.Errorf("Float mean: %f, expected: %f\n", mean, fgroupa.mean)
	}
	// test string
	data := []string{"1", "2", "3", "4"}
	stride := 1
	n := len(data)
	mean = Mean(data, stride, n)
	correct = assert.EqualFloat(mean, 2.5, delta64)
	if !correct {
		t.Errorf("String mean: %f, expected: %f\n", mean, 2.5)
	}
}
示例#2
0
func testQK(f Function, exp_result, exp_abserr, exp_resabs, exp_resasc float, qk QKFunction, a, b float64, prefix string, t *testing.T) {
	var result, abserr, resabs, resasc float64
	result, abserr, resabs, resasc = qk(f, a, b)
	if !assert.EqualFloat(result, exp_result.value, exp_result.precision) {
		t.Errorf("%s: result: %.15f, expected: %.15f\n", prefix, result, exp_result.value)
	}
	if !assert.EqualFloat(abserr, exp_abserr.value, exp_abserr.precision) {
		t.Errorf("%s: abserr: %.7f, expected: %.7f\n", prefix, abserr, exp_abserr.value)
	}
	if !assert.EqualFloat(resabs, exp_resabs.value, exp_resabs.precision) {
		t.Errorf("%s: resabs: %.15f, expected: %.15f\n", prefix, resabs, exp_resabs.value)
	}
	if !assert.EqualFloat(resasc, exp_resasc.value, exp_resasc.precision) {
		t.Errorf("%s: result: %.15f, resasc: %.15f\n", prefix, resasc, exp_resasc.value)
	}

	result, abserr, resabs, resasc = qk(f, b, a)
	if !assert.EqualFloat(result, -exp_result.value, exp_result.precision) {
		t.Errorf("%s: result: %.15f, expected: %.15f\n", prefix, result, -exp_result.value)
	}
	if !assert.EqualFloat(abserr, exp_abserr.value, exp_abserr.precision) {
		t.Errorf("%s: abserr: %.7f, expected: %.7f\n", prefix, abserr, exp_abserr.value)
	}
	if !assert.EqualFloat(resabs, exp_resabs.value, exp_resabs.precision) {
		t.Errorf("%s: resabs: %.15f, expected: %.15f\n", prefix, resabs, exp_resabs.value)
	}
	if !assert.EqualFloat(resasc, exp_resasc.value, exp_resasc.precision) {
		t.Errorf("%s: result: %.15f, resasc: %.15f\n", prefix, resasc, exp_resasc.value)
	}
}
示例#3
0
func TestMedianFromSortedData(t *testing.T) {
	var median, expected float64
	var correct bool
	// test float
	sorted_floats := make([]float64, len(fgroupa.raw))
	copy(sorted_floats, fgroupa.raw)
	sort.Float64s(sorted_floats)
	fgroup := make([]float64, len(sorted_floats)*fgroupa.stride)
	for i, item := range sorted_floats {
		fgroup[i*fgroupa.stride] = item
	}
	// n
	median = MedianFromSortedData(fgroup, fgroupa.stride, fgroupa.n)
	expected = 0.07505
	correct = assert.EqualFloat(median, expected, delta64)
	if !correct {
		t.Errorf("median: %f, expected %f\n", median, expected)
	}
	// n - 1
	median = MedianFromSortedData(fgroup, fgroupa.stride, fgroupa.n-1)
	expected = 0.0728
	correct = assert.EqualFloat(median, expected, delta64)
	if !correct {
		t.Errorf("median: %f, expected %f\n", median, expected)
	}

	// test int
	sorted_ints := make([]int, len(igroupa.raw))
	copy(sorted_ints, igroupa.raw)
	sort.Ints(sorted_ints)
	igroup := make([]int, len(sorted_ints)*igroupa.stride)
	for i, item := range sorted_ints {
		igroup[i*igroupa.stride] = item
	}
	// n
	median = MedianFromSortedData(igroup, igroupa.stride, igroupa.n)
	expected = 18
	correct = assert.EqualFloat(median, expected, delta64)
	if !correct {
		t.Errorf("median: %f, expected %f\n", median, expected)
	}
	// n - 1
	median = MedianFromSortedData(igroup, igroupa.stride, igroupa.n-1)
	expected = 18
	correct = assert.EqualFloat(median, expected, delta64)
	if !correct {
		t.Errorf("median: %f, expected %f\n", median, expected)
	}
}
示例#4
0
func TestAbsdev(t *testing.T) {
	var absdev float64
	var correct bool
	// test float
	absdev = Absdev(fgroupa.group, fgroupa.stride, fgroupa.n)
	correct = assert.EqualFloat(absdev, fgroupa.absdev, delta64)
	if !correct {
		t.Errorf("absdev: %f, expected: %f\n", absdev, fgroupa.absdev)
	}
	// test int
	absdev = Absdev(igroupa.group, igroupa.stride, igroupa.n)
	correct = assert.EqualFloat(absdev, igroupa.absdev, delta64)
	if !correct {
		t.Errorf("absdev: %f, expected: %f\n", absdev, igroupa.absdev)
	}
}
示例#5
0
func TestSd(t *testing.T) {
	var sd float64
	var correct bool
	// test float
	sd = Sd(fgroupa.group, fgroupa.stride, fgroupa.n)
	correct = assert.EqualFloat(sd, fgroupa.sd, delta64)
	if !correct {
		t.Errorf("sd: %f, expected: %f\n", sd, fgroupa.sd)
	}
	// test int
	sd = Sd(igroupa.group, igroupa.stride, igroupa.n)
	correct = assert.EqualFloat(sd, igroupa.sd, delta64)
	if !correct {
		t.Errorf("sd: %f, expected: %f\n", sd, igroupa.sd)
	}
}
示例#6
0
func TestVariance(t *testing.T) {
	var variance float64
	var correct bool
	// test float
	variance = Variance(fgroupb.group, fgroupb.stride, fgroupb.n)
	correct = assert.EqualFloat(variance, fgroupb.variance, delta64)
	if !correct {
		t.Errorf("variance: %f, expected: %f\n", variance, fgroupb.variance)
	}
	// test int
	variance = Variance(igroupa.group, igroupa.stride, igroupa.n)
	correct = assert.EqualFloat(variance, igroupa.variance, delta64)
	if !correct {
		t.Errorf("variance: %f, expected: %f\n", variance, igroupa.variance)
	}
}
示例#7
0
func TestMeanInts(t *testing.T) {
	mean := MeanInts(igroupa.group, igroupa.stride, igroupa.n)
	correct := assert.EqualFloat(mean, igroupa.mean, delta64)
	if !correct {
		t.Errorf("mean: %f, expected: %f\n", mean, igroupa.mean)
	}
}
示例#8
0
func TestTssM(t *testing.T) {
	mean := MeanFloats(fgroupa.group, fgroupa.stride, fgroupa.n)
	tss := TssM(fgroupa.group, fgroupa.stride, fgroupa.n, mean)
	correct := assert.EqualFloat(tss, fgroupa.tss_m, delta64)
	if !correct {
		t.Errorf("tss_m: %f, expected: %f\n", tss, fgroupa.tss_m)
	}
}
示例#9
0
func TestSdWithFixedMean(t *testing.T) {
	var mean, sd float64
	var correct bool
	// test float
	mean = Mean(fgroupa.group, fgroupa.stride, fgroupa.n)
	sd = SdWithFixedMean(fgroupa.group, fgroupa.stride, fgroupa.n, mean)
	correct = assert.EqualFloat(sd, fgroupa.sd_with_fixed_mean, delta64)
	if !correct {
		t.Errorf("sd_with_fixed_mean: %f, but expected: %f\n", sd, fgroupa.sd_with_fixed_mean)
	}
	// test int
	mean = Mean(igroupa.group, igroupa.stride, igroupa.n)
	sd = SdWithFixedMean(igroupa.group, igroupa.stride, igroupa.n, mean)
	correct = assert.EqualFloat(sd, igroupa.sd_with_fixed_mean, delta64)
	if !correct {
		t.Errorf("sd_with_fixed_mean: %f, but expected: %f\n", sd, igroupa.sd_with_fixed_mean)
	}
}
示例#10
0
func TestVarianceWithFixedMean(t *testing.T) {
	var mean, variance float64
	var correct bool
	// test float
	mean = Mean(fgroupa.group, fgroupa.stride, fgroupa.n)
	variance = VarianceWithFixedMean(fgroupa.group, fgroupa.stride, fgroupa.n, mean)
	correct = assert.EqualFloat(variance, fgroupa.variance_with_fixed_mean, delta64)
	if !correct {
		t.Errorf("variance: %f, expected: %f\n", variance, fgroupa.variance)
	}
	// test int
	mean = Mean(igroupa.group, igroupa.stride, igroupa.n)
	variance = VarianceWithFixedMean(igroupa.group, igroupa.stride, igroupa.n, mean)
	correct = assert.EqualFloat(variance, igroupa.variance_with_fixed_mean, delta64)
	if !correct {
		t.Errorf("variance_with_fixed_mean: %f, expected %f\n", variance, igroupa.variance_with_fixed_mean)
	}
}
示例#11
0
func TestCorrelation(t *testing.T) {
	var correlation, expected float64
	var correct bool
	// test float
	correlation = Correlation(fgroupa.group, fgroupa.stride, fgroupb.group, fgroupb.stride, fgroupb.n)
	expected = -0.112322712666074171
	correct = assert.EqualFloat(correlation, expected, delta64)
	if !correct {
		t.Errorf("correlation: %f, expected: %f\n", correlation, expected)
	}

	// test int
	correlation = Correlation(igroupa.group, igroupa.stride, igroupb.group, igroupb.stride, igroupb.n)
	expected = 0.793090350710101
	correct = assert.EqualFloat(correlation, expected, delta64)
	if !correct {
		t.Errorf("correlation: %f, expected: %f\n", correlation, expected)
	}
}
示例#12
0
func TestCovariance(t *testing.T) {
	var covariance, expected float64
	var correct bool
	// test float
	covariance = Covariance(fgroupa.group, fgroupa.stride, fgroupb.group, fgroupb.stride, fgroupb.n)
	expected = -0.000139021538461539
	correct = assert.EqualFloat(covariance, expected, delta64)
	if !correct {
		t.Errorf("covariance: %f, expected: %f\n", covariance, expected)
	}

	// test int
	covariance = Covariance(igroupa.group, igroupa.stride, igroupb.group, igroupb.stride, igroupb.n)
	expected = 14.5263157894737
	correct = assert.EqualFloat(covariance, expected, delta64)
	if !correct {
		t.Errorf("covariance: %f, expected: %f\n", covariance, expected)
	}
}
示例#13
0
func TestTss(t *testing.T) {
	var tss float64
	var correct bool
	// test float
	tss = Tss(fgroupb.group, fgroupb.stride, fgroupb.n)
	correct = assert.EqualFloat(tss, fgroupb.tss, delta64)
	if !correct {
		t.Errorf("tss: %f, expected: %f\n", tss, fgroupb.tss)
	}
}
示例#14
0
func TestQag(t *testing.T) {
	{
		w, _ := NewWorkspace(1000)
		exp_result := 7.716049382715854665E-02
		exp_abserr := 6.679384885865053037E-12
		exp_last := 6

		a := []float64{0, 0.5, 0.25, 0.125, 0.0625, 0.03125}
		b := []float64{0.03125, 1, 0.5, 0.25, 0.125, 0.0625}
		r := []float64{3.966769831709074375E-06, 5.491842501998222409E-02,
			1.909827770934243926E-02, 2.776531175604360531E-03,
			3.280661030752063693E-04, 3.522704932261797744E-05}
		e := []float64{6.678528276336181873E-12, 6.097169993333454062E-16,
			2.120334764359736934E-16, 3.082568839745514608E-17,
			3.642265412331439511E-18, 3.910988124757650942E-19}
		order := []int{1, 2, 3, 4, 5, 6}

		alpha := 2.6
		f := f1{alpha: alpha}
		result, abserr, err := Qag(f, 0.0, 1.0, 0.0, 1e-10, w.limit, w, Qk15)
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Smooth: result %.10f, expected %.10f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Smooth: abserr %f, expected %f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Smooth: last %d, expected %d\n", w.size, exp_last)
		}
		if err != nil {
			t.Errorf("Smooth: do not expected error %v\n", err)
		}

		for i := 0; i < 6; i++ {
			if !assert.EqualFloat(w.alist[i], a[i], 1e-15) {
				t.Errorf("Smooth: a[%d] %f, expected %f\n", i, w.alist[i], a[i])
			}
			if !assert.EqualFloat(w.blist[i], b[i], 1e-15) {
				t.Errorf("Smooth: b[%d] %f, expected %f\n", i, w.blist[i], b[i])
			}
			if !assert.EqualFloat(w.rlist[i], r[i], 1e-15) {
				t.Errorf("Smooth: r[%d] %f, expected %f\n", i, w.rlist[i], r[i])
			}
			if !assert.EqualFloat(w.elist[i], e[i], 1e-15) {
				t.Errorf("Smooth: e[%d] %f, expected %f\n", i, w.elist[i], e[i])
			}
			if !assert.EqualInt(w.order[i], order[i]-1) {
				t.Errorf("Smooth: order[%d] %d, expected %d\n", i, w.order[i], order[i]-1)
			}
		}

		result, abserr, err = Qag(f, 1.0, 0.0, 0.0, 1e-10, w.limit, w, Qk15)
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Smooth: result %.10f, expected %.10f\n", result, -exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Smooth: abserr %f, expected %f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Smooth: last %d, expected %d\n", w.size, exp_last)
		}
		if err != nil {
			t.Errorf("Smooth: do not expected error %v\n", err)
		}
	}

	/* Test the same function using an absolute error bound and the
	   21-point rule */

	{
		w, _ := NewWorkspace(1000)
		exp_result := 7.716049382716050342E-02
		exp_abserr := 2.227969521869139532E-15
		exp_last := 8

		a := []float64{0, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625, 0.0078125}
		b := []float64{0.0078125, 1, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.015625}
		r := []float64{3.696942726831556522E-08, 5.491842501998223103E-02,
			1.909827770934243579E-02, 2.776531175604360097E-03,
			3.280661030752062609E-04, 3.522704932261797744E-05,
			3.579060884684503576E-06, 3.507395216921808047E-07}
		e := []float64{1.371316364034059572E-15, 6.097169993333454062E-16,
			2.120334764359736441E-16, 3.082568839745514608E-17,
			3.642265412331439511E-18, 3.910988124757650460E-19,
			3.973555800712018091E-20, 3.893990926286736620E-21}
		order := []int{1, 2, 3, 4, 5, 6, 7, 8}

		alpha := 2.6
		f := f1{alpha: alpha}
		result, abserr, err := Qag(f, 0.0, 1.0, 1e-14, 0.0, w.limit, w, Qk21)
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Smooth: result %.10f, expected %.10f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Smooth: abserr %f, expected %f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Smooth: last %d, expected %d\n", w.size, exp_last)
		}
		if err != nil {
			t.Errorf("Smooth: do not expected error %v\n", err)
		}

		for i := 0; i < 6; i++ {
			if !assert.EqualFloat(w.alist[i], a[i], 1e-15) {
				t.Errorf("Smooth: a[%d] %f, expected %f\n", i, w.alist[i], a[i])
			}
			if !assert.EqualFloat(w.blist[i], b[i], 1e-15) {
				t.Errorf("Smooth: b[%d] %f, expected %f\n", i, w.blist[i], b[i])
			}
			if !assert.EqualFloat(w.rlist[i], r[i], 1e-15) {
				t.Errorf("Smooth: r[%d] %f, expected %f\n", i, w.rlist[i], r[i])
			}
			if !assert.EqualFloat(w.elist[i], e[i], 1e-6) {
				t.Errorf("Smooth: e[%d] %f, expected %f\n", i, w.elist[i], e[i])
			}
			if !assert.EqualInt(w.order[i], order[i]-1) {
				t.Errorf("Smooth: order[%d] %d, expected %d\n", i, w.order[i], order[i]-1)
			}
		}

		result, abserr, err = Qag(f, 1.0, 0.0, 1e-14, 0.0, w.limit, w, Qk21)
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Smooth: result %.10f, expected %.10f\n", result, -exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Smooth: abserr %.20f, expected %.20f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Smooth: last %d, expected %d\n", w.size, exp_last)
		}
		if err != nil {
			t.Errorf("Smooth: do not expected error %v\n", err)
		}
	}

	/* Adaptive integration of an oscillatory function which terminates because
	   of roundoff error, uses the 31-pt rule */
	{
		w, _ := NewWorkspace(1000)
		exp_result := -7.238969575482959717E-01
		exp_abserr := 1.285805464427459261E-14
		exp_last := 1

		alpha := 1.3
		f := f3{alpha: alpha}
		result, abserr, err := Qag(f, 0.3, 2.71, 1e-14, 0.0, w.limit, w, Qk31)
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Oscill: result %.10f, expected %.10f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Oscill: abserr %f, expected %f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Oscill: last %d, expected %d\n", w.size, exp_last)
		}
		if err == nil {
			t.Errorf("Oscill: expected error.\n")
		}

		result, abserr, err = Qag(f, 2.71, 0.3, 1e-14, 0.0, w.limit, w, Qk31)
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Oscill: result %.10f, expected %.10f\n", result, -exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Oscill: abserr %.20f, expected %.20f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Oscill: last %d, expected %d\n", w.size, exp_last)
		}
		if err == nil {
			t.Errorf("Oscill: expected error.\n")
		}
	}

	/* Check the singularity detection (singularity at x=-0.1 in this example) */
	{
		w, _ := NewWorkspace(1000)
		exp_last := 51

		alpha := 2.0
		f := f16{alpha: alpha}
		_, _, err := Qag(f, -1.0, 1.0, 1e-14, 0.0, w.limit, w, Qk51)

		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Oscill: last %d, expected %d\n", w.size, exp_last)
		}
		if err == nil {
			t.Errorf("Oscill: expected error.\n")
		}

		_, _, err = Qag(f, 1.0, -1.0, 1e-14, 0.0, w.limit, w, Qk51)

		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Oscill: last %d, expected %d\n", w.size, exp_last)
		}
		if err == nil {
			t.Errorf("Oscill: expected error.\n")
		}
	}
	/* Check for hitting the iteration limit */
	{
		w, _ := NewWorkspace(3)
		exp_result := 9.565151449233894709
		exp_abserr := 1.570369823891028460E+01
		exp_last := 3

		a := []float64{-5.000000000000000000E-01,
			0.000000000000000000,
			-1.000000000000000000}
		b := []float64{0.000000000000000000,
			1.000000000000000000,
			-5.000000000000000000E-01}
		r := []float64{9.460353469435913709,
			9.090909090909091161E-02,
			1.388888888888888812E-02}
		e := []float64{1.570369823891028460E+01,
			1.009293658750142399E-15,
			1.541976423090495140E-16}
		order := []int{1, 2, 3}

		alpha := 1.0
		f := f16{alpha: alpha}
		result, abserr, err := Qag(f, -1.0, 1.0, 1e-14, 0.0, w.limit, w, Qk61)
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Limit: result %.10f, expected %.10f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Limit: abserr %f, expected %f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Limit: last %d, expected %d\n", w.size, exp_last)
		}
		if err == nil {
			t.Errorf("Limit: expect error\n")
		}

		for i := 0; i < 3; i++ {
			if !assert.EqualFloat(w.alist[i], a[i], 1e-15) {
				t.Errorf("Limit: a[%d] %f, expected %f\n", i, w.alist[i], a[i])
			}
			if !assert.EqualFloat(w.blist[i], b[i], 1e-15) {
				t.Errorf("Limit: b[%d] %f, expected %f\n", i, w.blist[i], b[i])
			}
			if !assert.EqualFloat(w.rlist[i], r[i], 1e-15) {
				t.Errorf("Limit: r[%d] %f, expected %f\n", i, w.rlist[i], r[i])
			}
			if !assert.EqualFloat(w.elist[i], e[i], 1e-6) {
				t.Errorf("Limit: e[%d] %f, expected %f\n", i, w.elist[i], e[i])
			}
			if !assert.EqualInt(w.order[i], order[i]-1) {
				t.Errorf("Limit: order[%d] %d, expected %d\n", i, w.order[i], order[i]-1)
			}
		}

		result, abserr, err = Qag(f, 1.0, -1.0, 1e-14, 0.0, w.limit, w, Qk61)
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Limit: result %.10f, expected %.10f\n", result, -exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-6) {
			t.Errorf("Limit: abserr %.20f, expected %.20f\n", abserr, exp_abserr)
		}
		if !assert.EqualInt(w.size, exp_last) {
			t.Errorf("Limit: last %d, expected %d\n", w.size, exp_last)
		}
		if err == nil {
			t.Errorf("Limit: expect error\n")
		}
	}
}
示例#15
0
func TestQng(t *testing.T) {
	{
		exp_result := 7.716049379303083211E-02
		exp_abserr := 9.424302199601294244E-08
		exp_neval := 21
		f := f1{alpha: 2.6}
		result, abserr, neval, err := Qng(f, 0.0, 1.0, 1e-1, 0.0)
		if err != nil {
			t.Errorf("Don't expect Error: %v\n", err)
		}
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-7) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %f, expect: %f\n", neval, exp_neval)
		}
	}

	{
		exp_result := 7.716049379303083211E-02
		exp_abserr := 9.424302199601294244E-08
		exp_neval := 21
		f := f1{alpha: 2.6}
		result, abserr, neval, err := Qng(f, 1.0, 0.0, 1e-1, 0.0)
		if err != nil {
			t.Errorf("Don't expect Error: %v\n", err)
		}
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-7) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %f, expect: %f\n", neval, exp_neval)
		}
	}

	{
		exp_result := 7.716049382706505200E-02
		exp_abserr := 2.666893044866214501E-12
		exp_neval := 43
		f := f1{alpha: 2.6}

		result, abserr, neval, err := Qng(f, 0.0, 1.0, 1e-9, 0.0)
		if err != nil {
			t.Errorf("Don't expect Error: %v\n", err)
		}
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-5) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %d, expect: %d\n", neval, exp_neval)
		}
	}

	{
		exp_result := 7.716049382716029525E-02
		exp_abserr := 8.566535680046930668E-16
		exp_neval := 87
		f := f1{alpha: 2.6}

		result, abserr, neval, err := Qng(f, 0.0, 1.0, 0.0, 1e-13)
		if err != nil {
			t.Errorf("Don't expect Error: %v\n", err)
		}
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-5) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %d, expect: %d\n", neval, exp_neval)
		}

		result, abserr, neval, err = Qng(f, 1.0, 0.0, 0.0, 1e-13)
		if err != nil {
			t.Errorf("Don't expect Error: %v\n", err)
		}
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, -exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-5) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %d, expect: %d\n", neval, exp_neval)
		}
	}

	{
		exp_result := -7.238969575482961938E-01
		exp_abserr := 1.277676889520056369E-14
		exp_neval := 43
		f := f3{alpha: 1.3}

		result, abserr, neval, err := Qng(f, 0.3, 2.71, 0.0, 1e-12)
		if err != nil {
			t.Errorf("Don't expect Error: %v\n", err)
		}
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-7) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %d, expect: %d\n", neval, exp_neval)
		}

		result, abserr, neval, err = Qng(f, 2.71, 0.3, 0.0, 1e-12)
		if err != nil {
			t.Errorf("Don't expect Error: %v\n", err)
		}
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, -exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-7) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %d, expect: %d\n", neval, exp_neval)
		}
	}

	{
		exp_result := 3.222948711817264211E+01
		exp_abserr := 2.782360287710622870E+01
		exp_neval := 87
		f := f1{alpha: -0.9}

		result, abserr, neval, err := Qng(f, 0.0, 1.0, 0.0, 1e-3)
		if err == nil {
			t.Errorf("Expect error!: failed to reach tolerance with highest-order rule\n")
		}
		if !assert.EqualFloat(result, exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-5) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %d, expect: %d\n", neval, exp_neval)
		}

		result, abserr, neval, err = Qng(f, 1.0, 0.0, 0.0, 1e-13)
		if err == nil {
			t.Errorf("Expect error!: failed to reach tolerance with highest-order rule\n")
		}
		if !assert.EqualFloat(result, -exp_result, 1e-15) {
			t.Errorf("Result: %f, expect: %f\n", result, -exp_result)
		}
		if !assert.EqualFloat(abserr, exp_abserr, 1e-5) {
			t.Errorf("Abserr: %f, expect: %f\n", abserr, exp_abserr)
		}
		if neval != exp_neval {
			t.Errorf("Neval: %d, expect: %d\n", neval, exp_neval)
		}
	}
}