gonum.org/v1/gonum@v0.14.0/internal/cmplx64/isnan.go (about) 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 5 // Copyright ©2017 The Gonum Authors. All rights reserved. 6 // Use of this source code is governed by a BSD-style 7 // license that can be found in the LICENSE file. 8 9 package cmplx64 10 11 import math "gonum.org/v1/gonum/internal/math32" 12 13 // IsNaN returns true if either real(x) or imag(x) is NaN 14 // and neither is an infinity. 15 func IsNaN(x complex64) bool { 16 switch { 17 case math.IsInf(real(x), 0) || math.IsInf(imag(x), 0): 18 return false 19 case math.IsNaN(real(x)) || math.IsNaN(imag(x)): 20 return true 21 } 22 return false 23 } 24 25 // NaN returns a complex “not-a-number” value. 26 func NaN() complex64 { 27 nan := math.NaN() 28 return complex(nan, nan) 29 }