native,testlapack: fix docs and checks for correct size of T and W in Dlaqr2

This commit is contained in:
Vladimir Chalupecky
2016-08-18 23:00:44 +09:00
parent eef8e925c0
commit 30aa278560
2 changed files with 10 additions and 18 deletions

View File

@@ -48,14 +48,8 @@ import (
// sr and si must have length kbot+1, otherwise Dlaqr2 will panic.
//
// v and ldv represent an nw×nw work matrix.
//
// t and ldt represent an nw×nw work matrix T. nh is the number of columns of T
// available for workspace. It must hold that nh <= nw, otherwise Dlaqr2 will
// panic.
//
// wv and ldwv represent an nw×nw work matrix W. nv is the number of rows of W
// available for workspace. It must hold that nv <= nw, otherwise Dlaqr2 will
// panic.
// t and ldt represent an nw×nh work matrix, and nh must be at least nw.
// wv and ldwv represent an nv×nw work matrix.
//
// work must have length at least lwork and lwork must be at least max(1,2*nw),
// otherwise Dlaqr2 will panic. Larger values of lwork may result in greater
@@ -105,13 +99,11 @@ func (impl Implementation) Dlaqr2(wantt, wantz bool, n, ktop, kbot, nw int, h []
}
}
checkMatrix(nw, nw, v, ldv)
checkMatrix(nw, nw, t, ldt)
checkMatrix(nw, nw, wv, ldwv)
checkMatrix(nw, nh, t, ldt)
checkMatrix(nv, nw, wv, ldwv)
switch {
case nh > nw:
case nh < nw:
panic("lapack: invalid value of nh")
case nv > nw:
panic("lapack: invalid value of nv")
case len(sr) != kbot+1:
panic("lapack: bad length of sr")
case len(si) != kbot+1:

View File

@@ -232,27 +232,27 @@ func testDlaqr2(t *testing.T, impl Dlaqr2er, test dlaqr2Test, opt bool, rnd *ran
v := randomGeneral(nw, nw, nw+extra, rnd)
var nh int
if nw > 0 {
nh = rnd.Intn(nw) + 1
nh = nw + rnd.Intn(nw) // nh must be at least nw.
}
tmat := randomGeneral(nw, nw, nw+extra, rnd)
tmat := randomGeneral(nw, nh, nh+extra, rnd)
var nv int
if nw > 0 {
nv = rnd.Intn(nw) + 1
}
wv := randomGeneral(nw, nw, nw+extra, rnd)
wv := randomGeneral(nv, nw, nw+extra, rnd)
var work []float64
if opt {
work = nanSlice(1)
impl.Dlaqr2(wantt, wantz, n, ktop, kbot, nw, h.Data, h.Stride, iloz, ihiz, z.Data, z.Stride,
sr, si, v.Data, v.Stride, nh, tmat.Data, tmat.Stride, nv, wv.Data, wv.Stride, work, -1)
sr, si, v.Data, v.Stride, tmat.Cols, tmat.Data, tmat.Stride, wv.Rows, wv.Data, wv.Stride, work, -1)
work = nanSlice(int(work[0]))
} else {
work = nanSlice(max(1, 2*nw))
}
ns, nd := impl.Dlaqr2(wantt, wantz, n, ktop, kbot, nw, h.Data, h.Stride, iloz, ihiz, z.Data, z.Stride,
sr, si, v.Data, v.Stride, nh, tmat.Data, tmat.Stride, nv, wv.Data, wv.Stride, work, len(work))
sr, si, v.Data, v.Stride, tmat.Cols, tmat.Data, tmat.Stride, wv.Rows, wv.Data, wv.Stride, work, len(work))
prefix := fmt.Sprintf("Case wantt=%v, wantz=%v, n=%v, ktop=%v, kbot=%v, nw=%v, iloz=%v, ihiz=%v, extra=%v",
wantt, wantz, n, ktop, kbot, nw, iloz, ihiz, extra)