Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4331293f
Commit
4331293f
authored
Jun 27, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update to new world. still can't use it but it's a lot of editing....
SVN=125218
parent
390d5fe5
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
59 additions
and
66 deletions
+59
-66
src/lib/math/asin.go
src/lib/math/asin.go
+9
-9
src/lib/math/atan.go
src/lib/math/atan.go
+1
-1
src/lib/math/atan2.go
src/lib/math/atan2.go
+3
-3
src/lib/math/exp.go
src/lib/math/exp.go
+7
-8
src/lib/math/fabs.go
src/lib/math/fabs.go
+1
-1
src/lib/math/floor.go
src/lib/math/floor.go
+1
-2
src/lib/math/fmod.go
src/lib/math/fmod.go
+2
-3
src/lib/math/hypot.go
src/lib/math/hypot.go
+1
-1
src/lib/math/log.go
src/lib/math/log.go
+3
-4
src/lib/math/pow.go
src/lib/math/pow.go
+12
-13
src/lib/math/pow10.go
src/lib/math/pow10.go
+1
-1
src/lib/math/sin.go
src/lib/math/sin.go
+2
-3
src/lib/math/sinh.go
src/lib/math/sinh.go
+6
-6
src/lib/math/sqrt.go
src/lib/math/sqrt.go
+4
-4
src/lib/math/tan.go
src/lib/math/tan.go
+2
-3
src/lib/math/tanh.go
src/lib/math/tanh.go
+4
-4
No files found.
src/lib/math/asin.go
View file @
4331293f
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// 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
export
asin
,
acos
/*
/*
...
@@ -34,14 +34,14 @@ asin(arg double)double
...
@@ -34,14 +34,14 @@ asin(arg double)double
sign
=
true
;
sign
=
true
;
}
}
if
arg
>
1
{
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
{
if
x
>
0.7
{
temp
=
pio2
-
atan
.
atan
(
temp
/
x
);
temp
=
pio2
-
atan
(
temp
/
x
);
}
else
{
}
else
{
temp
=
atan
.
atan
(
x
/
temp
);
temp
=
atan
(
x
/
temp
);
}
}
if
sign
{
if
sign
{
...
@@ -54,7 +54,7 @@ func
...
@@ -54,7 +54,7 @@ func
acos
(
arg
double
)
double
acos
(
arg
double
)
double
{
{
if
(
arg
>
1
||
arg
<
-
1
)
{
if
(
arg
>
1
||
arg
<
-
1
)
{
return
sys
.
NaN
()
;
panic
"return sys.NaN()"
;
}
}
return
pio2
-
asin
(
arg
);
return
pio2
-
asin
(
arg
);
}
}
src/lib/math/atan.go
View file @
4331293f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
atan
package
math
export
atan
export
atan
...
...
src/lib/math/atan2.go
View file @
4331293f
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
atan2
package
math
import
atan
"atan"
import
math
"atan"
export
atan2
export
atan2
/*
/*
...
@@ -29,7 +29,7 @@ atan2(arg1, arg2 double) double
...
@@ -29,7 +29,7 @@ atan2(arg1, arg2 double) double
}
}
return
-
pio2
;
return
-
pio2
;
}
}
x
=
atan
.
atan
(
arg1
/
arg2
);
x
=
atan
(
arg1
/
arg2
);
if
arg2
<
0
{
if
arg2
<
0
{
if
x
<=
0
{
if
x
<=
0
{
return
x
+
pi
;
return
x
+
pi
;
...
...
src/lib/math/exp.go
View file @
4331293f
...
@@ -2,10 +2,9 @@
...
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
exp
package
math
import
sys
"sys"
import
math
"floor"
import
floor
"floor"
export
exp
export
exp
/*
/*
...
@@ -34,21 +33,21 @@ exp(arg double) double
...
@@ -34,21 +33,21 @@ exp(arg double) double
var
x
,
fract
,
temp1
,
temp2
,
xsq
double
;
var
x
,
fract
,
temp1
,
temp2
,
xsq
double
;
var
ent
int
;
var
ent
int
;
if
arg
==
0
{
if
arg
==
0
.
{
return
1
;
return
1
;
}
}
if
arg
<
-
maxf
{
if
arg
<
-
maxf
{
return
0
;
return
0
.
;
}
}
if
arg
>
maxf
{
if
arg
>
maxf
{
return
sys
.
Inf
(
1
);
panic
"return sys.Inf(1)"
}
}
x
=
arg
*
log2e
;
x
=
arg
*
log2e
;
ent
=
int
(
floor
.
floor
(
x
));
ent
=
int
(
floor
(
x
));
fract
=
(
x
-
double
(
ent
))
-
0.5
;
fract
=
(
x
-
double
(
ent
))
-
0.5
;
xsq
=
fract
*
fract
;
xsq
=
fract
*
fract
;
temp1
=
((
p2
*
xsq
+
p1
)
*
xsq
+
p0
)
*
fract
;
temp1
=
((
p2
*
xsq
+
p1
)
*
xsq
+
p0
)
*
fract
;
temp2
=
((
xsq
+
q2
)
*
xsq
+
q1
)
*
xsq
+
q0
;
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
)
);
}
}
src/lib/math/fabs.go
View file @
4331293f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
fabs
package
math
export
fabs
export
fabs
...
...
src/lib/math/floor.go
View file @
4331293f
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
floor
package
math
import
sys
"sys"
export
floor
,
ceil
export
floor
,
ceil
/*
/*
...
...
src/lib/math/fmod.go
View file @
4331293f
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
fmod
package
math
import
sys
"sys"
export
fmod
export
fmod
/*
/*
...
@@ -39,7 +38,7 @@ fmod(x, y double) double
...
@@ -39,7 +38,7 @@ fmod(x, y double) double
if
rfr
<
yfr
{
if
rfr
<
yfr
{
rexp
=
rexp
-
1
;
rexp
=
rexp
-
1
;
}
}
r
=
r
-
sys
.
ldexp
(
y
,
rexp
-
yexp
);
r
=
r
-
sys
.
ldexp
(
rexp
-
yexp
,
y
);
}
}
if
sign
{
if
sign
{
r
=
-
r
;
r
=
-
r
;
...
...
src/lib/math/hypot.go
View file @
4331293f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
hypot
package
math
export
hypot
export
hypot
...
...
src/lib/math/log.go
View file @
4331293f
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
log
package
math
import
sys
"sys"
export
log
,
log10
export
log
,
log10
/*
/*
...
@@ -37,7 +36,7 @@ log(arg double) double
...
@@ -37,7 +36,7 @@ log(arg double) double
var
exp
int
;
var
exp
int
;
if
arg
<=
0
{
if
arg
<=
0
{
return
sys
.
NaN
()
;
panic
"return sys.NaN()"
;
}
}
exp
,
x
=
sys
.
frexp
(
arg
);
exp
,
x
=
sys
.
frexp
(
arg
);
...
@@ -64,7 +63,7 @@ log10(arg double) double
...
@@ -64,7 +63,7 @@ log10(arg double) double
{
{
if
arg
<=
0
{
if
arg
<=
0
{
return
sys
.
NaN
()
;
panic
"return sys.NaN()"
;
}
}
return
log
(
arg
)
*
ln10o1
;
return
log
(
arg
)
*
ln10o1
;
}
}
src/lib/math/pow.go
View file @
4331293f
...
@@ -2,13 +2,12 @@
...
@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
pow
package
math
import
sys
"sys"
import
math
"floor"
import
floor
"floor"
import
math
"sqrt"
import
sqrt
"sqrt"
import
math
"log"
import
log
"log"
import
math
"exp"
import
exp
"exp"
export
pow
export
pow
/*
/*
...
@@ -27,14 +26,14 @@ pow(arg1,arg2 double) double
...
@@ -27,14 +26,14 @@ pow(arg1,arg2 double) double
if
arg1
<=
0
{
if
arg1
<=
0
{
if
(
arg1
==
0
)
{
if
(
arg1
==
0
)
{
if
arg2
<=
0
{
if
arg2
<=
0
{
return
sys
.
NaN
()
;
panic
"return sys.NaN()"
;
}
}
return
0
;
return
0
;
}
}
temp
=
floor
.
floor
(
arg2
);
temp
=
floor
(
arg2
);
if
temp
!=
arg2
{
if
temp
!=
arg2
{
return
sys
.
NaN
()
;
panic
"return sys.NaN()"
;
}
}
l
=
long
(
temp
);
l
=
long
(
temp
);
...
@@ -44,15 +43,15 @@ pow(arg1,arg2 double) double
...
@@ -44,15 +43,15 @@ pow(arg1,arg2 double) double
return
pow
(
-
arg1
,
arg2
);
return
pow
(
-
arg1
,
arg2
);
}
}
temp
=
floor
.
floor
(
arg2
);
temp
=
floor
(
arg2
);
if
temp
!=
arg2
{
if
temp
!=
arg2
{
if
arg2
-
temp
==
.5
{
if
arg2
-
temp
==
.5
{
if
temp
==
0
{
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
);
l
=
long
(
temp
);
...
...
src/lib/math/pow10.go
View file @
4331293f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
pow10
package
math
export
pow10
export
pow10
...
...
src/lib/math/sin.go
View file @
4331293f
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
sin
package
math
import
sys
"sys"
export
sin
,
cos
export
sin
,
cos
const
const
...
@@ -41,7 +40,7 @@ sinus(arg double, quad int) double
...
@@ -41,7 +40,7 @@ sinus(arg double, quad int) double
}
else
{
}
else
{
k
=
long
(
x
);
k
=
long
(
x
);
y
=
x
-
double
(
k
);
y
=
x
-
double
(
k
);
quad
=
(
quad
+
k
)
&
3
;
quad
=
(
quad
+
int
(
k
)
)
&
3
;
}
}
if
quad
&
1
!=
0
{
if
quad
&
1
!=
0
{
...
...
src/lib/math/sinh.go
View file @
4331293f
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
sin
h
package
mat
h
import
exp
"exp"
import
math
"exp"
export
sinh
,
cosh
export
sinh
,
cosh
/*
/*
...
@@ -45,10 +45,10 @@ sinh(arg double) double
...
@@ -45,10 +45,10 @@ sinh(arg double) double
}
}
switch
true
{
switch
true
{
case
arg
>
21
:
case
arg
>
21
:
temp
=
exp
.
exp
(
arg
)
/
2
;
temp
=
exp
(
arg
)
/
2
;
case
arg
>
0.5
:
case
arg
>
0.5
:
temp
=
(
exp
.
exp
(
arg
)
-
exp
.
exp
(
-
arg
))
/
2
;
// temp = (exp(arg) -
exp(-arg))/2;
default
:
default
:
argsq
=
arg
*
arg
;
argsq
=
arg
*
arg
;
...
@@ -69,7 +69,7 @@ cosh(arg double) double
...
@@ -69,7 +69,7 @@ cosh(arg double) double
arg
=
-
arg
;
arg
=
-
arg
;
}
}
if
arg
>
21
{
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;
}
}
src/lib/math/sqrt.go
View file @
4331293f
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
sqrt
package
math
import
sys
"sys"
export
sqrt
export
sqrt
/*
/*
...
@@ -20,13 +19,14 @@ sqrt(arg double) double
...
@@ -20,13 +19,14 @@ sqrt(arg double) double
var
x
,
temp
double
;
var
x
,
temp
double
;
var
exp
,
i
int
;
var
exp
,
i
int
;
/* BUG: NO isINF
if sys.isInf(arg, 1) {
if sys.isInf(arg, 1) {
return arg;
return arg;
}
}
*/
if
arg
<=
0
{
if
arg
<=
0
{
if
arg
<
0
{
if
arg
<
0
{
return
sys
.
NaN
();
panic
"return sys.NaN()"
}
}
return
0
;
return
0
;
}
}
...
...
src/lib/math/tan.go
View file @
4331293f
...
@@ -2,9 +2,8 @@
...
@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
tan
package
math
import
sys
"sys"
export
tan
export
tan
/*
/*
...
@@ -63,7 +62,7 @@ tan(arg double) double
...
@@ -63,7 +62,7 @@ tan(arg double) double
if
flag
{
if
flag
{
if
(
temp
==
0
)
{
if
(
temp
==
0
)
{
return
sys
.
NaN
()
;
panic
"return sys.NaN()"
;
}
}
temp
=
1
/
temp
;
temp
=
1
/
temp
;
}
}
...
...
src/lib/math/tanh.go
View file @
4331293f
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
tan
h
package
mat
h
import
sin
h
"sinh"
import
mat
h
"sinh"
export
tanh
export
tanh
/*
/*
...
@@ -23,10 +23,10 @@ tanh(arg double) double
...
@@ -23,10 +23,10 @@ tanh(arg double) double
if
arg
>
21
{
if
arg
>
21
{
return
-
1
;
return
-
1
;
}
}
return
-
sinh
.
sinh
(
arg
)
/
sinh
.
cosh
(
arg
);
return
-
sinh
(
arg
)
/
cosh
(
arg
);
}
}
if
arg
>
21
{
if
arg
>
21
{
return
1
;
return
1
;
}
}
return
sinh
.
sinh
(
arg
)
/
sinh
.
cosh
(
arg
);
return
sinh
(
arg
)
/
cosh
(
arg
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment