isinf.go 706 B

12345678910111213141516171819202122232425
  1. // Copyright 2010 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Copyright ©2017 The Gonum Authors. All rights reserved.
  5. // Use of this source code is governed by a BSD-style
  6. // license that can be found in the LICENSE file.
  7. package cmplx64
  8. import math "gonum.org/v1/gonum/internal/math32"
  9. // IsInf returns true if either real(x) or imag(x) is an infinity.
  10. func IsInf(x complex64) bool {
  11. if math.IsInf(real(x), 0) || math.IsInf(imag(x), 0) {
  12. return true
  13. }
  14. return false
  15. }
  16. // Inf returns a complex infinity, complex(+Inf, +Inf).
  17. func Inf() complex64 {
  18. inf := math.Inf(1)
  19. return complex(inf, inf)
  20. }