summaryrefslogtreecommitdiff
path: root/src/lib/math/sin.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-06-09 09:53:44 -0700
committerRob Pike <r@golang.org>2009-06-09 09:53:44 -0700
commit7249ea4df2b4f12a4e7ed446f270cea87e4ffd34 (patch)
tree7032a11d0cac2ae4d3e90f7a189b575b5a50f848 /src/lib/math/sin.go
parentacf6ef7a82b3fe61516a1bac4563706552bdf078 (diff)
downloadgolang-7249ea4df2b4f12a4e7ed446f270cea87e4ffd34.tar.gz
mv src/lib to src/pkg
tests: all.bash passes, gobuild still works, godoc still works. R=rsc OCL=30096 CL=30102
Diffstat (limited to 'src/lib/math/sin.go')
-rw-r--r--src/lib/math/sin.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/src/lib/math/sin.go b/src/lib/math/sin.go
deleted file mode 100644
index 9fc69606c..000000000
--- a/src/lib/math/sin.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// 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
-
-import "math"
-
-func sinus(x float64, quad int) float64 {
- // Coefficients are #3370 from Hart & Cheney (18.80D).
- 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);
- temp1, 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);
-}