lapack/testlapack: use worklen type in DgetriTest

... and make worklen type a Stringer.
This commit is contained in:
Vladimir Chalupecky
2019-01-22 16:23:13 +01:00
committed by Vladimír Chalupecký
parent 0662aa10a9
commit 85a94c5204
2 changed files with 17 additions and 8 deletions

View File

@@ -57,22 +57,19 @@ func DgetriTest(t *testing.T, impl Dgetrier) {
// Compute LU decomposition.
impl.Dgetrf(n, n, a, lda, ipiv)
// Test with various workspace sizes.
for size := range []int{0, 1, 2} {
for _, wl := range []worklen{minimumWork, mediumWork, optimumWork} {
ainv := make([]float64, len(a))
copy(ainv, a)
var lwork int
switch size {
case 0:
// Minimum workspace size.
switch wl {
case minimumWork:
lwork = max(1, n)
case 1:
// Medium workspace size.
case mediumWork:
work := make([]float64, 1)
impl.Dgetri(n, ainv, lda, ipiv, work, -1)
lwork = max(int(work[0])-2*n, n)
case 2:
// Optimum workspace size.
case optimumWork:
work := make([]float64, 1)
impl.Dgetri(n, ainv, lda, ipiv, work, -1)
lwork = int(work[0])

View File

@@ -50,6 +50,18 @@ const (
optimumWork
)
func (wl worklen) String() string {
switch wl {
case minimumWork:
return "minimum"
case mediumWork:
return "medium"
case optimumWork:
return "optimum"
}
return ""
}
// nanSlice allocates a new slice of length n filled with NaN.
func nanSlice(n int) []float64 {
s := make([]float64, n)