native,cgo: replace lapack.EigComp with lapack.JobEV in Dsyev

This commit is contained in:
Vladimir Chalupecky
2016-10-05 22:47:24 +09:00
parent 5877fdce9e
commit efcc5f8fec
5 changed files with 13 additions and 13 deletions

View File

@@ -1412,14 +1412,14 @@ func (impl Implementation) Dpocon(uplo blas.Uplo, n int, a []float64, lda int, a
// at least n, and Dsyev will panic otherwise.
//
// On entry, a contains the elements of the symmetric matrix A in the triangular
// portion specified by uplo. If jobz == lapack.EigDecomp a contains the
// portion specified by uplo. If jobz == lapack.ComputeEV a contains the
// orthonormal eigenvectors of A on exit, otherwise on exit the specified
// triangular region is overwritten.
//
// The C interface does not support providing temporary storage. To provide compatibility
// with native, lwork == -1 will not run Dsyev but will instead write the minimum
// work necessary to work[0]. If len(work) < lwork, Dsyev will panic.
func (impl Implementation) Dsyev(jobz lapack.EigComp, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool) {
func (impl Implementation) Dsyev(jobz lapack.JobEV, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool) {
checkMatrix(n, n, a, lda)
if lwork == -1 {
work[0] = 3*float64(n) - 1

View File

@@ -33,7 +33,7 @@ type Float64 interface {
Dormlq(side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int)
Dpocon(uplo blas.Uplo, n int, a []float64, lda int, anorm float64, work []float64, iwork []int) float64
Dpotrf(ul blas.Uplo, n int, a []float64, lda int) (ok bool)
Dsyev(jobz EigComp, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool)
Dsyev(jobz JobEV, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool)
Dtrcon(norm MatrixNorm, uplo blas.Uplo, diag blas.Diag, n int, a []float64, lda int, work []float64, iwork []int) float64
Dtrtri(uplo blas.Uplo, diag blas.Diag, n int, a []float64, lda int) (ok bool)
Dtrtrs(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n, nrhs int, a []float64, lda int, b []float64, ldb int) (ok bool)

View File

@@ -344,7 +344,7 @@ func Pocon(a blas64.Symmetric, anorm float64, work []float64, iwork []int) float
// at least n, and Syev will panic otherwise.
//
// On entry, a contains the elements of the symmetric matrix A in the triangular
// portion specified by uplo. If jobz == lapack.EigDecomp a contains the
// portion specified by uplo. If jobz == lapack.ComputeEV a contains the
// orthonormal eigenvectors of A on exit, otherwise on exit the specified
// triangular region is overwritten.
//
@@ -352,7 +352,7 @@ func Pocon(a blas64.Symmetric, anorm float64, work []float64, iwork []int) float
// lwork >= 3*n-1, and Syev will panic otherwise. The amount of blocking is
// limited by the usable length. If lwork == -1, instead of computing Syev the
// optimal work length is stored into work[0].
func Syev(jobz lapack.EigComp, a blas64.Symmetric, w, work []float64, lwork int) (ok bool) {
func Syev(jobz lapack.JobEV, a blas64.Symmetric, w, work []float64, lwork int) (ok bool) {
return lapack64.Dsyev(jobz, a.Uplo, a.N, a.Data, a.Stride, w, work, lwork)
}

View File

@@ -19,7 +19,7 @@ import (
// at least n, and Dsyev will panic otherwise.
//
// On entry, a contains the elements of the symmetric matrix A in the triangular
// portion specified by uplo. If jobz == lapack.EigDecomp a contains the
// portion specified by uplo. If jobz == lapack.ComputeEV a contains the
// orthonormal eigenvectors of A on exit, otherwise on exit the specified
// triangular region is overwritten.
//
@@ -27,10 +27,10 @@ import (
// lwork >= 3*n-1, and Dsyev will panic otherwise. The amount of blocking is
// limited by the usable length. If lwork == -1, instead of computing Dsyev the
// optimal work length is stored into work[0].
func (impl Implementation) Dsyev(jobz lapack.EigComp, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool) {
func (impl Implementation) Dsyev(jobz lapack.JobEV, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool) {
checkMatrix(n, n, a, lda)
upper := uplo == blas.Upper
wantz := jobz == lapack.EigDecomp
wantz := jobz == lapack.ComputeEV
var opts string
if upper {
opts = "U"
@@ -97,7 +97,7 @@ func (impl Implementation) Dsyev(jobz lapack.EigComp, uplo blas.Uplo, n int, a [
ok = impl.Dsterf(n, w, work[inde:])
} else {
impl.Dorgtr(uplo, n, a, lda, work[indtau:], work[indwork:], llwork)
ok = impl.Dsteqr(jobz, n, w, work[inde:], a, lda, work[indtau:])
ok = impl.Dsteqr(lapack.EigComp(jobz), n, w, work[inde:], a, lda, work[indtau:])
}
if !ok {
return false

View File

@@ -15,7 +15,7 @@ import (
)
type Dsyever interface {
Dsyev(jobz lapack.EigComp, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool)
Dsyev(jobz lapack.JobEV, uplo blas.Uplo, n int, a []float64, lda int, w, work []float64, lwork int) (ok bool)
}
func DsyevTest(t *testing.T, impl Dsyever) {
@@ -54,9 +54,9 @@ func DsyevTest(t *testing.T, impl Dsyever) {
}
work := make([]float64, 1)
impl.Dsyev(lapack.EigDecomp, uplo, n, a, lda, w, work, -1)
impl.Dsyev(lapack.ComputeEV, uplo, n, a, lda, w, work, -1)
work = make([]float64, int(work[0]))
impl.Dsyev(lapack.EigDecomp, uplo, n, a, lda, w, work, len(work))
impl.Dsyev(lapack.ComputeEV, uplo, n, a, lda, w, work, len(work))
// Check that the decomposition is correct
orig := blas64.General{
@@ -105,7 +105,7 @@ func DsyevTest(t *testing.T, impl Dsyever) {
for i := range work {
work[i] = rnd.Float64()
}
impl.Dsyev(lapack.EigValueOnly, uplo, n, a, lda, w, work, len(work))
impl.Dsyev(lapack.None, uplo, n, a, lda, w, work, len(work))
if !floats.EqualApprox(w, wAns, 1e-8) {
t.Errorf("Eigenvalue mismatch when vectors not computed")
}