native,cgo: change type of compq in Dtrexc from lapack.EigComp to lapack.Comp

This commit is contained in:
Vladimir Chalupecky
2016-10-05 23:14:05 +09:00
parent 87c360a6b8
commit fd57e99f9e
4 changed files with 27 additions and 25 deletions

View File

@@ -1483,10 +1483,11 @@ func (impl Implementation) Dtrcon(norm lapack.MatrixNorm, uplo blas.Uplo, diag b
// On return, T will be reordered by an orthogonal similarity transformation Z
// as Z^T*T*Z, and will be again in Schur canonical form.
//
// If compq is lapack.EigDecomp, on return the matrix Q of Schur vectors will be
// updated by postmultiplying it with Z. If compq is lapack.EigValueOnly, the
// matrix Q is not referenced and will not be updated. For other values of compq
// Dtrexc will panic.
// If compq is lapack.UpdateQ, on return the matrix Q of Schur vectors will be
// updated by postmultiplying it with Z.
// If compq is lapack.None, the matrix Q is not referenced and will not be
// updated.
// For other values of compq Dtrexc will panic.
//
// ifst and ilst specify the reordering of the diagonal blocks of T. The block
// with row index ifst is moved to row ilst, by a sequence of transpositions
@@ -1510,16 +1511,16 @@ func (impl Implementation) Dtrcon(norm lapack.MatrixNorm, uplo blas.Uplo, diag b
// work must have length at least n, otherwise Dtrexc will panic.
//
// Dtrexc is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dtrexc(compq lapack.EigComp, n int, t []float64, ldt int, q []float64, ldq int, ifst, ilst int, work []float64) (ifstOut, ilstOut int, ok bool) {
func (impl Implementation) Dtrexc(compq lapack.Comp, n int, t []float64, ldt int, q []float64, ldq int, ifst, ilst int, work []float64) (ifstOut, ilstOut int, ok bool) {
checkMatrix(n, n, t, ldt)
switch compq {
default:
panic(badEigComp)
case lapack.EigValueOnly:
panic("lapack: bad value of compq")
case lapack.None:
// q is not referenced but LAPACKE checks that ldq >= n always.
q = nil
ldq = max(1, n)
case lapack.EigDecomp:
case lapack.UpdateQ:
checkMatrix(n, n, q, ldq)
}
if (ifst < 0 || n <= ifst) && n > 0 {
@@ -1539,7 +1540,7 @@ func (impl Implementation) Dtrexc(compq lapack.EigComp, n int, t []float64, ldt
ifst32 := []int32{int32(ifst + 1)}
ilst32 := []int32{int32(ilst + 1)}
ok = lapacke.Dtrexc(lapack.Comp(compq), n, t, ldt, q, ldq, ifst32, ilst32, work)
ok = lapacke.Dtrexc(compq, n, t, ldt, q, ldq, ifst32, ilst32, work)
ifst = int(ifst32[0] - 1)
ilst = int(ilst32[0] - 1)
return ifst, ilst, ok

View File

@@ -234,7 +234,7 @@ func (impl Implementation) Dlaqr23(wantt, wantz bool, n, ktop, kbot, nw int, h [
} else {
// Undeflatable, move it up out of the way.
// Dtrexc can not fail in this case.
_, ilst, _ = impl.Dtrexc(lapack.EigDecomp, jw, t, ldt, v, ldv, ns-1, ilst, work)
_, ilst, _ = impl.Dtrexc(lapack.UpdateQ, jw, t, ldt, v, ldv, ns-1, ilst, work)
ilst++
}
continue
@@ -251,7 +251,7 @@ func (impl Implementation) Dlaqr23(wantt, wantz bool, n, ktop, kbot, nw int, h [
// Undeflatable, move them up out of the way.
// Dtrexc does the right thing with ilst in case of a
// rare exchange failure.
_, ilst, _ = impl.Dtrexc(lapack.EigDecomp, jw, t, ldt, v, ldv, ns-1, ilst, work)
_, ilst, _ = impl.Dtrexc(lapack.UpdateQ, jw, t, ldt, v, ldv, ns-1, ilst, work)
ilst += 2
}
}
@@ -294,7 +294,7 @@ func (impl Implementation) Dlaqr23(wantt, wantz bool, n, ktop, kbot, nw int, h [
i = k
} else {
sorted = false
_, ilst, ok := impl.Dtrexc(lapack.EigDecomp, jw, t, ldt, v, ldv, i, k, work)
_, ilst, ok := impl.Dtrexc(lapack.UpdateQ, jw, t, ldt, v, ldv, i, k, work)
if ok {
i = ilst
} else {

View File

@@ -17,10 +17,11 @@ import "github.com/gonum/lapack"
// On return, T will be reordered by an orthogonal similarity transformation Z
// as Z^T*T*Z, and will be again in Schur canonical form.
//
// If compq is lapack.EigDecomp, on return the matrix Q of Schur vectors will be
// updated by postmultiplying it with Z. If compq is lapack.EigValueOnly, the
// matrix Q is not referenced and will not be updated. For other values of compq
// Dtrexc will panic.
// If compq is lapack.UpdateQ, on return the matrix Q of Schur vectors will be
// updated by postmultiplying it with Z.
// If compq is lapack.None, the matrix Q is not referenced and will not be
// updated.
// For other values of compq Dtrexc will panic.
//
// ifst and ilst specify the reordering of the diagonal blocks of T. The block
// with row index ifst is moved to row ilst, by a sequence of transpositions
@@ -44,15 +45,15 @@ import "github.com/gonum/lapack"
// work must have length at least n, otherwise Dtrexc will panic.
//
// Dtrexc is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dtrexc(compq lapack.EigComp, n int, t []float64, ldt int, q []float64, ldq int, ifst, ilst int, work []float64) (ifstOut, ilstOut int, ok bool) {
func (impl Implementation) Dtrexc(compq lapack.Comp, n int, t []float64, ldt int, q []float64, ldq int, ifst, ilst int, work []float64) (ifstOut, ilstOut int, ok bool) {
checkMatrix(n, n, t, ldt)
var wantq bool
switch compq {
default:
panic(badEigComp)
case lapack.EigValueOnly:
panic("lapack: bad value of compq")
case lapack.None:
// Nothing to do because wantq is already false.
case lapack.EigDecomp:
case lapack.UpdateQ:
wantq = true
checkMatrix(n, n, q, ldq)
}

View File

@@ -16,13 +16,13 @@ import (
)
type Dtrexcer interface {
Dtrexc(compq lapack.EigComp, n int, t []float64, ldt int, q []float64, ldq int, ifst, ilst int, work []float64) (ifstOut, ilstOut int, ok bool)
Dtrexc(compq lapack.Comp, n int, t []float64, ldt int, q []float64, ldq int, ifst, ilst int, work []float64) (ifstOut, ilstOut int, ok bool)
}
func DtrexcTest(t *testing.T, impl Dtrexcer) {
rnd := rand.New(rand.NewSource(1))
for _, compq := range []lapack.EigComp{lapack.EigValueOnly, lapack.EigDecomp} {
for _, compq := range []lapack.Comp{lapack.None, lapack.UpdateQ} {
for _, n := range []int{1, 2, 3, 4, 5, 6, 10, 18, 31, 53} {
for _, extra := range []int{0, 1, 11} {
for cas := 0; cas < 100; cas++ {
@@ -35,7 +35,7 @@ func DtrexcTest(t *testing.T, impl Dtrexcer) {
}
}
for _, compq := range []lapack.EigComp{lapack.EigValueOnly, lapack.EigDecomp} {
for _, compq := range []lapack.Comp{lapack.None, lapack.UpdateQ} {
for _, extra := range []int{0, 1, 11} {
tmat := randomSchurCanonical(0, extra, rnd)
testDtrexc(t, impl, compq, tmat, 0, 0, extra, rnd)
@@ -43,7 +43,7 @@ func DtrexcTest(t *testing.T, impl Dtrexcer) {
}
}
func testDtrexc(t *testing.T, impl Dtrexcer, compq lapack.EigComp, tmat blas64.General, ifst, ilst, extra int, rnd *rand.Rand) {
func testDtrexc(t *testing.T, impl Dtrexcer, compq lapack.Comp, tmat blas64.General, ifst, ilst, extra int, rnd *rand.Rand) {
const tol = 1e-13
n := tmat.Rows
@@ -54,7 +54,7 @@ func testDtrexc(t *testing.T, impl Dtrexcer, compq lapack.EigComp, tmat blas64.G
var wantq bool
var q, qCopy blas64.General
if compq == lapack.EigDecomp {
if compq == lapack.UpdateQ {
wantq = true
q = eye(n, n+extra)
qCopy = cloneGeneral(q)