-
Notifications
You must be signed in to change notification settings - Fork 2
/
filter_test.go
59 lines (54 loc) · 1.17 KB
/
filter_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
package gdsp
import "testing"
func TestFilterLowPass1(t *testing.T) {
b := MakeVectorFromArray([]float64{0.25, 0.25})
a := MakeVectorFromArray([]float64{1.0, -0.5})
zfRef := 1.25
eRef := 0.875
zf, e := Filter(b, a, []float64{1.0}, []float64{1.0})
if zf[0] != zfRef {
t.FailNow()
}
if e[0] != eRef {
t.FailNow()
}
}
func TestFilterLowPass2(t *testing.T) {
b := MakeVectorFromArray([]float64{0.25, 0.25})
a := MakeVectorFromArray([]float64{1.0, -0.5})
zfRef := 0.25
eRef := 0.375
zf, e := Filter(b, a, []float64{1.0}, nil)
if zf[0] != zfRef {
t.FailNow()
}
if e[0] != eRef {
t.FailNow()
}
}
func TestFilterHighPass1(t *testing.T) {
b := MakeVectorFromArray([]float64{0.25, -0.25})
a := MakeVectorFromArray([]float64{1.0, 0.5})
zfRef := 1.0
eRef := -0.5
zf, e := Filter(b, a, []float64{0.0}, []float64{1.0})
if zf[0] != zfRef {
t.FailNow()
}
if e[0] != eRef {
t.FailNow()
}
}
func TestFilterHighPass2(t *testing.T) {
b := MakeVectorFromArray([]float64{0.25, -0.25})
a := MakeVectorFromArray([]float64{1.0, 0.5})
zfRef := 0.0
eRef := 0.0
zf, e := Filter(b, a, []float64{0.0}, nil)
if zf[0] != zfRef {
t.FailNow()
}
if e[0] != eRef {
t.FailNow()
}
}