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.
5 // Disabled for s390x because it uses assembly routines that are not
6 // accurate for huge arguments.
17 // Inputs to test trig_reduce
18 var trigHuge = []float64{
22 1234567891234567 << 180,
23 1234567891234567 << 300,
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{
40 var sinHuge = []float64{
49 var tanHuge = []float64{
58 // Check that trig values of huge angles return accurate results.
59 // This confirms that argument reduction works for very large values
61 func TestHugeCos(t *testing.T) {
62 for i := 0; i < len(trigHuge); i++ {
64 f2 := Cos(trigHuge[i])
66 t.Errorf("Cos(%g) = %g, want %g", trigHuge[i], f2, f1)
71 func TestHugeSin(t *testing.T) {
72 for i := 0; i < len(trigHuge); i++ {
74 f2 := Sin(trigHuge[i])
76 t.Errorf("Sin(%g) = %g, want %g", trigHuge[i], f2, f1)
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)
91 func TestHugeTan(t *testing.T) {
92 for i := 0; i < len(trigHuge); i++ {
94 f2 := Tan(trigHuge[i])
96 t.Errorf("Tan(%g) = %g, want %g", trigHuge[i], f2, f1)