sqrt.go 560 B

123456789101112131415161718192021222324
  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. // +build !amd64,!arm64 noasm appengine safe
  5. package math32
  6. import (
  7. "math"
  8. )
  9. // Sqrt returns the square root of x.
  10. //
  11. // Special cases are:
  12. // Sqrt(+Inf) = +Inf
  13. // Sqrt(±0) = ±0
  14. // Sqrt(x < 0) = NaN
  15. // Sqrt(NaN) = NaN
  16. func Sqrt(x float32) float32 {
  17. // FIXME(kortschak): Direct translation of the math package
  18. // asm code for 386 fails to build.
  19. return float32(math.Sqrt(float64(x)))
  20. }