]> Cypherpunks repositories - gostls13.git/commitdiff
update to new world. still can't use it but it's a lot of editing....
authorRob Pike <r@golang.org>
Sat, 28 Jun 2008 00:06:23 +0000 (17:06 -0700)
committerRob Pike <r@golang.org>
Sat, 28 Jun 2008 00:06:23 +0000 (17:06 -0700)
SVN=125218

16 files changed:
src/lib/math/asin.go
src/lib/math/atan.go
src/lib/math/atan2.go
src/lib/math/exp.go
src/lib/math/fabs.go
src/lib/math/floor.go
src/lib/math/fmod.go
src/lib/math/hypot.go
src/lib/math/log.go
src/lib/math/pow.go
src/lib/math/pow10.go
src/lib/math/sin.go
src/lib/math/sinh.go
src/lib/math/sqrt.go
src/lib/math/tan.go
src/lib/math/tanh.go

index 6297064dbe739706b8b3ee7454e59590befb68a6..9a83e9e435dc06221602f45b28a566fe6bce0980 100644 (file)
@@ -2,11 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package asin
+package math
+
+import math "atan"
+import math "sqrt"
 
-import sys "sys"
-import atan "atan"
-import sqrt "sqrt"
 export asin, acos
 
 /*
@@ -34,14 +34,14 @@ asin(arg double)double
                sign = true;
        }
        if arg > 1 {
-               return sys.NaN();
+               panic "return sys.NaN()";
        }
 
-       temp = sqrt.sqrt(1 - x*x);
+       temp = sqrt(1 - x*x);
        if x > 0.7 {
-               temp = pio2 - atan.atan(temp/x);
+               temp = pio2 - atan(temp/x);
        } else {
-               temp = atan.atan(x/temp);
+               temp = atan(x/temp);
        }
 
        if sign {
@@ -54,7 +54,7 @@ func
 acos(arg double)double
 {
        if(arg > 1 || arg < -1) {
-               return sys.NaN();
+               panic "return sys.NaN()";
        }
        return pio2 - asin(arg);
 }
index 47513899689d697fc9254b74fcb7c3098d6b8407..064b8d4fca544112bb09a655da3b03393565eed1 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package atan
+package math
 
 export atan
 
index 2e1093f9d93161ce42f5c300395b6c6b117e87ec..b3bddf752193bf73f1591a5ac41df303e79eb400 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package atan2
+package math
 
-import atan "atan"
+import math "atan"
 export atan2
 
 /*
@@ -29,7 +29,7 @@ atan2(arg1, arg2 double) double
                }
                return -pio2;
        }
-       x = atan.atan(arg1/arg2);
+       x = atan(arg1/arg2);
        if arg2 < 0 {
                if x <= 0 {
                        return x + pi;
index 8a9542a35893a89f9cbc76e612d647e36db62e19..6be61afdf3a09cfd52f6a6bcdda952e388d0d20a 100644 (file)
@@ -2,10 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package exp
+package math
 
-import sys "sys"
-import floor "floor"
+import math "floor"
 export exp
 
 /*
@@ -34,21 +33,21 @@ exp(arg double) double
        var x, fract, temp1, temp2, xsq double;
        var ent int;
 
-       if arg == 0 {
+       if arg == 0. {
                return 1;
        }
        if arg < -maxf {
-               return 0;
+               return 0.;
        }
        if arg > maxf {
-               return sys.Inf(1);
+               panic "return sys.Inf(1)"
        }
 
        x = arg*log2e;
-       ent = int(floor.floor(x));
+       ent = int(floor(x));
        fract = (x-double(ent)) - 0.5;
        xsq = fract*fract;
        temp1 = ((p2*xsq+p1)*xsq+p0)*fract;
        temp2 = ((xsq+q2)*xsq+q1)*xsq + q0;
-       return sys.ldexp(sqrt2*(temp2+temp1)/(temp2-temp1), ent);
+       return sys.ldexp(ent, sqrt2*(temp2+temp1)/(temp2-temp1));
 }
index 34d0de96984491facf2ecc9c02b498f21ad13db5..4a184be33ae8907a7a4c651588d07d742fd54ba3 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package fabs
+package math
 
 export fabs
 
index 581836a8c266100e60f3331ad8cb5813348945f9..108b40395c73b1a6cc07c7a52e26176fc9e636e0 100644 (file)
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package floor
+package math
 
-import sys "sys"
 export floor, ceil
 
 /*
index fc26b5068f3dcb770b7d6cb4ce38182338ac6875..4a5fe3b83c6b031052dfc4c2fc0964eed287c992 100644 (file)
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package fmod
+package math
 
-import sys "sys"
 export fmod
 
 /*
@@ -39,7 +38,7 @@ fmod(x, y double) double
                if rfr < yfr {
                        rexp = rexp - 1;
                }
-               r = r - sys.ldexp(y, rexp-yexp);
+               r = r - sys.ldexp(rexp-yexp, y);
        }
        if sign {
                r = -r;
index a1e9e729e47743553ae2642c2a14740fb5ed6ef9..51e6662ddcda4b82d4c5303cb017fad68403b947 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package hypot
+package math
 
 export hypot
 
index cc7ebf06c7b459a4851fb70ec946b64d87631d4c..1c44eb8a3bd4e57c7266d918190c99f86e2a1e06 100644 (file)
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package log
+package math
 
-import sys "sys"
 export log, log10
 
 /*
@@ -37,7 +36,7 @@ log(arg double) double
        var exp int;
 
        if arg <= 0 {
-               return sys.NaN();
+               panic "return sys.NaN()";
        }
 
        exp,x = sys.frexp(arg);
@@ -64,7 +63,7 @@ log10(arg double) double
 {
 
        if arg <= 0 {
-               return sys.NaN();
+               panic "return sys.NaN()";
        }
        return log(arg) * ln10o1;
 }
index b2a954fb1b1b8c5329ad07488f875b8978260ed0..dba41efdcb69daefa2caa5d465459f625419d604 100644 (file)
@@ -2,13 +2,12 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package pow
+package math
 
-import         sys "sys"
-import         floor "floor"
-import         sqrt "sqrt"
-import         log "log"
-import         exp "exp"
+import         math "floor"
+import         math "sqrt"
+import         math "log"
+import         math "exp"
 export         pow
 
 /*
@@ -27,14 +26,14 @@ pow(arg1,arg2 double) double
        if arg1 <= 0 {
                if(arg1 == 0) {
                        if arg2 <= 0 {
-                               return sys.NaN();
+                               panic "return sys.NaN()";
                        }
                        return 0;
                }
 
-               temp = floor.floor(arg2);
+               temp = floor(arg2);
                if temp != arg2 {
-                       return sys.NaN();
+                       panic "return sys.NaN()";
                }
 
                l = long(temp);
@@ -44,15 +43,15 @@ pow(arg1,arg2 double) double
                return pow(-arg1, arg2);
        }
 
-       temp = floor.floor(arg2);
+       temp = floor(arg2);
        if temp != arg2 {
                if arg2-temp == .5 {
                        if temp == 0 {
-                               return sqrt.sqrt(arg1);
+                               return sqrt(arg1);
                        }
-                       return pow(arg1, temp) * sqrt.sqrt(arg1);
+                       return pow(arg1, temp) * sqrt(arg1);
                }
-               return exp.exp(arg2 * log.log(arg1));
+               return exp(arg2 * log(arg1));
        }
 
        l = long(temp);
index 1eb9bd1f18149e7217130ec02e7d1c8a8bbb3c03..bb06758ff1ae912d9948c728fccb92c1c2ea6930 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package pow10
+package math
 
 export pow10
 
index ccadd1c82aaf1bd57e28c487e722e66661415e6c..dabe825128ad254b987f097549a69462dd662d55 100644 (file)
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package sin
+package math
 
-import sys "sys"
 export sin, cos
 
 const
@@ -41,7 +40,7 @@ sinus(arg double, quad int) double
        } else {
                k = long(x);
                y = x - double(k);
-               quad = (quad + k) & 3;
+               quad = (quad + int(k)) & 3;
        }
 
        if quad&1 != 0 {
index a26031ba5213e4dbe808f643fd02737dae3da709..75f6ddd631000dda36a628d8762aa45dee353638 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package sinh
+package math
 
-import exp "exp"
+import math "exp"
 export sinh, cosh
 
 /*
@@ -45,10 +45,10 @@ sinh(arg double) double
        }
        switch true {
        case arg > 21:
-               temp = exp.exp(arg)/2;
+               temp = exp(arg)/2;
 
        case arg > 0.5:
-               temp = (exp.exp(arg) - exp.exp(-arg))/2;
+//             temp = (exp(arg) - exp(-arg))/2;
 
        default:
                argsq = arg*arg;
@@ -69,7 +69,7 @@ cosh(arg double) double
                arg = - arg;
        }
        if arg > 21 {
-               return exp.exp(arg)/2;
+               return exp(arg)/2;
        }
-       return (exp.exp(arg) + exp.exp(-arg))/2;
+//     return (exp(arg) + exp(-arg))/2;
 }
index 8209a3ac49e1fb00e622419a2b9fc0c8ccf632f7..c5c01584fe3c8fc539b4781301f9ea4dd608fd9e 100644 (file)
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package sqrt
+package math
 
-import         sys "sys"
 export         sqrt
 
 /*
@@ -20,13 +19,14 @@ sqrt(arg double) double
        var x, temp double;
        var exp, i int;
 
+/* BUG: NO isINF
        if sys.isInf(arg, 1) {
                return arg;
        }
-
+*/
        if arg <= 0 {
                if arg < 0 {
-                       return sys.NaN();
+                       panic "return sys.NaN()"
                }
                return 0;
        }
index 913d942c21b8edf58a682c73294c03e96c259af3..695352ae5e319e5d4262f1d708d99a883a2596f7 100644 (file)
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package tan
+package math
 
-import         sys "sys"
 export         tan
 
 /*
@@ -63,7 +62,7 @@ tan(arg double) double
 
        if flag {
                if(temp == 0) {
-                       return sys.NaN();
+                       panic "return sys.NaN()";
                }
                temp = 1/temp;
        }
index 8d1748205c9e7c519997d2e7c2053f108ce885ac..3e299c808f8b455d728a1ee7dd82a54424afe81f 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package tanh
+package math
 
-import         sinh "sinh"
+import         math "sinh"
 export         tanh
 
 /*
@@ -23,10 +23,10 @@ tanh(arg double) double
                if arg > 21 {
                        return -1;
                }
-               return -sinh.sinh(arg)/sinh.cosh(arg);
+               return -sinh(arg)/cosh(arg);
        }
        if arg > 21 {
                return 1;
        }
-       return sinh.sinh(arg)/sinh.cosh(arg);
+       return sinh(arg)/cosh(arg);
 }