aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/math/sin.go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2010-12-03 04:34:57 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2010-12-03 04:34:57 +0000
commit7a9389330e91acc3ed05deac2d198af25d13cf3c (patch)
tree38fe54a4f38ede5d949c915d66191f24a6fe5153 /libgo/go/math/sin.go
parent1aa6700378e5188a853c018256113ce6e1fb5c05 (diff)
downloadgcc-7a9389330e91acc3ed05deac2d198af25d13cf3c.zip
gcc-7a9389330e91acc3ed05deac2d198af25d13cf3c.tar.gz
gcc-7a9389330e91acc3ed05deac2d198af25d13cf3c.tar.bz2
Add Go frontend, libgo library, and Go testsuite.
gcc/: * gcc.c (default_compilers): Add entry for ".go". * common.opt: Add -static-libgo as a driver option. * doc/install.texi (Configuration): Mention libgo as an option for --enable-shared. Mention go as an option for --enable-languages. * doc/invoke.texi (Overall Options): Mention .go as a file name suffix. Mention go as a -x option. * doc/frontends.texi (G++ and GCC): Mention Go as a supported language. * doc/sourcebuild.texi (Top Level): Mention libgo. * doc/standards.texi (Standards): Add section on Go language. Move references for other languages into their own section. * doc/contrib.texi (Contributors): Mention that I contributed the Go frontend. gcc/testsuite/: * lib/go.exp: New file. * lib/go-dg.exp: New file. * lib/go-torture.exp: New file. * lib/target-supports.exp (check_compile): Match // Go. From-SVN: r167407
Diffstat (limited to 'libgo/go/math/sin.go')
-rw-r--r--libgo/go/math/sin.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/libgo/go/math/sin.go b/libgo/go/math/sin.go
new file mode 100644
index 0000000..35220cb
--- /dev/null
+++ b/libgo/go/math/sin.go
@@ -0,0 +1,66 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package math
+
+
+/*
+ Floating-point sine and cosine.
+
+ Coefficients are #5077 from Hart & Cheney. (18.80D)
+*/
+
+func sinus(x float64, quad int) float64 {
+ const (
+ P0 = .1357884097877375669092680e8
+ P1 = -.4942908100902844161158627e7
+ P2 = .4401030535375266501944918e6
+ P3 = -.1384727249982452873054457e5
+ P4 = .1459688406665768722226959e3
+ Q0 = .8644558652922534429915149e7
+ Q1 = .4081792252343299749395779e6
+ Q2 = .9463096101538208180571257e4
+ Q3 = .1326534908786136358911494e3
+ )
+ if x < 0 {
+ x = -x
+ quad = quad + 2
+ }
+ x = x * (2 / Pi) /* underflow? */
+ var y float64
+ if x > 32764 {
+ var e float64
+ e, y = Modf(x)
+ e = e + float64(quad)
+ f, _ := Modf(0.25 * e)
+ quad = int(e - 4*f)
+ } else {
+ k := int32(x)
+ y = x - float64(k)
+ quad = (quad + int(k)) & 3
+ }
+
+ if quad&1 != 0 {
+ y = 1 - y
+ }
+ if quad > 1 {
+ y = -y
+ }
+
+ yy := y * y
+ temp1 := ((((P4*yy+P3)*yy+P2)*yy+P1)*yy + P0) * y
+ temp2 := ((((yy+Q3)*yy+Q2)*yy+Q1)*yy + Q0)
+ return temp1 / temp2
+}
+
+// Cos returns the cosine of x.
+func Cos(x float64) float64 {
+ if x < 0 {
+ x = -x
+ }
+ return sinus(x, 1)
+}
+
+// Sin returns the sine of x.
+func Sin(x float64) float64 { return sinus(x, 0) }