lapack,native,cgo: remove lapack.UpdateZ and rename lapack.InitZ to lapack.HessEV

This commit is contained in:
Vladimir Chalupecky
2016-10-08 23:42:03 +09:00
parent 0c9ab78926
commit fd435a9071
5 changed files with 20 additions and 20 deletions

View File

@@ -1739,9 +1739,9 @@ func (impl Implementation) Dtrtrs(uplo blas.Uplo, trans blas.Transpose, diag bla
// //
// If compz == lapack.None, no Schur vectors will be computed and Z will not be // If compz == lapack.None, no Schur vectors will be computed and Z will not be
// referenced. // referenced.
// If compz == lapack.InitZ, on return Z will contain the matrix of Schur // If compz == lapack.HessEV, on return Z will contain the matrix of Schur
// vectors of H. // vectors of H.
// If compz == lapack.UpdateZ, on entry z is assumed to contain the orthogonal // If compz == lapack.OriginalEV, on entry z is assumed to contain the orthogonal
// matrix Q that is the identity except for the submatrix // matrix Q that is the identity except for the submatrix
// Q[ilo:ihi+1,ilo:ihi+1]. On return z will be updated to the product Q*Z. // Q[ilo:ihi+1,ilo:ihi+1]. On return z will be updated to the product Q*Z.
// //
@@ -1806,7 +1806,7 @@ func (impl Implementation) Dtrtrs(uplo blas.Uplo, trans blas.Transpose, diag bla
// where U is an orthogonal matrix. The final H is upper Hessenberg and // where U is an orthogonal matrix. The final H is upper Hessenberg and
// H[unconverged:ihi+1,unconverged:ihi+1] is upper quasi-triangular. // H[unconverged:ihi+1,unconverged:ihi+1] is upper quasi-triangular.
// //
// If unconverged > 0 and compz == lapack.UpdateZ, then on return // If unconverged > 0 and compz == lapack.OriginalEV, then on return
// (final Z) = (initial Z) U, // (final Z) = (initial Z) U,
// where U is the orthogonal matrix in (*) regardless of the value of job. // where U is the orthogonal matrix in (*) regardless of the value of job.
// //
@@ -1839,7 +1839,7 @@ func (impl Implementation) Dhseqr(job lapack.EVJob, compz lapack.EVComp, n, ilo,
default: default:
panic(badEVComp) panic(badEVComp)
case lapack.None: case lapack.None:
case lapack.InitZ, lapack.UpdateZ: case lapack.HessEV, lapack.OriginalEV:
wantz = true wantz = true
} }
switch { switch {

View File

@@ -118,6 +118,9 @@ const (
// TridiagEV specifies to compute both the eigenvectors of the input // TridiagEV specifies to compute both the eigenvectors of the input
// tridiagonal matrix. // tridiagonal matrix.
TridiagEV EVComp = 'I' TridiagEV EVComp = 'I'
// HessEV specifies to compute both the eigenvectors of the input upper
// Hessenberg matrix.
HessEV EVComp = 'I'
) )
// Job types for computation of eigenvectors. // Job types for computation of eigenvectors.
@@ -141,13 +144,10 @@ const (
PermuteScale Job = 'B' PermuteScale Job = 'B'
) )
// Jobs and Comps for Dhseqr. // Job constants for Dhseqr.
const ( const (
EigenvaluesOnly EVJob = 'E' EigenvaluesOnly EVJob = 'E'
EigenvaluesAndSchur EVJob = 'S' EigenvaluesAndSchur EVJob = 'S'
InitZ EVComp = 'I'
UpdateZ EVComp = 'V'
) )
// UpdateQ specifies that the matrix Q will be updated. // UpdateQ specifies that the matrix Q will be updated.

View File

@@ -115,7 +115,7 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
maxwrk := 2*n + n*impl.Ilaenv(1, "DGEHRD", " ", n, 1, n, 0) maxwrk := 2*n + n*impl.Ilaenv(1, "DGEHRD", " ", n, 1, n, 0)
if wantvl || wantvr { if wantvl || wantvr {
maxwrk = max(maxwrk, 2*n+(n-1)*impl.Ilaenv(1, "DORGHR", " ", n, 1, n, -1)) maxwrk = max(maxwrk, 2*n+(n-1)*impl.Ilaenv(1, "DORGHR", " ", n, 1, n, -1))
impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.UpdateZ, n, 0, n-1, impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.OriginalEV, n, 0, n-1,
nil, 1, nil, nil, nil, 1, work, -1) nil, 1, nil, nil, nil, 1, work, -1)
maxwrk = max(maxwrk, max(n+1, n+int(work[0]))) maxwrk = max(maxwrk, max(n+1, n+int(work[0])))
side := lapack.LeftEV side := lapack.LeftEV
@@ -175,7 +175,7 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
impl.Dorghr(n, ilo, ihi, vl, ldvl, tau, work[iwrk:], lwork-iwrk) impl.Dorghr(n, ilo, ihi, vl, ldvl, tau, work[iwrk:], lwork-iwrk)
// Perform QR iteration, accumulating Schur vectors in VL. // Perform QR iteration, accumulating Schur vectors in VL.
iwrk = n iwrk = n
first = impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.UpdateZ, n, ilo, ihi, first = impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.OriginalEV, n, ilo, ihi,
a, lda, wr, wi, vl, ldvl, work[iwrk:], lwork-iwrk) a, lda, wr, wi, vl, ldvl, work[iwrk:], lwork-iwrk)
if wantvr { if wantvr {
// Want left and right eigenvectors. // Want left and right eigenvectors.
@@ -191,7 +191,7 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
impl.Dorghr(n, ilo, ihi, vr, ldvr, tau, work[iwrk:], lwork-iwrk) impl.Dorghr(n, ilo, ihi, vr, ldvr, tau, work[iwrk:], lwork-iwrk)
// Perform QR iteration, accumulating Schur vectors in VR. // Perform QR iteration, accumulating Schur vectors in VR.
iwrk = n iwrk = n
first = impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.UpdateZ, n, ilo, ihi, first = impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.OriginalEV, n, ilo, ihi,
a, lda, wr, wi, vr, ldvr, work[iwrk:], lwork-iwrk) a, lda, wr, wi, vr, ldvr, work[iwrk:], lwork-iwrk)
} else { } else {
// Compute eigenvalues only. // Compute eigenvalues only.

View File

@@ -29,9 +29,9 @@ import (
// //
// If compz == lapack.None, no Schur vectors will be computed and Z will not be // If compz == lapack.None, no Schur vectors will be computed and Z will not be
// referenced. // referenced.
// If compz == lapack.InitZ, on return Z will contain the matrix of Schur // If compz == lapack.HessEV, on return Z will contain the matrix of Schur
// vectors of H. // vectors of H.
// If compz == lapack.UpdateZ, on entry z is assumed to contain the orthogonal // If compz == lapack.OriginalEV, on entry z is assumed to contain the orthogonal
// matrix Q that is the identity except for the submatrix // matrix Q that is the identity except for the submatrix
// Q[ilo:ihi+1,ilo:ihi+1]. On return z will be updated to the product Q*Z. // Q[ilo:ihi+1,ilo:ihi+1]. On return z will be updated to the product Q*Z.
// //
@@ -96,11 +96,11 @@ import (
// where U is an orthogonal matrix. The final H is upper Hessenberg and // where U is an orthogonal matrix. The final H is upper Hessenberg and
// H[unconverged:ihi+1,unconverged:ihi+1] is upper quasi-triangular. // H[unconverged:ihi+1,unconverged:ihi+1] is upper quasi-triangular.
// //
// If unconverged > 0 and compz == lapack.UpdateZ, then on return // If unconverged > 0 and compz == lapack.OriginalEV, then on return
// (final Z) = (initial Z) U, // (final Z) = (initial Z) U,
// where U is the orthogonal matrix in (*) regardless of the value of job. // where U is the orthogonal matrix in (*) regardless of the value of job.
// //
// If unconverged > 0 and compz == lapack.InitZ, then on return // If unconverged > 0 and compz == lapack.HessEV, then on return
// (final Z) = U, // (final Z) = U,
// where U is the orthogonal matrix in (*) regardless of the value of job. // where U is the orthogonal matrix in (*) regardless of the value of job.
// //
@@ -132,7 +132,7 @@ func (impl Implementation) Dhseqr(job lapack.EVJob, compz lapack.EVComp, n, ilo,
default: default:
panic(badEVComp) panic(badEVComp)
case lapack.None: case lapack.None:
case lapack.InitZ, lapack.UpdateZ: case lapack.HessEV, lapack.OriginalEV:
wantz = true wantz = true
} }
switch { switch {
@@ -197,7 +197,7 @@ func (impl Implementation) Dhseqr(job lapack.EVJob, compz lapack.EVComp, n, ilo,
} }
// Initialize Z to identity matrix if requested. // Initialize Z to identity matrix if requested.
if compz == lapack.InitZ { if compz == lapack.HessEV {
impl.Dlaset(blas.All, n, n, 0, 1, z, ldz) impl.Dlaset(blas.All, n, n, 0, 1, z, ldz)
} }

View File

@@ -61,7 +61,7 @@ func testDhseqr(t *testing.T, impl Dhseqrer, i int, test dhseqrTest, job lapack.
z := blas64.General{Stride: max(1, n)} z := blas64.General{Stride: max(1, n)}
if wantz { if wantz {
// First, let Dhseqr initialize Z to the identity matrix. // First, let Dhseqr initialize Z to the identity matrix.
compz = lapack.InitZ compz = lapack.HessEV
z = nanGeneral(n, n, n+extra) z = nanGeneral(n, n, n+extra)
} }
@@ -70,7 +70,7 @@ func testDhseqr(t *testing.T, impl Dhseqrer, i int, test dhseqrTest, job lapack.
work := nanSlice(max(1, n)) work := nanSlice(max(1, n))
if optwork { if optwork {
impl.Dhseqr(job, lapack.InitZ, n, ilo, ihi, nil, h.Stride, nil, nil, nil, z.Stride, work, -1) impl.Dhseqr(job, lapack.HessEV, n, ilo, ihi, nil, h.Stride, nil, nil, nil, z.Stride, work, -1)
work = nanSlice(int(work[0])) work = nanSlice(int(work[0]))
} }
@@ -196,7 +196,7 @@ func testDhseqr(t *testing.T, impl Dhseqrer, i int, test dhseqrTest, job lapack.
copyGeneral(h, hCopy) copyGeneral(h, hCopy)
// Call Dhseqr again with the identity matrix given explicitly in Q. // Call Dhseqr again with the identity matrix given explicitly in Q.
q := eye(n, n+extra) q := eye(n, n+extra)
impl.Dhseqr(job, lapack.UpdateZ, n, ilo, ihi, h.Data, h.Stride, wr, wi, q.Data, q.Stride, work, len(work)) impl.Dhseqr(job, lapack.OriginalEV, n, ilo, ihi, h.Data, h.Stride, wr, wi, q.Data, q.Stride, work, len(work))
if !equalApproxGeneral(z, q, 0) { if !equalApproxGeneral(z, q, 0) {
t.Errorf("%v: Z and Q are not equal", prefix) t.Errorf("%v: Z and Q are not equal", prefix)
} }