github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/num/quat/nan.go (about) 1 // Copyright ©2018 The Gonum 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 Go 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 quat 10 11 import "math" 12 13 // IsNaN returns true if any of real(q), imag(q), jmag(q), or kmag(q) is NaN 14 // and none are an infinity. 15 func IsNaN(q Number) bool { 16 if math.IsInf(q.Real, 0) || math.IsInf(q.Imag, 0) || math.IsInf(q.Jmag, 0) || math.IsInf(q.Kmag, 0) { 17 return false 18 } 19 return math.IsNaN(q.Real) || math.IsNaN(q.Imag) || math.IsNaN(q.Jmag) || math.IsNaN(q.Kmag) 20 } 21 22 // NaN returns a quaternion ``not-a-number'' value. 23 func NaN() Number { 24 nan := math.NaN() 25 return Number{Real: nan, Imag: nan, Jmag: nan, Kmag: nan} 26 }