github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/internal/math32/sqrt.go (about) 1 // Copyright ©2015 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 // +build !amd64,!arm64 noasm gccgo safe 6 7 package math32 8 9 import ( 10 "math" 11 ) 12 13 // Sqrt returns the square root of x. 14 // 15 // Special cases are: 16 // Sqrt(+Inf) = +Inf 17 // Sqrt(±0) = ±0 18 // Sqrt(x < 0) = NaN 19 // Sqrt(NaN) = NaN 20 func Sqrt(x float32) float32 { 21 // FIXME(kortschak): Direct translation of the math package 22 // asm code for 386 fails to build. 23 return float32(math.Sqrt(float64(x))) 24 }