lapack: rename EVSide consts

This commit is contained in:
Vladimir Chalupecky
2018-08-22 14:46:17 +02:00
committed by Vladimír Chalupecký
parent d3817b5e18
commit 7ef6056c6f
6 changed files with 36 additions and 37 deletions

View File

@@ -10,8 +10,8 @@ import (
) )
// Dgebak updates an n×m matrix V as // Dgebak updates an n×m matrix V as
// V = P D V, if side == lapack.RightEV, // V = P D V, if side == lapack.EVRight,
// V = P D^{-1} V, if side == lapack.LeftEV, // V = P D^{-1} V, if side == lapack.EVLeft,
// where P and D are n×n permutation and scaling matrices, respectively, // where P and D are n×n permutation and scaling matrices, respectively,
// implicitly represented by job, scale, ilo and ihi as returned by Dgebal. // implicitly represented by job, scale, ilo and ihi as returned by Dgebal.
// //
@@ -29,7 +29,7 @@ func (impl Implementation) Dgebak(job lapack.BalanceJob, side lapack.EVSide, n,
switch side { switch side {
default: default:
panic(badEVSide) panic(badEVSide)
case lapack.LeftEV, lapack.RightEV: case lapack.EVLeft, lapack.EVRight:
} }
checkMatrix(n, m, v, ldv) checkMatrix(n, m, v, ldv)
switch { switch {
@@ -47,7 +47,7 @@ func (impl Implementation) Dgebak(job lapack.BalanceJob, side lapack.EVSide, n,
bi := blas64.Implementation() bi := blas64.Implementation()
if ilo != ihi && job != lapack.Permute { if ilo != ihi && job != lapack.Permute {
// Backward balance. // Backward balance.
if side == lapack.RightEV { if side == lapack.EVRight {
for i := ilo; i <= ihi; i++ { for i := ilo; i <= ihi; i++ {
bi.Dscal(m, scale[i], v[i*ldv:], 1) bi.Dscal(m, scale[i], v[i*ldv:], 1)
} }

View File

@@ -119,9 +119,9 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.OriginalEV, n, 0, n-1, impl.Dhseqr(lapack.EigenvaluesAndSchur, lapack.OriginalEV, n, 0, n-1,
nil, 1, nil, nil, nil, 1, work, -1) nil, 1, nil, nil, nil, 1, work, -1)
maxwrk = max(maxwrk, max(n+1, n+int(work[0]))) maxwrk = max(maxwrk, max(n+1, n+int(work[0])))
side := lapack.LeftEV side := lapack.EVLeft
if wantvr { if wantvr {
side = lapack.RightEV side = lapack.EVRight
} }
impl.Dtrevc3(side, lapack.AllEVMulQ, nil, n, nil, 1, nil, 1, nil, 1, impl.Dtrevc3(side, lapack.AllEVMulQ, nil, n, nil, 1, nil, 1, nil, 1,
n, work, -1) n, work, -1)
@@ -169,7 +169,7 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
var side lapack.EVSide var side lapack.EVSide
if wantvl { if wantvl {
side = lapack.LeftEV side = lapack.EVLeft
// Copy Householder vectors to VL. // Copy Householder vectors to VL.
impl.Dlacpy(blas.Lower, n, n, a, lda, vl, ldvl) impl.Dlacpy(blas.Lower, n, n, a, lda, vl, ldvl)
// Generate orthogonal matrix in VL. // Generate orthogonal matrix in VL.
@@ -181,11 +181,11 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
if wantvr { if wantvr {
// Want left and right eigenvectors. // Want left and right eigenvectors.
// Copy Schur vectors to VR. // Copy Schur vectors to VR.
side = lapack.RightLeftEV side = lapack.EVRightLeft
impl.Dlacpy(blas.All, n, n, vl, ldvl, vr, ldvr) impl.Dlacpy(blas.All, n, n, vl, ldvl, vr, ldvr)
} }
} else if wantvr { } else if wantvr {
side = lapack.RightEV side = lapack.EVRight
// Copy Householder vectors to VR. // Copy Householder vectors to VR.
impl.Dlacpy(blas.Lower, n, n, a, lda, vr, ldvr) impl.Dlacpy(blas.Lower, n, n, a, lda, vr, ldvr)
// Generate orthogonal matrix in VR. // Generate orthogonal matrix in VR.
@@ -221,7 +221,7 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
bi := blas64.Implementation() bi := blas64.Implementation()
if wantvl { if wantvl {
// Undo balancing of left eigenvectors. // Undo balancing of left eigenvectors.
impl.Dgebak(lapack.PermuteScale, lapack.LeftEV, n, ilo, ihi, workbal, n, vl, ldvl) impl.Dgebak(lapack.PermuteScale, lapack.EVLeft, n, ilo, ihi, workbal, n, vl, ldvl)
// Normalize left eigenvectors and make largest component real. // Normalize left eigenvectors and make largest component real.
for i, wii := range wi { for i, wii := range wi {
if wii < 0 { if wii < 0 {
@@ -248,7 +248,7 @@ func (impl Implementation) Dgeev(jobvl lapack.LeftEVJob, jobvr lapack.RightEVJob
} }
if wantvr { if wantvr {
// Undo balancing of right eigenvectors. // Undo balancing of right eigenvectors.
impl.Dgebak(lapack.PermuteScale, lapack.RightEV, n, ilo, ihi, workbal, n, vr, ldvr) impl.Dgebak(lapack.PermuteScale, lapack.EVRight, n, ilo, ihi, workbal, n, vr, ldvr)
// Normalize right eigenvectors and make largest component real. // Normalize right eigenvectors and make largest component real.
for i, wii := range wi { for i, wii := range wi {
if wii < 0 { if wii < 0 {

View File

@@ -31,9 +31,9 @@ import (
// orthogonal factor that reduces a matrix A to Schur form T, then Q*X and Q*Y // orthogonal factor that reduces a matrix A to Schur form T, then Q*X and Q*Y
// are the matrices of right and left eigenvectors of A. // are the matrices of right and left eigenvectors of A.
// //
// If side == lapack.RightEV, only right eigenvectors will be computed. // If side == lapack.EVRight, only right eigenvectors will be computed.
// If side == lapack.LeftEV, only left eigenvectors will be computed. // If side == lapack.EVLeft, only left eigenvectors will be computed.
// If side == lapack.RightLeftEV, both right and left eigenvectors will be computed. // If side == lapack.EVRightLeft, both right and left eigenvectors will be computed.
// For other values of side, Dtrevc3 will panic. // For other values of side, Dtrevc3 will panic.
// //
// If howmny == lapack.AllEV, all right and/or left eigenvectors will be // If howmny == lapack.AllEV, all right and/or left eigenvectors will be
@@ -60,13 +60,13 @@ import (
// selected complex eigenvector occupies two columns. If mm is not sufficiently // selected complex eigenvector occupies two columns. If mm is not sufficiently
// large, Dtrevc3 will panic. // large, Dtrevc3 will panic.
// //
// On entry, if howmny == lapack.AllEVMulQ, it is assumed that VL (if side // On entry, if howmny is lapack.EVAllMulQ, it is assumed that VL (if side
// is lapack.LeftEV or lapack.RightLeftEV) contains an n×n matrix QL, // is lapack.EVLeft or lapack.EVRightLeft) contains an n×n matrix QL,
// and that VR (if side is lapack.LeftEV or lapack.RightLeftEV) contains // and that VR (if side is lapack.EVLeft or lapack.EVRightLeft) contains
// an n×n matrix QR. QL and QR are typically the orthogonal matrix Q of Schur // an n×n matrix QR. QL and QR are typically the orthogonal matrix Q of Schur
// vectors returned by Dhseqr. // vectors returned by Dhseqr.
// //
// On return, if side is lapack.LeftEV or lapack.RightLeftEV, // On return, if side is lapack.EVLeft or lapack.EVRightLeft,
// VL will contain: // VL will contain:
// if howmny == lapack.AllEV, the matrix Y of left eigenvectors of T, // if howmny == lapack.AllEV, the matrix Y of left eigenvectors of T,
// if howmny == lapack.AllEVMulQ, the matrix Q*Y, // if howmny == lapack.AllEVMulQ, the matrix Q*Y,
@@ -74,9 +74,9 @@ import (
// selected, stored consecutively in the // selected, stored consecutively in the
// columns of VL, in the same order as their // columns of VL, in the same order as their
// eigenvalues. // eigenvalues.
// VL is not referenced if side == lapack.RightEV. // VL is not referenced if side == lapack.EVRight.
// //
// On return, if side is lapack.RightEV or lapack.RightLeftEV, // On return, if side is lapack.EVRight or lapack.EVRightLeft,
// VR will contain: // VR will contain:
// if howmny == lapack.AllEV, the matrix X of right eigenvectors of T, // if howmny == lapack.AllEV, the matrix X of right eigenvectors of T,
// if howmny == lapack.AllEVMulQ, the matrix Q*X, // if howmny == lapack.AllEVMulQ, the matrix Q*X,
@@ -84,7 +84,7 @@ import (
// selected, stored consecutively in the // selected, stored consecutively in the
// columns of VR, in the same order as their // columns of VR, in the same order as their
// eigenvalues. // eigenvalues.
// VR is not referenced if side == lapack.LeftEV. // VR is not referenced if side == lapack.EVLeft.
// //
// Complex eigenvectors corresponding to a complex eigenvalue are stored in VL // Complex eigenvectors corresponding to a complex eigenvalue are stored in VL
// and VR in two consecutive columns, the first holding the real part, and the // and VR in two consecutive columns, the first holding the real part, and the
@@ -109,7 +109,7 @@ func (impl Implementation) Dtrevc3(side lapack.EVSide, howmny lapack.HowMany, se
switch side { switch side {
default: default:
panic(badEVSide) panic(badEVSide)
case lapack.RightEV, lapack.LeftEV, lapack.RightLeftEV: case lapack.EVRight, lapack.EVLeft, lapack.EVRightLeft:
} }
switch howmny { switch howmny {
default: default:
@@ -158,10 +158,10 @@ func (impl Implementation) Dtrevc3(side lapack.EVSide, howmny lapack.HowMany, se
panic("lapack: insufficient number of columns") panic("lapack: insufficient number of columns")
} }
checkMatrix(n, n, t, ldt) checkMatrix(n, n, t, ldt)
if (side == lapack.RightEV || side == lapack.RightLeftEV) && m > 0 { if (side == lapack.EVRight || side == lapack.EVRightLeft) && m > 0 {
checkMatrix(n, m, vr, ldvr) checkMatrix(n, m, vr, ldvr)
} }
if (side == lapack.LeftEV || side == lapack.RightLeftEV) && m > 0 { if (side == lapack.EVLeft || side == lapack.EVRightLeft) && m > 0 {
checkMatrix(n, m, vl, ldvl) checkMatrix(n, m, vl, ldvl)
} }
} }
@@ -230,7 +230,7 @@ func (impl Implementation) Dtrevc3(side lapack.EVSide, howmny lapack.HowMany, se
iscomplex [nbmax]int // Stores ip for each column in current block. iscomplex [nbmax]int // Stores ip for each column in current block.
) )
if side == lapack.LeftEV { if side == lapack.EVLeft {
goto leftev goto leftev
} }
@@ -539,7 +539,7 @@ func (impl Implementation) Dtrevc3(side lapack.EVSide, howmny lapack.HowMany, se
} }
} }
if side == lapack.RightEV { if side == lapack.EVRight {
return m return m
} }

View File

@@ -178,14 +178,13 @@ const (
EigenvaluesAndSchur SchurJob = 'S' EigenvaluesAndSchur SchurJob = 'S'
) )
// EVSide specifies what eigenvectors will be computed. // EVSide specifies what eigenvectors are computed in Dtrevc3.
type EVSide byte type EVSide byte
// EVSide constants for Dtrevc3.
const ( const (
RightEV EVSide = 'R' // Compute right eigenvectors only. EVRight EVSide = 'R' // Only right eigenvectors are computed.
LeftEV EVSide = 'L' // Compute left eigenvectors only. EVLeft EVSide = 'L' // Only left eigenvectors are computed.
RightLeftEV EVSide = 'B' // Compute both right and left eigenvectors. EVRightLeft EVSide = 'B' // Both right and left eigenvectors are computed.
) )
// HowMany specifies which eigenvectors will be computed. // HowMany specifies which eigenvectors will be computed.

View File

@@ -23,7 +23,7 @@ func DgebakTest(t *testing.T, impl Dgebaker) {
rnd := rand.New(rand.NewSource(1)) rnd := rand.New(rand.NewSource(1))
for _, job := range []lapack.BalanceJob{lapack.None, lapack.Permute, lapack.Scale, lapack.PermuteScale} { for _, job := range []lapack.BalanceJob{lapack.None, lapack.Permute, lapack.Scale, lapack.PermuteScale} {
for _, side := range []lapack.EVSide{lapack.LeftEV, lapack.RightEV} { for _, side := range []lapack.EVSide{lapack.EVLeft, lapack.EVRight} {
for _, n := range []int{0, 1, 2, 3, 4, 5, 6, 10, 18, 31, 53} { for _, n := range []int{0, 1, 2, 3, 4, 5, 6, 10, 18, 31, 53} {
for _, extra := range []int{0, 11} { for _, extra := range []int{0, 11} {
for cas := 0; cas < 100; cas++ { for cas := 0; cas < 100; cas++ {
@@ -96,7 +96,7 @@ func testDgebak(t *testing.T, impl Dgebaker, job lapack.BalanceJob, side lapack.
// Compute D*V or D^{-1}*V and store into dv. // Compute D*V or D^{-1}*V and store into dv.
dv := zeros(n, m, m) dv := zeros(n, m, m)
if side == lapack.RightEV { if side == lapack.EVRight {
blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, d, v, 0, dv) blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, d, v, 0, dv)
} else { } else {
blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, dinv, v, 0, dv) blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, dinv, v, 0, dv)

View File

@@ -22,8 +22,8 @@ type Dtrevc3er interface {
func Dtrevc3Test(t *testing.T, impl Dtrevc3er) { func Dtrevc3Test(t *testing.T, impl Dtrevc3er) {
rnd := rand.New(rand.NewSource(1)) rnd := rand.New(rand.NewSource(1))
for _, side := range []lapack.EVSide{lapack.RightEV, lapack.LeftEV, lapack.RightLeftEV} { for _, side := range []lapack.EVSide{lapack.EVRight, lapack.EVLeft, lapack.EVRightLeft} {
for _, howmny := range []lapack.HowMany{lapack.AllEV, lapack.AllEVMulQ, lapack.SelectedEV} { for _, howmny := range []lapack.EVHowMany{lapack.EVAll, lapack.EVAllMulQ, lapack.EVSelected} {
for _, n := range []int{0, 1, 2, 3, 4, 5, 10, 34, 100} { for _, n := range []int{0, 1, 2, 3, 4, 5, 10, 34, 100} {
for _, extra := range []int{0, 11} { for _, extra := range []int{0, 11} {
for _, optwork := range []bool{true, false} { for _, optwork := range []bool{true, false} {
@@ -43,8 +43,8 @@ func testDtrevc3(t *testing.T, impl Dtrevc3er, side lapack.EVSide, howmny lapack
n := tmat.Rows n := tmat.Rows
extra := tmat.Stride - tmat.Cols extra := tmat.Stride - tmat.Cols
right := side != lapack.LeftEV right := side != lapack.EVLeft
left := side != lapack.RightEV left := side != lapack.EVRight
var selected, selectedWant []bool var selected, selectedWant []bool
var mWant int // How many columns will the eigenvectors occupy. var mWant int // How many columns will the eigenvectors occupy.