mirror of
https://github.com/gonum/gonum.git
synced 2025-10-13 10:54:03 +08:00
mathext: make tests parallel
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestAiry(t *testing.T) {
|
func TestAiry(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
z, ans complex128
|
z, ans complex128
|
||||||
}{
|
}{
|
||||||
|
@@ -84,6 +84,7 @@ var betaTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBeta(t *testing.T) {
|
func TestBeta(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for i, test := range betaTests {
|
for i, test := range betaTests {
|
||||||
v := mathext.Beta(test.p, test.q)
|
v := mathext.Beta(test.p, test.q)
|
||||||
testOK := func(x float64) bool {
|
testOK := func(x float64) bool {
|
||||||
@@ -142,6 +143,7 @@ func BenchmarkBeta2(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLbeta(t *testing.T) {
|
func TestLbeta(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for i, test := range betaTests {
|
for i, test := range betaTests {
|
||||||
want := math.Log(test.want)
|
want := math.Log(test.want)
|
||||||
v := mathext.Lbeta(test.p, test.q)
|
v := mathext.Lbeta(test.p, test.q)
|
||||||
|
@@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestIncBeta(t *testing.T) {
|
func TestIncBeta(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
tol := 1e-14
|
tol := 1e-14
|
||||||
tol2 := 1e-10
|
tol2 := 1e-10
|
||||||
// Test against values from scipy
|
// Test against values from scipy
|
||||||
|
@@ -14,6 +14,7 @@ import (
|
|||||||
var result float64
|
var result float64
|
||||||
|
|
||||||
func TestDigamma(t *testing.T) {
|
func TestDigamma(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const tol = 1e-10
|
const tol = 1e-10
|
||||||
|
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
|
@@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
// Testing EllipticF (and EllipticRF) using the addition theorems from http://dlmf.nist.gov/19.11.i
|
// Testing EllipticF (and EllipticRF) using the addition theorems from http://dlmf.nist.gov/19.11.i
|
||||||
func TestEllipticF(t *testing.T) {
|
func TestEllipticF(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const tol = 1.0e-14
|
const tol = 1.0e-14
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ func TestEllipticF(t *testing.T) {
|
|||||||
|
|
||||||
// Testing EllipticE (and EllipticRF, EllipticRD) using the addition theorems from http://dlmf.nist.gov/19.11.i
|
// Testing EllipticE (and EllipticRF, EllipticRD) using the addition theorems from http://dlmf.nist.gov/19.11.i
|
||||||
func TestEllipticE(t *testing.T) {
|
func TestEllipticE(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const tol = 1.0e-14
|
const tol = 1.0e-14
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@ import (
|
|||||||
// TestCompleteKE checks if the Legendre's relation for m=0.0001(0.0001)0.9999
|
// TestCompleteKE checks if the Legendre's relation for m=0.0001(0.0001)0.9999
|
||||||
// is satisfied with accuracy 1e-14.
|
// is satisfied with accuracy 1e-14.
|
||||||
func TestCompleteKE(t *testing.T) {
|
func TestCompleteKE(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const tol = 1.0e-14
|
const tol = 1.0e-14
|
||||||
|
|
||||||
for m := 1; m <= 9999; m++ {
|
for m := 1; m <= 9999; m++ {
|
||||||
@@ -34,6 +35,7 @@ func TestCompleteKE(t *testing.T) {
|
|||||||
// K(m) = B(m) + D(m),
|
// K(m) = B(m) + D(m),
|
||||||
// E(m) = B(m) + (1-m)D(m).
|
// E(m) = B(m) + (1-m)D(m).
|
||||||
func TestCompleteBD(t *testing.T) {
|
func TestCompleteBD(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
const tol = 1.0e-14
|
const tol = 1.0e-14
|
||||||
|
|
||||||
for m := 1; m <= 9999; m++ {
|
for m := 1; m <= 9999; m++ {
|
||||||
|
@@ -11,6 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNormalQuantile(t *testing.T) {
|
func TestNormalQuantile(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
// Values from https://www.johndcook.com/blog/normal_cdf_inverse/
|
// Values from https://www.johndcook.com/blog/normal_cdf_inverse/
|
||||||
p := []float64{
|
p := []float64{
|
||||||
0.0000001,
|
0.0000001,
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGammaIncReg(t *testing.T) {
|
func TestGammaIncReg(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
a, x, want float64
|
a, x, want float64
|
||||||
}{
|
}{
|
||||||
@@ -42,6 +43,7 @@ func TestGammaIncReg(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGammaIncRegComp(t *testing.T) {
|
func TestGammaIncRegComp(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
a, x, want float64
|
a, x, want float64
|
||||||
}{
|
}{
|
||||||
@@ -74,6 +76,7 @@ func TestGammaIncRegComp(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGammaIncRegInv(t *testing.T) {
|
func TestGammaIncRegInv(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
a, x, want float64
|
a, x, want float64
|
||||||
}{
|
}{
|
||||||
@@ -106,6 +109,7 @@ func TestGammaIncRegInv(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGammaIncRegCompInv(t *testing.T) {
|
func TestGammaIncRegCompInv(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
a, x, want float64
|
a, x, want float64
|
||||||
}{
|
}{
|
||||||
|
@@ -62,6 +62,7 @@ func randInput(rnd *rand.Rand) input {
|
|||||||
const nInputs = 100000
|
const nInputs = 100000
|
||||||
|
|
||||||
func TestAiry(t *testing.T) {
|
func TestAiry(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < nInputs; i++ {
|
for i := 0; i < nInputs; i++ {
|
||||||
in := randInput(rnd)
|
in := randInput(rnd)
|
||||||
@@ -70,6 +71,7 @@ func TestAiry(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZacai(t *testing.T) {
|
func TestZacai(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
switch runtime.GOARCH {
|
switch runtime.GOARCH {
|
||||||
case "arm64":
|
case "arm64":
|
||||||
t.Skipf("skipping on GOARCH=%s", runtime.GOARCH)
|
t.Skipf("skipping on GOARCH=%s", runtime.GOARCH)
|
||||||
@@ -82,6 +84,7 @@ func TestZacai(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZbknu(t *testing.T) {
|
func TestZbknu(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < nInputs; i++ {
|
for i := 0; i < nInputs; i++ {
|
||||||
in := randInput(rnd)
|
in := randInput(rnd)
|
||||||
@@ -90,6 +93,7 @@ func TestZbknu(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZasyi(t *testing.T) {
|
func TestZasyi(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < nInputs; i++ {
|
for i := 0; i < nInputs; i++ {
|
||||||
in := randInput(rnd)
|
in := randInput(rnd)
|
||||||
@@ -98,6 +102,7 @@ func TestZasyi(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZseri(t *testing.T) {
|
func TestZseri(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
switch runtime.GOARCH {
|
switch runtime.GOARCH {
|
||||||
case "arm64":
|
case "arm64":
|
||||||
t.Skipf("skipping on GOARCH=%s", runtime.GOARCH)
|
t.Skipf("skipping on GOARCH=%s", runtime.GOARCH)
|
||||||
@@ -110,6 +115,7 @@ func TestZseri(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZmlri(t *testing.T) {
|
func TestZmlri(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < nInputs; i++ {
|
for i := 0; i < nInputs; i++ {
|
||||||
in := randInput(rnd)
|
in := randInput(rnd)
|
||||||
@@ -118,6 +124,7 @@ func TestZmlri(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZkscl(t *testing.T) {
|
func TestZkscl(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < nInputs; i++ {
|
for i := 0; i < nInputs; i++ {
|
||||||
in := randInput(rnd)
|
in := randInput(rnd)
|
||||||
@@ -126,6 +133,7 @@ func TestZkscl(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZuchk(t *testing.T) {
|
func TestZuchk(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < nInputs; i++ {
|
for i := 0; i < nInputs; i++ {
|
||||||
in := randInput(rnd)
|
in := randInput(rnd)
|
||||||
@@ -134,6 +142,7 @@ func TestZuchk(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestZs1s2(t *testing.T) {
|
func TestZs1s2(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for i := 0; i < nInputs; i++ {
|
for i := 0; i < nInputs; i++ {
|
||||||
in := randInput(rnd)
|
in := randInput(rnd)
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMvLgamma(t *testing.T) {
|
func TestMvLgamma(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
// Values compared with scipy
|
// Values compared with scipy
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
v float64
|
v float64
|
||||||
|
@@ -17,6 +17,7 @@ var _ rand.Source = (*MT19937_64)(nil)
|
|||||||
// with or without an initial seed array.
|
// with or without an initial seed array.
|
||||||
|
|
||||||
func TestMT19937_64(t *testing.T) {
|
func TestMT19937_64(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint64{
|
want := []uint64{
|
||||||
14514284786278117030, 4620546740167642908, 13109570281517897720, 17462938647148434322, 355488278567739596,
|
14514284786278117030, 4620546740167642908, 13109570281517897720, 17462938647148434322, 355488278567739596,
|
||||||
7469126240319926998, 4635995468481642529, 418970542659199878, 9604170989252516556, 6358044926049913402,
|
7469126240319926998, 4635995468481642529, 418970542659199878, 9604170989252516556, 6358044926049913402,
|
||||||
@@ -38,6 +39,7 @@ func TestMT19937_64(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMT19937_64SeedFromKeys(t *testing.T) {
|
func TestMT19937_64SeedFromKeys(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint64{
|
want := []uint64{
|
||||||
7266447313870364031, 4946485549665804864, 16945909448695747420, 16394063075524226720, 4873882236456199058,
|
7266447313870364031, 4946485549665804864, 16945909448695747420, 16394063075524226720, 4873882236456199058,
|
||||||
14877448043947020171, 6740343660852211943, 13857871200353263164, 5249110015610582907, 10205081126064480383,
|
14877448043947020171, 6740343660852211943, 13857871200353263164, 5249110015610582907, 10205081126064480383,
|
||||||
@@ -60,6 +62,7 @@ func TestMT19937_64SeedFromKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMT19937_64RoundTrip(t *testing.T) {
|
func TestMT19937_64RoundTrip(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var src MT19937_64
|
var src MT19937_64
|
||||||
src.Seed(uint64(time.Now().Unix()))
|
src.Seed(uint64(time.Now().Unix()))
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@ var _ rand.Source = (*MT19937)(nil)
|
|||||||
// with or without an initial seed array.
|
// with or without an initial seed array.
|
||||||
|
|
||||||
func TestMT19937(t *testing.T) {
|
func TestMT19937(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint32{
|
want := []uint32{
|
||||||
3499211612, 581869302, 3890346734, 3586334585, 545404204,
|
3499211612, 581869302, 3890346734, 3586334585, 545404204,
|
||||||
4161255391, 3922919429, 949333985, 2715962298, 1323567403,
|
4161255391, 3922919429, 949333985, 2715962298, 1323567403,
|
||||||
@@ -38,6 +39,7 @@ func TestMT19937(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMT19937SeedFromKeys(t *testing.T) {
|
func TestMT19937SeedFromKeys(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint32{
|
want := []uint32{
|
||||||
1067595299, 955945823, 477289528, 4107218783, 4228976476,
|
1067595299, 955945823, 477289528, 4107218783, 4228976476,
|
||||||
3344332714, 3355579695, 227628506, 810200273, 2591290167,
|
3344332714, 3355579695, 227628506, 810200273, 2591290167,
|
||||||
@@ -60,6 +62,7 @@ func TestMT19937SeedFromKeys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMT19937RoundTrip(t *testing.T) {
|
func TestMT19937RoundTrip(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var src MT19937
|
var src MT19937
|
||||||
src.Seed(uint64(time.Now().Unix()))
|
src.Seed(uint64(time.Now().Unix()))
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ import (
|
|||||||
var _ rand.Source = (*SplitMix64)(nil)
|
var _ rand.Source = (*SplitMix64)(nil)
|
||||||
|
|
||||||
func TestSplitMix64(t *testing.T) {
|
func TestSplitMix64(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint64{
|
want := []uint64{
|
||||||
10451216379200822465, 13757245211066428519, 17911839290282890590, 8196980753821780235, 8195237237126968761,
|
10451216379200822465, 13757245211066428519, 17911839290282890590, 8196980753821780235, 8195237237126968761,
|
||||||
14072917602864530048, 16184226688143867045, 9648886400068060533, 5266705631892356520, 14646652180046636950,
|
14072917602864530048, 16184226688143867045, 9648886400068060533, 5266705631892356520, 14646652180046636950,
|
||||||
@@ -37,6 +38,7 @@ func TestSplitMix64(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSplitMix64RoundTrip(t *testing.T) {
|
func TestSplitMix64RoundTrip(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var src SplitMix64
|
var src SplitMix64
|
||||||
src.Seed(uint64(time.Now().Unix()))
|
src.Seed(uint64(time.Now().Unix()))
|
||||||
|
|
||||||
@@ -65,6 +67,7 @@ func TestSplitMix64RoundTrip(t *testing.T) {
|
|||||||
var _ rand.Source = (*Xoshiro256plus)(nil)
|
var _ rand.Source = (*Xoshiro256plus)(nil)
|
||||||
|
|
||||||
func TestXoshiro256plus(t *testing.T) {
|
func TestXoshiro256plus(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint64{
|
want := []uint64{
|
||||||
201453059313051084, 16342930563397888806, 2922809869868169223, 13315230553875954649, 6410977891529050008,
|
201453059313051084, 16342930563397888806, 2922809869868169223, 13315230553875954649, 6410977891529050008,
|
||||||
2721661332018190285, 3769995280709464022, 17208995829377771030, 16938999919058283733, 8307416726322109393,
|
2721661332018190285, 3769995280709464022, 17208995829377771030, 16938999919058283733, 8307416726322109393,
|
||||||
@@ -86,6 +89,7 @@ func TestXoshiro256plus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestXoshiro256plusRoundTrip(t *testing.T) {
|
func TestXoshiro256plusRoundTrip(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var src Xoshiro256plus
|
var src Xoshiro256plus
|
||||||
src.Seed(uint64(time.Now().Unix()))
|
src.Seed(uint64(time.Now().Unix()))
|
||||||
|
|
||||||
@@ -116,6 +120,7 @@ func TestXoshiro256plusRoundTrip(t *testing.T) {
|
|||||||
var _ rand.Source = (*Xoshiro256plusplus)(nil)
|
var _ rand.Source = (*Xoshiro256plusplus)(nil)
|
||||||
|
|
||||||
func TestXoshiro256plusplus(t *testing.T) {
|
func TestXoshiro256plusplus(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint64{
|
want := []uint64{
|
||||||
14971601782005023387, 13781649495232077965, 1847458086238483744, 13765271635752736470, 3406718355780431780,
|
14971601782005023387, 13781649495232077965, 1847458086238483744, 13765271635752736470, 3406718355780431780,
|
||||||
10892412867582108485, 18204613561675945223, 9655336933892813345, 1781989159761824720, 2477283028068920342,
|
10892412867582108485, 18204613561675945223, 9655336933892813345, 1781989159761824720, 2477283028068920342,
|
||||||
@@ -137,6 +142,7 @@ func TestXoshiro256plusplus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestXoshiro256plusplusRoundTrip(t *testing.T) {
|
func TestXoshiro256plusplusRoundTrip(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var src Xoshiro256plusplus
|
var src Xoshiro256plusplus
|
||||||
src.Seed(uint64(time.Now().Unix()))
|
src.Seed(uint64(time.Now().Unix()))
|
||||||
|
|
||||||
@@ -167,6 +173,7 @@ func TestXoshiro256plusplusRoundTrip(t *testing.T) {
|
|||||||
var _ rand.Source = (*Xoshiro256starstar)(nil)
|
var _ rand.Source = (*Xoshiro256starstar)(nil)
|
||||||
|
|
||||||
func TestXoshiro256starstar(t *testing.T) {
|
func TestXoshiro256starstar(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
want := []uint64{
|
want := []uint64{
|
||||||
12966619160104079557, 9600361134598540522, 10590380919521690900, 7218738570589545383, 12860671823995680371,
|
12966619160104079557, 9600361134598540522, 10590380919521690900, 7218738570589545383, 12860671823995680371,
|
||||||
2648436617965840162, 1310552918490157286, 7031611932980406429, 15996139959407692321, 10177250653276320208,
|
2648436617965840162, 1310552918490157286, 7031611932980406429, 15996139959407692321, 10177250653276320208,
|
||||||
@@ -188,6 +195,7 @@ func TestXoshiro256starstar(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestXoshiro256starstarRoundTrip(t *testing.T) {
|
func TestXoshiro256starstarRoundTrip(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
var src Xoshiro256starstar
|
var src Xoshiro256starstar
|
||||||
src.Seed(uint64(time.Now().Unix()))
|
src.Seed(uint64(time.Now().Unix()))
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestZeta(t *testing.T) {
|
func TestZeta(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
for i, test := range []struct {
|
for i, test := range []struct {
|
||||||
x, q, want float64
|
x, q, want float64
|
||||||
}{
|
}{
|
||||||
|
Reference in New Issue
Block a user