1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // Tests whether the non vector routines are working, even when the tests are run on a
8 // vector-capable machine.
16 func TestCosNovec(t
*testing
.T
) {
18 t
.Skipf("no vector support")
20 for i
:= 0; i
< len(vf
); i
++ {
21 if f
:= CosNoVec(vf
[i
]); !veryclose(cos
[i
], f
) {
22 t
.Errorf("Cos(%g) = %g, want %g", vf
[i
], f
, cos
[i
])
25 for i
:= 0; i
< len(vfcosSC
); i
++ {
26 if f
:= CosNoVec(vfcosSC
[i
]); !alike(cosSC
[i
], f
) {
27 t
.Errorf("Cos(%g) = %g, want %g", vfcosSC
[i
], f
, cosSC
[i
])
32 func TestCoshNovec(t
*testing
.T
) {
34 t
.Skipf("no vector support")
36 for i
:= 0; i
< len(vf
); i
++ {
37 if f
:= CoshNoVec(vf
[i
]); !close(cosh
[i
], f
) {
38 t
.Errorf("Cosh(%g) = %g, want %g", vf
[i
], f
, cosh
[i
])
41 for i
:= 0; i
< len(vfcoshSC
); i
++ {
42 if f
:= CoshNoVec(vfcoshSC
[i
]); !alike(coshSC
[i
], f
) {
43 t
.Errorf("Cosh(%g) = %g, want %g", vfcoshSC
[i
], f
, coshSC
[i
])
47 func TestSinNovec(t
*testing
.T
) {
49 t
.Skipf("no vector support")
51 for i
:= 0; i
< len(vf
); i
++ {
52 if f
:= SinNoVec(vf
[i
]); !veryclose(sin
[i
], f
) {
53 t
.Errorf("Sin(%g) = %g, want %g", vf
[i
], f
, sin
[i
])
56 for i
:= 0; i
< len(vfsinSC
); i
++ {
57 if f
:= SinNoVec(vfsinSC
[i
]); !alike(sinSC
[i
], f
) {
58 t
.Errorf("Sin(%g) = %g, want %g", vfsinSC
[i
], f
, sinSC
[i
])
63 func TestSinhNovec(t
*testing
.T
) {
65 t
.Skipf("no vector support")
67 for i
:= 0; i
< len(vf
); i
++ {
68 if f
:= SinhNoVec(vf
[i
]); !close(sinh
[i
], f
) {
69 t
.Errorf("Sinh(%g) = %g, want %g", vf
[i
], f
, sinh
[i
])
72 for i
:= 0; i
< len(vfsinhSC
); i
++ {
73 if f
:= SinhNoVec(vfsinhSC
[i
]); !alike(sinhSC
[i
], f
) {
74 t
.Errorf("Sinh(%g) = %g, want %g", vfsinhSC
[i
], f
, sinhSC
[i
])
79 // Check that math functions of high angle values
80 // return accurate results. [Since (vf[i] + large) - large != vf[i],
81 // testing for Trig(vf[i] + large) == Trig(vf[i]), where large is
82 // a multiple of 2*Pi, is misleading.]
83 func TestLargeCosNovec(t
*testing
.T
) {
85 t
.Skipf("no vector support")
87 large
:= float64(100000 * Pi
)
88 for i
:= 0; i
< len(vf
); i
++ {
90 f2
:= CosNoVec(vf
[i
] + large
)
92 t
.Errorf("Cos(%g) = %g, want %g", vf
[i
]+large
, f2
, f1
)
97 func TestLargeSinNovec(t
*testing
.T
) {
99 t
.Skipf("no vector support")
101 large
:= float64(100000 * Pi
)
102 for i
:= 0; i
< len(vf
); i
++ {
104 f2
:= SinNoVec(vf
[i
] + large
)
106 t
.Errorf("Sin(%g) = %g, want %g", vf
[i
]+large
, f2
, f1
)
111 func TestTanhNovec(t
*testing
.T
) {
113 t
.Skipf("no vector support")
115 for i
:= 0; i
< len(vf
); i
++ {
116 if f
:= TanhNoVec(vf
[i
]); !veryclose(tanh
[i
], f
) {
117 t
.Errorf("Tanh(%g) = %g, want %g", vf
[i
], f
, tanh
[i
])
120 for i
:= 0; i
< len(vftanhSC
); i
++ {
121 if f
:= TanhNoVec(vftanhSC
[i
]); !alike(tanhSC
[i
], f
) {
122 t
.Errorf("Tanh(%g) = %g, want %g", vftanhSC
[i
], f
, tanhSC
[i
])
128 func TestLog10Novec(t
*testing
.T
) {
130 t
.Skipf("no vector support")
132 for i
:= 0; i
< len(vf
); i
++ {
134 if f
:= Log10NoVec(a
); !veryclose(log10
[i
], f
) {
135 t
.Errorf("Log10(%g) = %g, want %g", a
, f
, log10
[i
])
138 if f
:= Log10NoVec(E
); f
!= Log10E
{
139 t
.Errorf("Log10(%g) = %g, want %g", E
, f
, Log10E
)
141 for i
:= 0; i
< len(vflogSC
); i
++ {
142 if f
:= Log10NoVec(vflogSC
[i
]); !alike(logSC
[i
], f
) {
143 t
.Errorf("Log10(%g) = %g, want %g", vflogSC
[i
], f
, logSC
[i
])