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
00e2cda6
Commit
00e2cda6
authored
Jan 12, 2010
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up and make consistent the comments in the math package.
R=rsc CC=golang-dev
https://golang.org/cl/186042
parent
093146b9
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
60 additions
and
64 deletions
+60
-64
src/pkg/math/asin.go
src/pkg/math/asin.go
+7
-7
src/pkg/math/atan.go
src/pkg/math/atan.go
+12
-21
src/pkg/math/fmod.go
src/pkg/math/fmod.go
+2
-2
src/pkg/math/hypot.go
src/pkg/math/hypot.go
+7
-6
src/pkg/math/log.go
src/pkg/math/log.go
+3
-0
src/pkg/math/pow10.go
src/pkg/math/pow10.go
+2
-9
src/pkg/math/sin.go
src/pkg/math/sin.go
+6
-1
src/pkg/math/sinh.go
src/pkg/math/sinh.go
+10
-10
src/pkg/math/sqrt_port.go
src/pkg/math/sqrt_port.go
+4
-0
src/pkg/math/tan.go
src/pkg/math/tan.go
+2
-2
src/pkg/math/tanh.go
src/pkg/math/tanh.go
+5
-6
No files found.
src/pkg/math/asin.go
View file @
00e2cda6
...
...
@@ -6,13 +6,13 @@ package math
/*
* asin(arg) and acos(arg) return the arcsin, arccos,
* respectively of their arguments.
*
* Arctan is called after appropriate range reduction.
*/
Floating-point sine and cosine.
// Asin returns the arc sine of x.
They are implemented by computing the arctangent
after appropriate range reduction.
*/
// Asin returns the arcsine of x.
func
Asin
(
x
float64
)
float64
{
sign
:=
false
if
x
<
0
{
...
...
@@ -36,5 +36,5 @@ func Asin(x float64) float64 {
return
temp
}
// Acos returns the arc
cosine of x.
// Acos returns the arccosine of x.
func
Acos
(
x
float64
)
float64
{
return
Pi
/
2
-
Asin
(
x
)
}
src/pkg/math/atan.go
View file @
00e2cda6
...
...
@@ -5,18 +5,16 @@
package
math
/*
* floating-point arctangent
*
* atan returns the value of the arctangent of its
* argument in the range [-pi/2,pi/2].
* there are no error returns.
* coefficients are #5077 from Hart & Cheney. (19.56D)
*/
Floating-point arctangent.
/*
* xatan evaluates a series valid in the
* range [-0.414...,+0.414...]. (tan(pi/8))
*/
Atan returns the value of the arctangent of its
argument in the range [-pi/2,pi/2].
There are no error returns.
Coefficients are #5077 from Hart & Cheney. (19.56D)
*/
// xatan evaluates a series valid in the
// range [-0.414...,+0.414...]. (tan(pi/8))
func
xatan
(
arg
float64
)
float64
{
const
(
P4
=
.161536412982230228262e2
...
...
@@ -36,10 +34,8 @@ func xatan(arg float64) float64 {
return
value
*
arg
}
/*
* satan reduces its argument (known to be positive)
* to the range [0,0.414...] and calls xatan.
*/
// satan reduces its argument (known to be positive)
// to the range [0,0.414...] and calls xatan.
func
satan
(
arg
float64
)
float64
{
if
arg
<
Sqrt2
-
1
{
return
xatan
(
arg
)
...
...
@@ -50,12 +46,7 @@ func satan(arg float64) float64 {
return
Pi
/
4
+
xatan
((
arg
-
1
)
/
(
arg
+
1
))
}
/*
* Atan makes its argument positive and
* calls the inner routine satan.
*/
// Atan returns the arc tangent of x.
// Atan returns the arctangent of x.
func
Atan
(
x
float64
)
float64
{
if
x
>
0
{
return
satan
(
x
)
...
...
src/pkg/math/fmod.go
View file @
00e2cda6
...
...
@@ -6,8 +6,8 @@ package math
/*
* f
loating-point mod func without infinity or NaN checking
*/
F
loating-point mod func without infinity or NaN checking
*/
// Fmod returns the floating-point remainder of x/y.
func
Fmod
(
x
,
y
float64
)
float64
{
...
...
src/pkg/math/hypot.go
View file @
00e2cda6
...
...
@@ -5,12 +5,13 @@
package
math
/*
* hypot -- sqrt(p*p + q*q), but overflows only if the result does.
* See Cleve Moler and Donald Morrison,
* Replacing Square Roots by Pythagorean Sums
* IBM Journal of Research and Development,
* Vol. 27, Number 6, pp. 577-581, Nov. 1983
*/
Hypot -- sqrt(p*p + q*q), but overflows only if the result does.
See:
Cleve Moler and Donald Morrison,
Replacing Square Roots by Pythagorean Sums
IBM Journal of Research and Development,
Vol. 27, Number 6, pp. 577-581, Nov. 1983
*/
// Hypot computes Sqrt(p*p + q*q), taking care to avoid
// unnecessary overflow and underflow.
...
...
src/pkg/math/log.go
View file @
00e2cda6
...
...
@@ -4,6 +4,9 @@
package
math
/*
Floating-point logarithm.
*/
// The original C code, the long comment, and the constants
// below are from FreeBSD's /usr/src/lib/msun/src/e_log.c
...
...
src/pkg/math/pow10.go
View file @
00e2cda6
...
...
@@ -4,15 +4,8 @@
package
math
/*
* this table might overflow 127-bit exponent representations.
* in that case, truncate it after 1.0e38.
* it is important to get all one can from this
* routine since it is used in atof to scale numbers.
* the presumption is that GO converts fp numbers better
* than multipication of lower powers of 10.
*/
// This table might overflow 127-bit exponent representations.
// In that case, truncate it after 1.0e38.
var
pow10tab
[
70
]
float64
// Pow10 returns 10**e, the base-10 exponential of e.
...
...
src/pkg/math/sin.go
View file @
00e2cda6
...
...
@@ -5,8 +5,13 @@
package
math
/*
Floating-point sine and cosine.
Coefficients are #5077 from Hart & Cheney. (18.80D)
*/
func
sinus
(
x
float64
,
quad
int
)
float64
{
// Coefficients are #3370 from Hart & Cheney (18.80D).
const
(
P0
=
.1357884097877375669092680e8
P1
=
-
.4942908100902844161158627e7
...
...
src/pkg/math/sinh.go
View file @
00e2cda6
...
...
@@ -6,16 +6,16 @@ package math
/*
* Sinh(x) returns the hyperbolic sine of x
*
*
The exponential func is called for arguments
*
greater in magnitude than 0.5.
*
*
A series is used for arguments smaller in magnitude than 0.5.
*
*
Cosh(x) is computed from the exponential func for
*
all arguments.
*/
Floating-point hyperbolic sine and cosine.
The exponential func is called for arguments
greater in magnitude than 0.5.
A series is used for arguments smaller in magnitude than 0.5.
Cosh(x) is computed from the exponential func for
all arguments.
*/
// Sinh returns the hyperbolic sine of x.
func
Sinh
(
x
float64
)
float64
{
...
...
src/pkg/math/sqrt_port.go
View file @
00e2cda6
...
...
@@ -4,6 +4,10 @@
package
math
/*
Floating-point square root.
*/
// The original C code and the long comment below are
// from FreeBSD's /usr/src/lib/msun/src/e_sqrt.c and
// came with this notice. The go code is a simplified
...
...
src/pkg/math/tan.go
View file @
00e2cda6
...
...
@@ -6,8 +6,8 @@ package math
/*
* floating point tangent
*/
Floating point tangent.
*/
// Tan returns the tangent of x.
func
Tan
(
x
float64
)
float64
{
...
...
src/pkg/math/tanh.go
View file @
00e2cda6
...
...
@@ -6,12 +6,11 @@ package math
/*
* tanh(x) computes the hyperbolic tangent of its floating
* point argument.
*
* sinh and cosh are called except for large arguments, which
* would cause overflow improperly.
*/
Floating-point hyperbolic tangent.
Sinh and Cosh are called except for large arguments, which
would cause overflow improperly.
*/
// Tanh computes the hyperbolic tangent of x.
func
Tanh
(
x
float64
)
float64
{
...
...
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