diff options
author | Charles L. Dorian <cldorian@gmail.com> | 2010-05-15 10:06:54 -0700 |
---|---|---|
committer | Charles L. Dorian <cldorian@gmail.com> | 2010-05-15 10:06:54 -0700 |
commit | dd64b918b4b0fe2ee95ffd71855afb502f2e5067 (patch) | |
tree | 94fa8c36f6ca15ed84199058757ddb57d1051590 | |
parent | 2de77de2f85073fe8b46ff6d3adac2f537da7d9b (diff) | |
download | golang-dd64b918b4b0fe2ee95ffd71855afb502f2e5067.tar.gz |
cmath: add package description
Also update range of Phase and Polar due to signed zero.
[Phase(cmplx(-1, +0)) = pi and Phase(cmplx(-1, -0)) = -pi]
R=rsc, r
CC=golang-dev
http://codereview.appspot.com/1235041
Committer: Rob Pike <r@golang.org>
-rw-r--r-- | src/pkg/cmath/abs.go | 2 | ||||
-rw-r--r-- | src/pkg/cmath/phase.go | 2 | ||||
-rw-r--r-- | src/pkg/cmath/polar.go | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/src/pkg/cmath/abs.go b/src/pkg/cmath/abs.go index 30995cec6..725dc4e98 100644 --- a/src/pkg/cmath/abs.go +++ b/src/pkg/cmath/abs.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// The cmath package provides basic constants +// and mathematical functions for complex numbers. package cmath import "math" diff --git a/src/pkg/cmath/phase.go b/src/pkg/cmath/phase.go index 97a483492..2d67aa34c 100644 --- a/src/pkg/cmath/phase.go +++ b/src/pkg/cmath/phase.go @@ -7,5 +7,5 @@ package cmath import "math" // Phase returns the phase (also called the argument) of x. -// The returned value is in the range (-Pi, Pi]. +// The returned value is in the range [-Pi, Pi]. func Phase(x complex128) float64 { return math.Atan2(imag(x), real(x)) } diff --git a/src/pkg/cmath/polar.go b/src/pkg/cmath/polar.go index f55aef42b..033676acc 100644 --- a/src/pkg/cmath/polar.go +++ b/src/pkg/cmath/polar.go @@ -6,7 +6,7 @@ package cmath // Polar returns the absolute value r and phase θ of x, // such that x = r * e**θi. -// The phase is in the range (-Pi, Pi]. +// The phase is in the range [-Pi, Pi]. func Polar(x complex128) (r, θ float64) { return Abs(x), Phase(x) } |