mirror of
https://github.com/golang/go
synced 2024-11-20 04:44:40 -07:00
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 https://golang.org/cl/1235041
This commit is contained in:
parent
31f79690f7
commit
1d4e2d1adc
@ -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"
|
||||
|
@ -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)) }
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user