mirror of
https://github.com/gonum/gonum.git
synced 2025-10-23 15:13:31 +08:00
lapack,native: rename EigDecomp and EigBoth consts to OriginalEV and TridiagEV
As a side effect fix the documentation of Dsteqr which has the description reversed.
This commit is contained in:
12
lapack.go
12
lapack.go
@@ -112,12 +112,12 @@ const (
|
|||||||
type EVComp byte
|
type EVComp byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// EigDecomp specifies to compute the eigenvalues and eigenvectors of the
|
// OriginalEV specifies to compute the eigenvectors of the original
|
||||||
// full symmetric matrix.
|
// matrix.
|
||||||
EigDecomp EVComp = 'V'
|
OriginalEV EVComp = 'V'
|
||||||
// EigBoth specifies to compute both the eigenvalues and eigenvectors of the
|
// TridiagEV specifies to compute both the eigenvectors of the input
|
||||||
// input tridiagonal matrix.
|
// tridiagonal matrix.
|
||||||
EigBoth EVComp = 'I'
|
TridiagEV EVComp = 'I'
|
||||||
)
|
)
|
||||||
|
|
||||||
// Job types for computation of eigenvectors.
|
// Job types for computation of eigenvectors.
|
||||||
|
@@ -26,9 +26,9 @@ import (
|
|||||||
// Dsteqr will panic otherwise.
|
// Dsteqr will panic otherwise.
|
||||||
//
|
//
|
||||||
// z, on entry, contains the n×n orthogonal matrix used in the reduction to
|
// z, on entry, contains the n×n orthogonal matrix used in the reduction to
|
||||||
// tridiagonal form if compz == lapack.EigDecomp. On exit, if
|
// tridiagonal form if compz == lapack.OriginalEV. On exit, if
|
||||||
// compz == lapack.EigBoth, z contains the orthonormal eigenvectors of the
|
// compz == lapack.OriginalEV, z contains the orthonormal eigenvectors of the
|
||||||
// original symmetric matrix, and if compz == lapack.EigDecomp, z contains the
|
// original symmetric matrix, and if compz == lapack.TridiagEV, z contains the
|
||||||
// orthonormal eigenvectors of the symmetric tridiagonal matrix. z is not used
|
// orthonormal eigenvectors of the symmetric tridiagonal matrix. z is not used
|
||||||
// if compz == lapack.None.
|
// if compz == lapack.None.
|
||||||
//
|
//
|
||||||
@@ -43,7 +43,7 @@ func (impl Implementation) Dsteqr(compz lapack.EVComp, n int, d, e, z []float64,
|
|||||||
if len(e) < n-1 {
|
if len(e) < n-1 {
|
||||||
panic(badE)
|
panic(badE)
|
||||||
}
|
}
|
||||||
if compz != lapack.None && compz != lapack.EigBoth && compz != lapack.EigDecomp {
|
if compz != lapack.None && compz != lapack.TridiagEV && compz != lapack.OriginalEV {
|
||||||
panic(badEVComp)
|
panic(badEVComp)
|
||||||
}
|
}
|
||||||
if compz != lapack.None {
|
if compz != lapack.None {
|
||||||
@@ -54,9 +54,9 @@ func (impl Implementation) Dsteqr(compz lapack.EVComp, n int, d, e, z []float64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
var icompz int
|
var icompz int
|
||||||
if compz == lapack.EigDecomp {
|
if compz == lapack.OriginalEV {
|
||||||
icompz = 1
|
icompz = 1
|
||||||
} else if compz == lapack.EigBoth {
|
} else if compz == lapack.TridiagEV {
|
||||||
icompz = 2
|
icompz = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ type Dsteqrer interface {
|
|||||||
|
|
||||||
func DsteqrTest(t *testing.T, impl Dsteqrer) {
|
func DsteqrTest(t *testing.T, impl Dsteqrer) {
|
||||||
rnd := rand.New(rand.NewSource(1))
|
rnd := rand.New(rand.NewSource(1))
|
||||||
for _, compz := range []lapack.EVComp{lapack.EigDecomp, lapack.EigBoth} {
|
for _, compz := range []lapack.EVComp{lapack.OriginalEV, lapack.TridiagEV} {
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
n, lda int
|
n, lda int
|
||||||
}{
|
}{
|
||||||
@@ -58,7 +58,7 @@ func DsteqrTest(t *testing.T, impl Dsteqrer) {
|
|||||||
copy(eCopy, e)
|
copy(eCopy, e)
|
||||||
aCopy := make([]float64, len(a))
|
aCopy := make([]float64, len(a))
|
||||||
copy(aCopy, a)
|
copy(aCopy, a)
|
||||||
if compz == lapack.EigDecomp {
|
if compz == lapack.OriginalEV {
|
||||||
// Compute triangular decomposition and orthonormal matrix.
|
// Compute triangular decomposition and orthonormal matrix.
|
||||||
uplo := blas.Upper
|
uplo := blas.Upper
|
||||||
tau := make([]float64, n)
|
tau := make([]float64, n)
|
||||||
@@ -90,7 +90,7 @@ func DsteqrTest(t *testing.T, impl Dsteqrer) {
|
|||||||
copy(dAns, d)
|
copy(dAns, d)
|
||||||
|
|
||||||
var truth blas64.General
|
var truth blas64.General
|
||||||
if compz == lapack.EigDecomp {
|
if compz == lapack.OriginalEV {
|
||||||
truth = blas64.General{
|
truth = blas64.General{
|
||||||
Rows: n,
|
Rows: n,
|
||||||
Cols: n,
|
Cols: n,
|
||||||
@@ -127,7 +127,8 @@ func DsteqrTest(t *testing.T, impl Dsteqrer) {
|
|||||||
Data: a,
|
Data: a,
|
||||||
}
|
}
|
||||||
if !eigenDecompCorrect(d, truth, V) {
|
if !eigenDecompCorrect(d, truth, V) {
|
||||||
t.Errorf("Eigen reconstruction mismatch. fromFull = %v, n = %v", compz == lapack.EigDecomp, n)
|
t.Errorf("Eigen reconstruction mismatch. fromFull = %v, n = %v",
|
||||||
|
compz == lapack.OriginalEV, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare eigenvalues when not computing eigenvectors.
|
// Compare eigenvalues when not computing eigenvectors.
|
||||||
|
Reference in New Issue
Block a user