blas/gonum: fix bad bound on column index in Dgbmv
MODIFY
blas/gonum/level2double.go
blas/gonum/level2double.go
@@ -257,14 +257,13 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64,
// i and j are indices of the compacted banded matrix.
// off is the offset into the dense matrix (off + j = densej)
- ld := min(m, n)
nCol := kU + 1 + kL
if tA == blas.NoTrans {
iy := ky
if incX == 1 {
for i := 0; i < min(m, n+kL); i++ {
l := max(0, kL-i)
- u := min(nCol, ld+kL-i)
+ u := min(nCol, n+kL-i)
off := max(0, i-kL)
atmp := a[i*lda+l : i*lda+u]
xtmp := x[off : off+u-l]
@@ -279,7 +278,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64,
}
for i := 0; i < min(m, n+kL); i++ {
l := max(0, kL-i)
- u := min(nCol, ld+kL-i)
+ u := min(nCol, n+kL-i)
off := max(0, i-kL)
atmp := a[i*lda+l : i*lda+u]
jx := kx
@@ -296,7 +295,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64,
if incX == 1 {
for i := 0; i < min(m, n+kL); i++ {
l := max(0, kL-i)
- u := min(nCol, ld+kL-i)
+ u := min(nCol, n+kL-i)
off := max(0, i-kL)
atmp := a[i*lda+l : i*lda+u]
tmp := alpha * x[i]
@@ -311,7 +310,7 @@ func (Implementation) Dgbmv(tA blas.Transpose, m, n, kL, kU int, alpha float64,
ix := kx
for i := 0; i < min(m, n+kL); i++ {
l := max(0, kL-i)
- u := min(nCol, ld+kL-i)
+ u := min(nCol, n+kL-i)
off := max(0, i-kL)
atmp := a[i*lda+l : i*lda+u]
tmp := alpha * x[ix]

MODIFY
blas/testblas/dgbmv.go
blas/testblas/dgbmv.go
@@ -108,6 +108,24 @@ func DgbmvTest(t *testing.T, blasser Dgbmver) {
y: []float64{-1, -2, -3},
ans: []float64{1, 2, 3},
},
+ {
+ tA: blas.NoTrans,
+ m: 3,
+ n: 5,
+ lda: 4,
+ kL: 1,
+ kU: 2,
+ alpha: 2.0,
+ beta: 1.0,
+ a: [][]float64{
+ {1, 2, 3, 0, 0},
+ {1, 3, 6, 9, 0},
+ {0, 1, 1, 1, 1},
+ },
+ x: []float64{1, 2, 3, 4, 5},
+ y: []float64{-1, -2, -3},
+ ans: []float64{-1 + 2*(1+4+9), -2 + 2*(1+6+18+36), -3 + 2*(2+3+4+5)},
+ },
} {
extra := 3
aFlat := flattenBanded(test.a, test.kU, test.kL)

blas/gonum: fix bad bound on column index in Dgbmv