mirror of
https://github.com/gonum/gonum.git
synced 2025-10-18 21:15:23 +08:00
native,cgo: replace lapack.EigComp with lapack.JobEV in Dsyev
This commit is contained in:
@@ -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.
|
// at least n, and Dsyev will panic otherwise.
|
||||||
//
|
//
|
||||||
// On entry, a contains the elements of the symmetric matrix A in the triangular
|
// 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
|
// orthonormal eigenvectors of A on exit, otherwise on exit the specified
|
||||||
// triangular region is overwritten.
|
// triangular region is overwritten.
|
||||||
//
|
//
|
||||||
// The C interface does not support providing temporary storage. To provide compatibility
|
// 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
|
// 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.
|
// 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)
|
checkMatrix(n, n, a, lda)
|
||||||
if lwork == -1 {
|
if lwork == -1 {
|
||||||
work[0] = 3*float64(n) - 1
|
work[0] = 3*float64(n) - 1
|
||||||
|
@@ -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)
|
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
|
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)
|
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
|
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)
|
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)
|
Dtrtrs(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n, nrhs int, a []float64, lda int, b []float64, ldb int) (ok bool)
|
||||||
|
@@ -344,7 +344,7 @@ func Pocon(a blas64.Symmetric, anorm float64, work []float64, iwork []int) float
|
|||||||
// at least n, and Syev will panic otherwise.
|
// at least n, and Syev will panic otherwise.
|
||||||
//
|
//
|
||||||
// On entry, a contains the elements of the symmetric matrix A in the triangular
|
// 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
|
// orthonormal eigenvectors of A on exit, otherwise on exit the specified
|
||||||
// triangular region is overwritten.
|
// 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
|
// 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
|
// limited by the usable length. If lwork == -1, instead of computing Syev the
|
||||||
// optimal work length is stored into work[0].
|
// 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)
|
return lapack64.Dsyev(jobz, a.Uplo, a.N, a.Data, a.Stride, w, work, lwork)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ import (
|
|||||||
// at least n, and Dsyev will panic otherwise.
|
// at least n, and Dsyev will panic otherwise.
|
||||||
//
|
//
|
||||||
// On entry, a contains the elements of the symmetric matrix A in the triangular
|
// 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
|
// orthonormal eigenvectors of A on exit, otherwise on exit the specified
|
||||||
// triangular region is overwritten.
|
// triangular region is overwritten.
|
||||||
//
|
//
|
||||||
@@ -27,10 +27,10 @@ import (
|
|||||||
// lwork >= 3*n-1, and Dsyev will panic otherwise. The amount of blocking is
|
// 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
|
// limited by the usable length. If lwork == -1, instead of computing Dsyev the
|
||||||
// optimal work length is stored into work[0].
|
// 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)
|
checkMatrix(n, n, a, lda)
|
||||||
upper := uplo == blas.Upper
|
upper := uplo == blas.Upper
|
||||||
wantz := jobz == lapack.EigDecomp
|
wantz := jobz == lapack.ComputeEV
|
||||||
var opts string
|
var opts string
|
||||||
if upper {
|
if upper {
|
||||||
opts = "U"
|
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:])
|
ok = impl.Dsterf(n, w, work[inde:])
|
||||||
} else {
|
} else {
|
||||||
impl.Dorgtr(uplo, n, a, lda, work[indtau:], work[indwork:], llwork)
|
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 {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
|
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Dsyever interface {
|
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) {
|
func DsyevTest(t *testing.T, impl Dsyever) {
|
||||||
@@ -54,9 +54,9 @@ func DsyevTest(t *testing.T, impl Dsyever) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
work := make([]float64, 1)
|
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]))
|
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
|
// Check that the decomposition is correct
|
||||||
orig := blas64.General{
|
orig := blas64.General{
|
||||||
@@ -105,7 +105,7 @@ func DsyevTest(t *testing.T, impl Dsyever) {
|
|||||||
for i := range work {
|
for i := range work {
|
||||||
work[i] = rnd.Float64()
|
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) {
|
if !floats.EqualApprox(w, wAns, 1e-8) {
|
||||||
t.Errorf("Eigenvalue mismatch when vectors not computed")
|
t.Errorf("Eigenvalue mismatch when vectors not computed")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user