-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgammainc_test.go
86 lines (78 loc) · 2.11 KB
/
gammainc_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2018, Jack Parkinson. All rights reserved.
// Use of this source code is governed by the BSD 3-Clause
// license that can be found in the LICENSE file.
package special_test
import (
"testing"
. "scientificgo.org/special"
"scientificgo.org/testutil"
)
var casesGammaIncU = []struct {
Label string
In1, In2, Out float64
}{
{"", nan, 2, nan},
{"", 20, -2.432, nan},
{"", 10, 0, 362880},
{"", 10, +inf, 0},
{"", 0, 10, 4.156968929685325e-06},
{"", -1, 10, 3.830240465631609e-07},
{"", -10, 10, 2.2146903192202743e-16},
{"", -10, 27, 2.420076067270557e-28},
{"", 10, 10, 166173.53478754574},
{"", 10, 1, 362879.95956592244},
{"", -10.2, 1.99, 9.893689107832149e-06},
}
var casesGammaIncL = []struct {
Label string
In1, In2, Out float64
}{
{"", nan, 2, nan},
{"", -10, nan, nan},
{"", 20, -2.432, nan},
{"", 10, 0, 0},
{"", 10, +inf, 362880},
{"", -10, 10, +inf},
{"", 10, 100, 362880},
{"", 10, 1000, 362880},
{"", 100, 1000, 9.332621544394415e+155},
{"", 10, 0.001, 9.990913256294004e-32},
{"", -11.2, 1.99, -4.522214610043099e-06},
}
var casesGammaIncIdentity = []struct {
Label string
In1, In2, Out float64
}{
{"", nan, 2, nan},
{"", -10, nan, nan},
{"", 20, -2.432, nan},
{"", +inf, 12.2, nan},
{"", 10, +inf, 362880},
{"", 10, 43, 362880},
{"", 50.5, 94.3, 4.290462912351957e+63},
{"", 150.5, 94.3, 4.661072627097374e+261},
{"", 150.5, 194.3, 4.661072627097374e+261},
{"", 150.5, 1.943e+07, 4.661072627097374e+261},
}
func TestGammaIncU(t *testing.T) { testutil.Test(t, tol, casesGammaIncU, GammaIncU) }
func TestGammaIncL(t *testing.T) { testutil.Test(t, tol, casesGammaIncL, GammaIncL) }
func TestGammaIncIdentity(t *testing.T) {
identity := func(a, x float64) float64 {
return GammaIncU(a, x) + GammaIncL(a, x)
}
testutil.Test(t, tol, casesGammaIncIdentity, identity)
}
/*
func BenchmarkGammaIncU(b *testing.B) {
GlobalF = bench(b, cGammaIncU, "",
func(x []float64) float64 {
return GammaIncU(x[0], x[1])
})
}
func BenchmarkGammaIncL(b *testing.B) {
GlobalF = bench(b, cGammaIncL, "",
func(x []float64) float64 {
return GammaIncL(x[0], x[1])
})
}
*/