mirror of
https://github.com/gonum/gonum.git
synced 2025-10-10 01:20:14 +08:00
lapack: add BalanceNone const
This commit is contained in:

committed by
Vladimír Chalupecký

parent
b132fde8ea
commit
3092bd2577
@@ -24,7 +24,7 @@ func (impl Implementation) Dgebak(job lapack.BalanceJob, side lapack.EVSide, n,
|
|||||||
switch job {
|
switch job {
|
||||||
default:
|
default:
|
||||||
panic(badBalanceJob)
|
panic(badBalanceJob)
|
||||||
case lapack.None, lapack.Permute, lapack.Scale, lapack.PermuteScale:
|
case lapack.BalanceNone, lapack.Permute, lapack.Scale, lapack.PermuteScale:
|
||||||
}
|
}
|
||||||
switch side {
|
switch side {
|
||||||
default:
|
default:
|
||||||
@@ -40,7 +40,7 @@ func (impl Implementation) Dgebak(job lapack.BalanceJob, side lapack.EVSide, n,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Quick return if possible.
|
// Quick return if possible.
|
||||||
if n == 0 || m == 0 || job == lapack.None {
|
if n == 0 || m == 0 || job == lapack.BalanceNone {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,14 +35,14 @@ import (
|
|||||||
// the computed eigenvalues and/or eigenvectors.
|
// the computed eigenvalues and/or eigenvectors.
|
||||||
//
|
//
|
||||||
// job specifies the operations that will be performed on A.
|
// job specifies the operations that will be performed on A.
|
||||||
// If job is lapack.None, Dgebal sets scale[i] = 1 for all i and returns ilo=0, ihi=n-1.
|
// If job is lapack.BalanceNone, Dgebal sets scale[i] = 1 for all i and returns ilo=0, ihi=n-1.
|
||||||
// If job is lapack.Permute, only permuting will be done.
|
// If job is lapack.Permute, only permuting will be done.
|
||||||
// If job is lapack.Scale, only scaling will be done.
|
// If job is lapack.Scale, only scaling will be done.
|
||||||
// If job is lapack.PermuteScale, both permuting and scaling will be done.
|
// If job is lapack.PermuteScale, both permuting and scaling will be done.
|
||||||
//
|
//
|
||||||
// On return, if job is lapack.Permute or lapack.PermuteScale, it will hold that
|
// On return, if job is lapack.Permute or lapack.PermuteScale, it will hold that
|
||||||
// A[i,j] == 0, for i > j and j ∈ {0, ..., ilo-1, ihi+1, ..., n-1}.
|
// A[i,j] == 0, for i > j and j ∈ {0, ..., ilo-1, ihi+1, ..., n-1}.
|
||||||
// If job is lapack.None or lapack.Scale, or if n == 0, it will hold that
|
// If job is lapack.BalanceNone or lapack.Scale, or if n == 0, it will hold that
|
||||||
// ilo == 0 and ihi == n-1.
|
// ilo == 0 and ihi == n-1.
|
||||||
//
|
//
|
||||||
// On return, scale will contain information about the permutations and scaling
|
// On return, scale will contain information about the permutations and scaling
|
||||||
@@ -58,7 +58,7 @@ func (impl Implementation) Dgebal(job lapack.BalanceJob, n int, a []float64, lda
|
|||||||
switch job {
|
switch job {
|
||||||
default:
|
default:
|
||||||
panic(badBalanceJob)
|
panic(badBalanceJob)
|
||||||
case lapack.None, lapack.Permute, lapack.Scale, lapack.PermuteScale:
|
case lapack.BalanceNone, lapack.Permute, lapack.Scale, lapack.PermuteScale:
|
||||||
}
|
}
|
||||||
checkMatrix(n, n, a, lda)
|
checkMatrix(n, n, a, lda)
|
||||||
if len(scale) != n {
|
if len(scale) != n {
|
||||||
@@ -68,7 +68,7 @@ func (impl Implementation) Dgebal(job lapack.BalanceJob, n int, a []float64, lda
|
|||||||
ilo = 0
|
ilo = 0
|
||||||
ihi = n - 1
|
ihi = n - 1
|
||||||
|
|
||||||
if n == 0 || job == lapack.None {
|
if n == 0 || job == lapack.BalanceNone {
|
||||||
for i := range scale {
|
for i := range scale {
|
||||||
scale[i] = 1
|
scale[i] = 1
|
||||||
}
|
}
|
||||||
|
@@ -168,6 +168,7 @@ const (
|
|||||||
Permute BalanceJob = 'P'
|
Permute BalanceJob = 'P'
|
||||||
Scale BalanceJob = 'S'
|
Scale BalanceJob = 'S'
|
||||||
PermuteScale BalanceJob = 'B'
|
PermuteScale BalanceJob = 'B'
|
||||||
|
BalanceNone BalanceJob = 'N'
|
||||||
)
|
)
|
||||||
|
|
||||||
// SchurJob specifies whether the Schur form is computed in Dhseqr.
|
// SchurJob specifies whether the Schur form is computed in Dhseqr.
|
||||||
|
@@ -22,7 +22,7 @@ type Dgebaker interface {
|
|||||||
func DgebakTest(t *testing.T, impl Dgebaker) {
|
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.BalanceNone, lapack.Permute, lapack.Scale, lapack.PermuteScale} {
|
||||||
for _, side := range []lapack.EVSide{lapack.EVLeft, lapack.EVRight} {
|
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} {
|
||||||
|
@@ -22,7 +22,7 @@ type Dgebaler interface {
|
|||||||
func DgebalTest(t *testing.T, impl Dgebaler) {
|
func DgebalTest(t *testing.T, impl Dgebaler) {
|
||||||
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.BalanceNone, lapack.Permute, lapack.Scale, lapack.PermuteScale} {
|
||||||
for _, n := range []int{0, 1, 2, 3, 4, 5, 6, 10, 18, 31, 53, 100} {
|
for _, n := range []int{0, 1, 2, 3, 4, 5, 6, 10, 18, 31, 53, 100} {
|
||||||
for _, extra := range []int{0, 11} {
|
for _, extra := range []int{0, 11} {
|
||||||
for cas := 0; cas < 100; cas++ {
|
for cas := 0; cas < 100; cas++ {
|
||||||
@@ -65,12 +65,12 @@ func testDgebal(t *testing.T, impl Dgebaler, job lapack.BalanceJob, a blas64.Gen
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if job == lapack.None {
|
if job == lapack.BalanceNone {
|
||||||
if ilo != 0 {
|
if ilo != 0 {
|
||||||
t.Errorf("%v: unexpected ilo when job=None. Want 0, got %v", prefix, ilo)
|
t.Errorf("%v: unexpected ilo when job=BalanceNone. Want 0, got %v", prefix, ilo)
|
||||||
}
|
}
|
||||||
if ihi != n-1 {
|
if ihi != n-1 {
|
||||||
t.Errorf("%v: unexpected ihi when job=None. Want %v, got %v", prefix, n-1, ihi)
|
t.Errorf("%v: unexpected ihi when job=BalanceNone. Want %v, got %v", prefix, n-1, ihi)
|
||||||
}
|
}
|
||||||
k := -1
|
k := -1
|
||||||
for i := range scale {
|
for i := range scale {
|
||||||
@@ -80,10 +80,10 @@ func testDgebal(t *testing.T, impl Dgebaler, job lapack.BalanceJob, a blas64.Gen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if k != -1 {
|
if k != -1 {
|
||||||
t.Errorf("%v: unexpected scale[%v] when job=None. Want 1, got %v", prefix, k, scale[k])
|
t.Errorf("%v: unexpected scale[%v] when job=BalanceNone. Want 1, got %v", prefix, k, scale[k])
|
||||||
}
|
}
|
||||||
if !equalApproxGeneral(a, want, 0) {
|
if !equalApproxGeneral(a, want, 0) {
|
||||||
t.Errorf("%v: unexpected modification of A when job=None", prefix)
|
t.Errorf("%v: unexpected modification of A when job=BalanceNone", prefix)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user