gonum.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. //go:generate ./single_precision.bash
  5. package gonum
  6. import (
  7. "math"
  8. "gonum.org/v1/gonum/internal/math32"
  9. )
  10. type Implementation struct{}
  11. // [SD]gemm behavior constants. These are kept here to keep them out of the
  12. // way during single precision code genration.
  13. const (
  14. blockSize = 64 // b x b matrix
  15. minParBlock = 4 // minimum number of blocks needed to go parallel
  16. )
  17. func max(a, b int) int {
  18. if a > b {
  19. return a
  20. }
  21. return b
  22. }
  23. func min(a, b int) int {
  24. if a > b {
  25. return b
  26. }
  27. return a
  28. }
  29. // blocks returns the number of divisions of the dimension length with the given
  30. // block size.
  31. func blocks(dim, bsize int) int {
  32. return (dim + bsize - 1) / bsize
  33. }
  34. // dcabs1 returns |real(z)|+|imag(z)|.
  35. func dcabs1(z complex128) float64 {
  36. return math.Abs(real(z)) + math.Abs(imag(z))
  37. }
  38. // scabs1 returns |real(z)|+|imag(z)|.
  39. func scabs1(z complex64) float32 {
  40. return math32.Abs(real(z)) + math32.Abs(imag(z))
  41. }