lapack: rename LeftEV and RightEV job constants

This commit is contained in:
Vladimir Chalupecky
2018-08-22 13:59:17 +02:00
committed by Vladimír Chalupecký
parent de667f08e7
commit a6f3f37374
6 changed files with 44 additions and 39 deletions

View File

@@ -36,9 +36,10 @@ import (
// where i is the imaginary unit. The computed eigenvectors are normalized to
// have Euclidean norm equal to 1 and largest component real.
//
// Left eigenvectors will be computed only if jobvl == lapack.ComputeLeftEV,
// otherwise jobvl must be lapack.None. Right eigenvectors will be computed
// only if jobvr == lapack.ComputeRightEV, otherwise jobvr must be lapack.None.
// Left eigenvectors will be computed only if jobvl == lapack.LeftEVCompute,
// otherwise jobvl must be lapack.LeftEVNone.
// Right eigenvectors will be computed only if jobvr == lapack.RightEVCompute,
// otherwise jobvr must be lapack.RightEVNone.
// For other values of jobvl and jobvr Dgeev will panic.
//
// wr and wi contain the real and imaginary parts, respectively, of the computed
@@ -64,17 +65,17 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
switch jobvl {
default:
panic("lapack: invalid LeftEVJob")
case lapack.ComputeLeftEV:
case lapack.LeftEVCompute:
wantvl = true
case lapack.None:
case lapack.LeftEVNone:
}
var wantvr bool
switch jobvr {
default:
panic("lapack: invalid RightEVJob")
case lapack.ComputeRightEV:
case lapack.RightEVCompute:
wantvr = true
case lapack.None:
case lapack.RightEVNone:
}
switch {
case n < 0:

View File

@@ -145,16 +145,20 @@ const (
EVNone EVJob = 'N' // Eigenvectors are not computed.
)
// Job types for computation of eigenvectors.
type (
LeftEVJob byte
RightEVJob byte
// LeftEVJob specifies whether left eigenvectors are computed in Dgeev.
type LeftEVJob byte
const (
LeftEVCompute LeftEVJob = 'V' // Left eigenvectors are computed.
LeftEVNone LeftEVJob = 'N' // Left eigenvectors are not computed.
)
// Job constants for computation of eigenvectors.
// RightEVJob specifies whether right eigenvectors are computed in Dgeev.
type RightEVJob byte
const (
ComputeLeftEV LeftEVJob = 'V' // Compute left eigenvectors.
ComputeRightEV RightEVJob = 'V' // Compute right eigenvectors.
RightEVCompute RightEVJob = 'V' // Right eigenvectors are computed.
RightEVNone RightEVJob = 'N' // Right eigenvectors are not computed.
)
// BalanceJob specifies matrix balancing operation.

View File

@@ -515,10 +515,10 @@ func Trtrs(trans blas.Transpose, a blas64.Triangular, b blas64.General) (ok bool
// where i is the imaginary unit. The computed eigenvectors are normalized to
// have Euclidean norm equal to 1 and largest component real.
//
// Left eigenvectors will be computed only if jobvl == lapack.ComputeLeftEV,
// otherwise jobvl must be lapack.None.
// Right eigenvectors will be computed only if jobvr == lapack.ComputeRightEV,
// otherwise jobvr must be lapack.None.
// Left eigenvectors will be computed only if jobvl == lapack.LeftEVCompute,
// otherwise jobvl must be lapack.LeftEVNone.
// Right eigenvectors will be computed only if jobvr == lapack.RightEVCompute,
// otherwise jobvr must be lapack.RightEVNone.
// For other values of jobvl and jobvr Geev will panic.
//
// On return, wr and wi will contain the real and imaginary parts, respectively,
@@ -544,10 +544,10 @@ func Geev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob, a blas64.General, wr,
if a.Cols != n {
panic("lapack64: matrix not square")
}
if jobvl == lapack.ComputeLeftEV && (vl.Rows != n || vl.Cols != n) {
if jobvl == lapack.LeftEVCompute && (vl.Rows != n || vl.Cols != n) {
panic("lapack64: bad size of VL")
}
if jobvr == lapack.ComputeRightEV && (vr.Rows != n || vr.Cols != n) {
if jobvr == lapack.RightEVCompute && (vr.Rows != n || vr.Cols != n) {
panic("lapack64: bad size of VR")
}
return lapack64.Dgeev(jobvl, jobvr, n, a.Data, a.Stride, wr, wi, vl.Data, vl.Stride, vr.Data, vr.Stride, work, lwork)

View File

@@ -475,8 +475,8 @@ func DgeevTest(t *testing.T, impl Dgeever) {
evWant: Zero(100).Eigenvalues(),
},
} {
for _, jobvl := range []lapack.LeftEVJob{lapack.ComputeLeftEV, lapack.None} {
for _, jobvr := range []lapack.RightEVJob{lapack.ComputeRightEV, lapack.None} {
for _, jobvl := range []lapack.LeftEVJob{lapack.LeftEVCompute, lapack.LeftEVNone} {
for _, jobvr := range []lapack.RightEVJob{lapack.RightEVCompute, lapack.RightEVNone} {
for _, extra := range []int{0, 11} {
for _, wl := range []worklen{minimumWork, mediumWork, optimumWork} {
testDgeev(t, impl, strconv.Itoa(i), test, jobvl, jobvr, extra, wl)
@@ -487,8 +487,8 @@ func DgeevTest(t *testing.T, impl Dgeever) {
}
for _, n := range []int{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 50, 51, 100, 101} {
for _, jobvl := range []lapack.LeftEVJob{lapack.ComputeLeftEV, lapack.None} {
for _, jobvr := range []lapack.RightEVJob{lapack.ComputeRightEV, lapack.None} {
for _, jobvl := range []lapack.LeftEVJob{lapack.LeftEVCompute, lapack.LeftEVNone} {
for _, jobvr := range []lapack.RightEVJob{lapack.RightEVCompute, lapack.RightEVNone} {
for cas := 0; cas < 10; cas++ {
// Create a block diagonal matrix with
// random eigenvalues of random multiplicity.
@@ -557,12 +557,12 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
n := a.Rows
var vl blas64.General
if jobvl == lapack.ComputeLeftEV {
if jobvl == lapack.LeftEVCompute {
vl = nanGeneral(n, n, n)
}
var vr blas64.General
if jobvr == lapack.ComputeRightEV {
if jobvr == lapack.RightEVCompute {
vr = nanGeneral(n, n, n)
}
@@ -572,7 +572,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
var lwork int
switch wl {
case minimumWork:
if jobvl == lapack.ComputeLeftEV || jobvr == lapack.ComputeRightEV {
if jobvl == lapack.LeftEVCompute || jobvr == lapack.RightEVCompute {
lwork = max(1, 4*n)
} else {
lwork = max(1, 3*n)
@@ -580,7 +580,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
case mediumWork:
work := make([]float64, 1)
impl.Dgeev(jobvl, jobvr, n, nil, 1, nil, nil, nil, 1, nil, 1, work, -1)
if jobvl == lapack.ComputeLeftEV || jobvr == lapack.ComputeRightEV {
if jobvl == lapack.LeftEVCompute || jobvr == lapack.RightEVCompute {
lwork = (int(work[0]) + 4*n) / 2
} else {
lwork = (int(work[0]) + 3*n) / 2
@@ -644,7 +644,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
}
}
if first > 0 || (jobvl == lapack.None && jobvr == lapack.None) {
if first > 0 || (jobvl == lapack.LeftEVNone && jobvr == lapack.RightEVNone) {
// No eigenvectors have been computed.
return
}
@@ -653,7 +653,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
// to the computed eigenvalues.
for k := 0; k < n; {
if wi[k] == 0 {
if jobvl == lapack.ComputeLeftEV {
if jobvl == lapack.LeftEVCompute {
ev := columnOf(vl, k)
if !isLeftEigenvectorOf(test.a, ev, nil, complex(wr[k], 0), vecTol) {
t.Errorf("%v: VL[:,%v] is not left real eigenvector",
@@ -666,7 +666,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
prefix, k, norm)
}
}
if jobvr == lapack.ComputeRightEV {
if jobvr == lapack.RightEVCompute {
ev := columnOf(vr, k)
if !isRightEigenvectorOf(test.a, ev, nil, complex(wr[k], 0), vecTol) {
t.Errorf("%v: VR[:,%v] is not right real eigenvector",
@@ -681,7 +681,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
}
k++
} else {
if jobvl == lapack.ComputeLeftEV {
if jobvl == lapack.LeftEVCompute {
evre := columnOf(vl, k)
evim := columnOf(vl, k+1)
if !isLeftEigenvectorOf(test.a, evre, evim, complex(wr[k], wi[k]), vecTol) {
@@ -700,7 +700,7 @@ func testDgeev(t *testing.T, impl Dgeever, tc string, test dgeevTest, jobvl lapa
prefix, k, norm)
}
}
if jobvr == lapack.ComputeRightEV {
if jobvr == lapack.RightEVCompute {
evre := columnOf(vr, k)
evim := columnOf(vr, k+1)
if !isRightEigenvectorOf(test.a, evre, evim, complex(wr[k], wi[k]), vecTol) {

View File

@@ -46,14 +46,14 @@ func DgeevBenchmark(b *testing.B, impl Dgeever) {
wr := make([]float64, n)
wi := make([]float64, n)
work := make([]float64, 1)
impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, nil, n, nil, nil, nil, n, nil, n, work, -1)
impl.Dgeev(lapack.LeftEVCompute, lapack.RightEVCompute, n, nil, n, nil, nil, nil, n, nil, n, work, -1)
work = make([]float64, int(work[0]))
b.Run(bm.name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
b.StopTimer()
copyGeneral(a, bm.a)
b.StartTimer()
impl.Dgeev(lapack.ComputeLeftEV, lapack.ComputeRightEV, n, a.Data, a.Stride, wr, wi,
impl.Dgeev(lapack.LeftEVCompute, lapack.RightEVCompute, n, a.Data, a.Stride, wr, wi,
vl.Data, vl.Stride, vr.Data, vr.Stride, work, len(work))
}
resultGeneral = a

View File

@@ -154,15 +154,15 @@ func (e *Eigen) Factorize(a Matrix, left, right bool) (ok bool) {
sd.Clone(a)
var vl, vr Dense
var jobvl lapack.LeftEVJob = lapack.None
var jobvr lapack.RightEVJob = lapack.None
jobvl := lapack.LeftEVNone
jobvr := lapack.RightEVNone
if left {
vl = *NewDense(r, r, nil)
jobvl = lapack.ComputeLeftEV
jobvl = lapack.LeftEVCompute
}
if right {
vr = *NewDense(c, c, nil)
jobvr = lapack.ComputeRightEV
jobvr = lapack.RightEVCompute
}
wr := getFloats(c, false)