mirror of
https://github.com/golang/go
synced 2024-11-21 22:24:40 -07:00
Clean up and make consistent the comments in the math package.
R=rsc CC=golang-dev https://golang.org/cl/186042
This commit is contained in:
parent
093146b920
commit
00e2cda624
@ -6,13 +6,13 @@ package math
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* asin(arg) and acos(arg) return the arcsin, arccos,
|
Floating-point sine and cosine.
|
||||||
* respectively of their arguments.
|
|
||||||
*
|
|
||||||
* Arctan is called after appropriate range reduction.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 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 {
|
func Asin(x float64) float64 {
|
||||||
sign := false
|
sign := false
|
||||||
if x < 0 {
|
if x < 0 {
|
||||||
@ -36,5 +36,5 @@ func Asin(x float64) float64 {
|
|||||||
return temp
|
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) }
|
func Acos(x float64) float64 { return Pi/2 - Asin(x) }
|
||||||
|
@ -5,18 +5,16 @@
|
|||||||
package math
|
package math
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* floating-point arctangent
|
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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
Atan returns the value of the arctangent of its
|
||||||
* xatan evaluates a series valid in the
|
argument in the range [-pi/2,pi/2].
|
||||||
* range [-0.414...,+0.414...]. (tan(pi/8))
|
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 {
|
func xatan(arg float64) float64 {
|
||||||
const (
|
const (
|
||||||
P4 = .161536412982230228262e2
|
P4 = .161536412982230228262e2
|
||||||
@ -36,10 +34,8 @@ func xatan(arg float64) float64 {
|
|||||||
return value * arg
|
return value * arg
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// satan reduces its argument (known to be positive)
|
||||||
* satan reduces its argument (known to be positive)
|
// to the range [0,0.414...] and calls xatan.
|
||||||
* to the range [0,0.414...] and calls xatan.
|
|
||||||
*/
|
|
||||||
func satan(arg float64) float64 {
|
func satan(arg float64) float64 {
|
||||||
if arg < Sqrt2-1 {
|
if arg < Sqrt2-1 {
|
||||||
return xatan(arg)
|
return xatan(arg)
|
||||||
@ -50,12 +46,7 @@ func satan(arg float64) float64 {
|
|||||||
return Pi/4 + xatan((arg-1)/(arg+1))
|
return Pi/4 + xatan((arg-1)/(arg+1))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Atan returns the arctangent of x.
|
||||||
* Atan makes its argument positive and
|
|
||||||
* calls the inner routine satan.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Atan returns the arc tangent of x.
|
|
||||||
func Atan(x float64) float64 {
|
func Atan(x float64) float64 {
|
||||||
if x > 0 {
|
if x > 0 {
|
||||||
return satan(x)
|
return satan(x)
|
||||||
|
@ -6,8 +6,8 @@ package math
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* floating-point mod func without infinity or NaN checking
|
Floating-point mod func without infinity or NaN checking
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Fmod returns the floating-point remainder of x/y.
|
// Fmod returns the floating-point remainder of x/y.
|
||||||
func Fmod(x, y float64) float64 {
|
func Fmod(x, y float64) float64 {
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
package math
|
package math
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hypot -- sqrt(p*p + q*q), but overflows only if the result does.
|
Hypot -- sqrt(p*p + q*q), but overflows only if the result does.
|
||||||
* See Cleve Moler and Donald Morrison,
|
See:
|
||||||
* Replacing Square Roots by Pythagorean Sums
|
Cleve Moler and Donald Morrison,
|
||||||
* IBM Journal of Research and Development,
|
Replacing Square Roots by Pythagorean Sums
|
||||||
* Vol. 27, Number 6, pp. 577-581, Nov. 1983
|
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
|
// Hypot computes Sqrt(p*p + q*q), taking care to avoid
|
||||||
// unnecessary overflow and underflow.
|
// unnecessary overflow and underflow.
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
|
|
||||||
package math
|
package math
|
||||||
|
|
||||||
|
/*
|
||||||
|
Floating-point logarithm.
|
||||||
|
*/
|
||||||
|
|
||||||
// The original C code, the long comment, and the constants
|
// The original C code, the long comment, and the constants
|
||||||
// below are from FreeBSD's /usr/src/lib/msun/src/e_log.c
|
// below are from FreeBSD's /usr/src/lib/msun/src/e_log.c
|
||||||
|
@ -4,15 +4,8 @@
|
|||||||
|
|
||||||
package math
|
package math
|
||||||
|
|
||||||
/*
|
// This table might overflow 127-bit exponent representations.
|
||||||
* this table might overflow 127-bit exponent representations.
|
// In that case, truncate it after 1.0e38.
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var pow10tab [70]float64
|
var pow10tab [70]float64
|
||||||
|
|
||||||
// Pow10 returns 10**e, the base-10 exponential of e.
|
// Pow10 returns 10**e, the base-10 exponential of e.
|
||||||
|
@ -5,8 +5,13 @@
|
|||||||
package math
|
package math
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Floating-point sine and cosine.
|
||||||
|
|
||||||
|
Coefficients are #5077 from Hart & Cheney. (18.80D)
|
||||||
|
*/
|
||||||
|
|
||||||
func sinus(x float64, quad int) float64 {
|
func sinus(x float64, quad int) float64 {
|
||||||
// Coefficients are #3370 from Hart & Cheney (18.80D).
|
|
||||||
const (
|
const (
|
||||||
P0 = .1357884097877375669092680e8
|
P0 = .1357884097877375669092680e8
|
||||||
P1 = -.4942908100902844161158627e7
|
P1 = -.4942908100902844161158627e7
|
||||||
|
@ -6,16 +6,16 @@ package math
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sinh(x) returns the hyperbolic sine of x
|
Floating-point hyperbolic sine and cosine.
|
||||||
*
|
|
||||||
* The exponential func is called for arguments
|
The exponential func is called for arguments
|
||||||
* greater in magnitude than 0.5.
|
greater in magnitude than 0.5.
|
||||||
*
|
|
||||||
* A series is used for arguments smaller 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
|
Cosh(x) is computed from the exponential func for
|
||||||
* all arguments.
|
all arguments.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Sinh returns the hyperbolic sine of x.
|
// Sinh returns the hyperbolic sine of x.
|
||||||
func Sinh(x float64) float64 {
|
func Sinh(x float64) float64 {
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
package math
|
package math
|
||||||
|
|
||||||
|
/*
|
||||||
|
Floating-point square root.
|
||||||
|
*/
|
||||||
|
|
||||||
// The original C code and the long comment below are
|
// The original C code and the long comment below are
|
||||||
// from FreeBSD's /usr/src/lib/msun/src/e_sqrt.c and
|
// from FreeBSD's /usr/src/lib/msun/src/e_sqrt.c and
|
||||||
// came with this notice. The go code is a simplified
|
// came with this notice. The go code is a simplified
|
||||||
|
@ -6,8 +6,8 @@ package math
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* floating point tangent
|
Floating point tangent.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Tan returns the tangent of x.
|
// Tan returns the tangent of x.
|
||||||
func Tan(x float64) float64 {
|
func Tan(x float64) float64 {
|
||||||
|
@ -6,12 +6,11 @@ package math
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tanh(x) computes the hyperbolic tangent of its floating
|
Floating-point hyperbolic tangent.
|
||||||
* point argument.
|
|
||||||
*
|
Sinh and Cosh are called except for large arguments, which
|
||||||
* sinh and cosh are called except for large arguments, which
|
would cause overflow improperly.
|
||||||
* would cause overflow improperly.
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
// Tanh computes the hyperbolic tangent of x.
|
// Tanh computes the hyperbolic tangent of x.
|
||||||
func Tanh(x float64) float64 {
|
func Tanh(x float64) float64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user