~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/math/cmplx/pow.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
//    IEEE      -10,+10     30000       9.4e-15     1.5e-15
44
44
 
45
45
// Pow returns x**y, the base-x exponential of y.
 
46
// For generalized compatibility with math.Pow:
 
47
//      Pow(0, ±0) returns 1+0i
 
48
//      Pow(0, c) for real(c)<0 returns Inf+0i if imag(c) is zero, otherwise Inf+Inf i.
46
49
func Pow(x, y complex128) complex128 {
 
50
        if x == 0 { // Guaranteed also true for x == -0.
 
51
                r, i := real(y), imag(y)
 
52
                switch {
 
53
                case r == 0:
 
54
                        return 1
 
55
                case r < 0:
 
56
                        if i == 0 {
 
57
                                return complex(math.Inf(1), 0)
 
58
                        }
 
59
                        return Inf()
 
60
                case r > 0:
 
61
                        return 0
 
62
                }
 
63
                panic("not reached")
 
64
        }
47
65
        modulus := Abs(x)
48
66
        if modulus == 0 {
49
67
                return complex(0, 0)