blas/gonum: remove checkDMatrix helper
MODIFY
blas/gonum/gonum.go
blas/gonum/gonum.go
@@ -37,36 +37,6 @@ func min(a, b int) int {
return a
}
-func checkSMatrix(name byte, m, n int, a []float32, lda int) {
- if m < 0 {
- panic(mLT0)
- }
- if n < 0 {
- panic(nLT0)
- }
- if lda < n {
- panic("blas: illegal stride of " + string(name))
- }
- if len(a) < (m-1)*lda+n {
- panic("blas: index of " + string(name) + " out of range")
- }
-}
-
-func checkDMatrix(name byte, m, n int, a []float64, lda int) {
- if m < 0 {
- panic(mLT0)
- }
- if n < 0 {
- panic(nLT0)
- }
- if lda < n {
- panic("blas: illegal stride of " + string(name))
- }
- if len(a) < (m-1)*lda+n {
- panic("blas: index of " + string(name) + " out of range")
- }
-}
-
func checkZMatrix(name byte, m, n int, a []complex128, lda int) {
if m < 0 {
panic(mLT0)

MODIFY
blas/gonum/level2single.go
blas/gonum/level2single.go
@@ -19,7 +19,6 @@ var _ blas.Float32Level2 = Implementation{}
//
// Float32 implementations are autogenerated and not directly tested.
func (Implementation) Sger(m, n int, alpha float32, x []float32, incX int, y []float32, incY int, a []float32, lda int) {
- // Check inputs
if m < 0 {
panic(mLT0)
}
@@ -532,7 +531,6 @@ func (Implementation) Strsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int,
//
// Float32 implementations are autogenerated and not directly tested.
func (Implementation) Ssymv(ul blas.Uplo, n int, alpha float32, a []float32, lda int, x []float32, incX int, beta float32, y []float32, incY int) {
- // Check inputs
if ul != blas.Lower && ul != blas.Upper {
panic(badUplo)
}

MODIFY
blas/gonum/sgemm.go
blas/gonum/sgemm.go
@@ -25,25 +25,75 @@ import (
//
// Float32 implementations are autogenerated and not directly tested.
func (Implementation) Sgemm(tA, tB blas.Transpose, m, n, k int, alpha float32, a []float32, lda int, b []float32, ldb int, beta float32, c []float32, ldc int) {
- if tA != blas.NoTrans && tA != blas.Trans && tA != blas.ConjTrans {
+ switch tA {
+ default:
panic(badTranspose)
+ case blas.NoTrans, blas.Trans, blas.ConjTrans:
}
- if tB != blas.NoTrans && tB != blas.Trans && tB != blas.ConjTrans {
+ switch tB {
+ default:
panic(badTranspose)
+ case blas.NoTrans, blas.Trans, blas.ConjTrans:
+ }
+ if m < 0 {
+ panic(mLT0)
+ }
+ if n < 0 {
+ panic(nLT0)
+ }
+ if k < 0 {
+ panic(kLT0)
}
aTrans := tA == blas.Trans || tA == blas.ConjTrans
if aTrans {
- checkSMatrix('a', k, m, a, lda)
+ if lda < max(1, m) {
+ panic(badLdA)
+ }
} else {
- checkSMatrix('a', m, k, a, lda)
+ if lda < max(1, k) {
+ panic(badLdA)
+ }
}
bTrans := tB == blas.Trans || tB == blas.ConjTrans
if bTrans {
- checkSMatrix('b', n, k, b, ldb)
+ if ldb < max(1, k) {
+ panic(badLdB)
+ }
} else {
- checkSMatrix('b', k, n, b, ldb)
+ if ldb < max(1, n) {
+ panic(badLdB)
+ }
+ }
+ if ldc < max(1, n) {
+ panic(badLdC)
+ }
+
+ // Quick return if possible.
+ if m == 0 || n == 0 || ((alpha == 0 || k == 0) && beta == 1) {
+ return
+ }
+
+ if aTrans {
+ if len(a) < (k-1)*lda+m {
+ panic(shortA)
+ }
+ } else {
+ if len(a) < (m-1)*lda+k {
+ panic(shortA)
+ }
+ }
+ if bTrans {
+ if len(b) < (n-1)*ldb+k {
+ panic(shortB)
+ }
+ } else {
+ if len(b) < (k-1)*ldb+n {
+ panic(shortB)
+ }
+ }
+ if len(c) < (m-1)*ldc+n {
+ panic(shortC)
}
- checkSMatrix('c', m, n, c, ldc)
// scale c
if beta != 1 {

blas/gonum: remove checkDMatrix helper