diff --git a/lapack/gonum/dsyev.go b/lapack/gonum/dsyev.go index b4c20c75..29a78319 100644 --- a/lapack/gonum/dsyev.go +++ b/lapack/gonum/dsyev.go @@ -19,9 +19,9 @@ 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.ComputeEV a contains the -// orthonormal eigenvectors of A on exit, otherwise on exit the specified -// triangular region is overwritten. +// portion specified by uplo. If jobz == lapack.EVCompute, a contains the +// orthonormal eigenvectors of A on exit, otherwise jobz must be lapack.EVNone +// and on exit the specified triangular region is overwritten. // // work is temporary storage, and lwork specifies the usable memory length. At minimum, // lwork >= 3*n-1, and Dsyev will panic otherwise. The amount of blocking is @@ -30,7 +30,14 @@ import ( func (impl Implementation) Dsyev(jobz lapack.EVJob, 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.ComputeEV + var wantz bool + switch jobz { + default: + panic(badEVJob) + case lapack.EVCompute: + wantz = true + case lapack.EVNone: + } var opts string if upper { opts = "U" diff --git a/lapack/lapack.go b/lapack/lapack.go index daf2c92a..927890f8 100644 --- a/lapack/lapack.go +++ b/lapack/lapack.go @@ -137,16 +137,22 @@ const ( UpdateSchur EVComp = 'V' ) +// EVJob specifies whether eigenvectors are computed in Dsyev. +type EVJob byte + +const ( + EVCompute EVJob = 'V' // Eigenvectors are computed. + EVNone EVJob = 'N' // Eigenvectors are not computed. +) + // Job types for computation of eigenvectors. type ( - EVJob byte LeftEVJob byte RightEVJob byte ) // Job constants for computation of eigenvectors. const ( - ComputeEV EVJob = 'V' // Compute eigenvectors in Dsyev. ComputeLeftEV LeftEVJob = 'V' // Compute left eigenvectors. ComputeRightEV RightEVJob = 'V' // Compute right eigenvectors. ) diff --git a/lapack/lapack64/lapack64.go b/lapack/lapack64/lapack64.go index f1460eca..ef251b54 100644 --- a/lapack/lapack64/lapack64.go +++ b/lapack/lapack64/lapack64.go @@ -454,9 +454,9 @@ 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.ComputeEV a contains the -// orthonormal eigenvectors of A on exit, otherwise on exit the specified -// triangular region is overwritten. +// portion specified by uplo. If jobz == lapack.EVCompute, a contains the +// orthonormal eigenvectors of A on exit, otherwise jobz must be lapack.EVNone +// and on exit the specified triangular region is overwritten. // // Work is temporary storage, and lwork specifies the usable memory length. At minimum, // lwork >= 3*n-1, and Syev will panic otherwise. The amount of blocking is diff --git a/lapack/testlapack/dsyev.go b/lapack/testlapack/dsyev.go index 0adf508a..b4b401ae 100644 --- a/lapack/testlapack/dsyev.go +++ b/lapack/testlapack/dsyev.go @@ -55,9 +55,9 @@ func DsyevTest(t *testing.T, impl Dsyever) { } work := make([]float64, 1) - impl.Dsyev(lapack.ComputeEV, uplo, n, a, lda, w, work, -1) + impl.Dsyev(lapack.EVCompute, uplo, n, a, lda, w, work, -1) work = make([]float64, int(work[0])) - impl.Dsyev(lapack.ComputeEV, uplo, n, a, lda, w, work, len(work)) + impl.Dsyev(lapack.EVCompute, uplo, n, a, lda, w, work, len(work)) // Check that the decomposition is correct orig := blas64.General{ diff --git a/mat/eigen.go b/mat/eigen.go index 6204a70f..22f4ca21 100644 --- a/mat/eigen.go +++ b/mat/eigen.go @@ -38,9 +38,9 @@ func (e *EigenSym) Factorize(a Symmetric, vectors bool) (ok bool) { sd := NewSymDense(n, nil) sd.CopySym(a) - jobz := lapack.EVJob(lapack.None) + jobz := lapack.EVNone if vectors { - jobz = lapack.ComputeEV + jobz = lapack.EVCompute } w := make([]float64, n) work := []float64{0}