lapack/gonum: clean up parameter checks in Dgehrd
@@ -67,21 +67,19 @@ import (
// Dgehrd is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dgehrd(n, ilo, ihi int, a []float64, lda int, tau, work []float64, lwork int) {
switch {
+ case n < 0:
+ panic(nLT0)
case ilo < 0 || max(0, n-1) < ilo:
panic(badIlo)
case ihi < min(ilo, n-1) || n <= ihi:
panic(badIhi)
+ case lda < max(1, n):
+ panic(badLdA)
case lwork < max(1, n) && lwork != -1:
panic(badWork)
case len(work) < lwork:
panic(shortWork)
}
- if lwork != -1 {
- checkMatrix(n, n, a, lda)
- if len(tau) != n-1 && n > 0 {
- panic(badTau)
- }
- }
const (
nbmax = 64
@@ -96,6 +94,13 @@ func (impl Implementation) Dgehrd(n, ilo, ihi int, a []float64, lda int, tau, wo
return
}
+ if len(a) < (n-1)*lda+n {
+ panic("lapack: insufficient length of a")
+ }
+ if len(tau) != n-1 && n > 0 {
+ panic(badTau)
+ }
+
// Set tau[:ilo] and tau[ihi:] to zero.
for i := 0; i < ilo; i++ {
tau[i] = 0
