Skip to content

Commit 9ce38f5

Browse files
committed
math: don't run huge argument tests on s390x
The s390x implementations for Sin/Cos/SinCos/Tan use assembly routines which don't reduce arguments accurately enough for huge inputs. Fixes #29221. Change-Id: I340f576899d67bb52a553c3ab22e6464172c936d Reviewed-on: https://go-review.googlesource.com/c/154119 Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 35edc96 commit 9ce38f5

File tree

2 files changed

+99
-84
lines changed

2 files changed

+99
-84
lines changed

src/math/all_test.go

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -176,47 +176,6 @@ var cosLarge = []float64{
176176
-7.3924135157173099849e-01,
177177
}
178178

179-
// Inputs to test trig_reduce
180-
var trigHuge = []float64{
181-
1 << 120,
182-
1 << 240,
183-
1 << 480,
184-
1234567891234567 << 180,
185-
1234567891234567 << 300,
186-
MaxFloat64,
187-
}
188-
189-
// Results for trigHuge[i] calculated with https://github.com/robpike/ivy
190-
// using 4096 bits of working precision. Values requiring less than
191-
// 102 decimal digits (1 << 120, 1 << 240, 1 << 480, 1234567891234567 << 180)
192-
// were confirmed via https://keisan.casio.com/
193-
var cosHuge = []float64{
194-
-0.92587902285483787,
195-
0.93601042593353793,
196-
-0.28282777640193788,
197-
-0.14616431394103619,
198-
-0.79456058210671406,
199-
-0.99998768942655994,
200-
}
201-
202-
var sinHuge = []float64{
203-
0.37782010936075202,
204-
-0.35197227524865778,
205-
0.95917070894368716,
206-
0.98926032637023618,
207-
-0.60718488235646949,
208-
0.00496195478918406,
209-
}
210-
211-
var tanHuge = []float64{
212-
-0.40806638884180424,
213-
-0.37603456702698076,
214-
-3.39135965054779932,
215-
-6.76813854009065030,
216-
0.76417695016604922,
217-
-0.00496201587444489,
218-
}
219-
220179
var cosh = []float64{
221180
7.2668796942212842775517446e+01,
222181
1.1479413465659254502011135e+03,
@@ -3103,49 +3062,6 @@ func TestTrigReduce(t *testing.T) {
31033062
}
31043063
}
31053064

3106-
// Check that trig values of huge angles return accurate results.
3107-
// This confirms that argument reduction works for very large values
3108-
// up to MaxFloat64.
3109-
func TestHugeCos(t *testing.T) {
3110-
for i := 0; i < len(trigHuge); i++ {
3111-
f1 := cosHuge[i]
3112-
f2 := Cos(trigHuge[i])
3113-
if !close(f1, f2) {
3114-
t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
3115-
}
3116-
}
3117-
}
3118-
3119-
func TestHugeSin(t *testing.T) {
3120-
for i := 0; i < len(trigHuge); i++ {
3121-
f1 := sinHuge[i]
3122-
f2 := Sin(trigHuge[i])
3123-
if !close(f1, f2) {
3124-
t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
3125-
}
3126-
}
3127-
}
3128-
3129-
func TestHugeSinCos(t *testing.T) {
3130-
for i := 0; i < len(trigHuge); i++ {
3131-
f1, g1 := sinHuge[i], cosHuge[i]
3132-
f2, g2 := Sincos(trigHuge[i])
3133-
if !close(f1, f2) || !close(g1, g2) {
3134-
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
3135-
}
3136-
}
3137-
}
3138-
3139-
func TestHugeTan(t *testing.T) {
3140-
for i := 0; i < len(trigHuge); i++ {
3141-
f1 := tanHuge[i]
3142-
f2 := Tan(trigHuge[i])
3143-
if !close(f1, f2) {
3144-
t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
3145-
}
3146-
}
3147-
}
3148-
31493065
// Check that math constants are accepted by compiler
31503066
// and have right value (assumes strconv.ParseFloat works).
31513067
// https://golang.org/issue/201

src/math/huge_test.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright 2018 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.
4+
5+
// Disabled for s390x because it uses assembly routines that are not
6+
// accurate for huge arguments.
7+
8+
// +build !s390x
9+
10+
package math_test
11+
12+
import (
13+
. "math"
14+
"testing"
15+
)
16+
17+
// Inputs to test trig_reduce
18+
var trigHuge = []float64{
19+
1 << 120,
20+
1 << 240,
21+
1 << 480,
22+
1234567891234567 << 180,
23+
1234567891234567 << 300,
24+
MaxFloat64,
25+
}
26+
27+
// Results for trigHuge[i] calculated with https://github.com/robpike/ivy
28+
// using 4096 bits of working precision. Values requiring less than
29+
// 102 decimal digits (1 << 120, 1 << 240, 1 << 480, 1234567891234567 << 180)
30+
// were confirmed via https://keisan.casio.com/
31+
var cosHuge = []float64{
32+
-0.92587902285483787,
33+
0.93601042593353793,
34+
-0.28282777640193788,
35+
-0.14616431394103619,
36+
-0.79456058210671406,
37+
-0.99998768942655994,
38+
}
39+
40+
var sinHuge = []float64{
41+
0.37782010936075202,
42+
-0.35197227524865778,
43+
0.95917070894368716,
44+
0.98926032637023618,
45+
-0.60718488235646949,
46+
0.00496195478918406,
47+
}
48+
49+
var tanHuge = []float64{
50+
-0.40806638884180424,
51+
-0.37603456702698076,
52+
-3.39135965054779932,
53+
-6.76813854009065030,
54+
0.76417695016604922,
55+
-0.00496201587444489,
56+
}
57+
58+
// Check that trig values of huge angles return accurate results.
59+
// This confirms that argument reduction works for very large values
60+
// up to MaxFloat64.
61+
func TestHugeCos(t *testing.T) {
62+
for i := 0; i < len(trigHuge); i++ {
63+
f1 := cosHuge[i]
64+
f2 := Cos(trigHuge[i])
65+
if !close(f1, f2) {
66+
t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
67+
}
68+
}
69+
}
70+
71+
func TestHugeSin(t *testing.T) {
72+
for i := 0; i < len(trigHuge); i++ {
73+
f1 := sinHuge[i]
74+
f2 := Sin(trigHuge[i])
75+
if !close(f1, f2) {
76+
t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
77+
}
78+
}
79+
}
80+
81+
func TestHugeSinCos(t *testing.T) {
82+
for i := 0; i < len(trigHuge); i++ {
83+
f1, g1 := sinHuge[i], cosHuge[i]
84+
f2, g2 := Sincos(trigHuge[i])
85+
if !close(f1, f2) || !close(g1, g2) {
86+
t.Errorf("Sincos(%g) = %g, %g, want %g, %g", trigHuge[i], f2, g2, f1, g1)
87+
}
88+
}
89+
}
90+
91+
func TestHugeTan(t *testing.T) {
92+
for i := 0; i < len(trigHuge); i++ {
93+
f1 := tanHuge[i]
94+
f2 := Tan(trigHuge[i])
95+
if !close(f1, f2) {
96+
t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)