lapack: add SchurJob type

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

View File

@@ -118,11 +118,11 @@ import (
// URL: http://dx.doi.org/10.1137/S0895479801384585 // URL: http://dx.doi.org/10.1137/S0895479801384585
// //
// Dhseqr is an internal routine. It is exported for testing purposes. // Dhseqr is an internal routine. It is exported for testing purposes.
func (impl Implementation) Dhseqr(job lapack.EVJob, compz lapack.EVComp, n, ilo, ihi int, h []float64, ldh int, wr, wi []float64, z []float64, ldz int, work []float64, lwork int) (unconverged int) { func (impl Implementation) Dhseqr(job lapack.SchurJob, compz lapack.EVComp, n, ilo, ihi int, h []float64, ldh int, wr, wi []float64, z []float64, ldz int, work []float64, lwork int) (unconverged int) {
var wantt bool var wantt bool
switch job { switch job {
default: default:
panic(badEVJob) panic(badSchurJob)
case lapack.EigenvaluesOnly: case lapack.EigenvaluesOnly:
case lapack.EigenvaluesAndSchur: case lapack.EigenvaluesAndSchur:
wantt = true wantt = true

View File

@@ -15,7 +15,7 @@ type Implementation struct{}
var _ lapack.Float64 = Implementation{} var _ lapack.Float64 = Implementation{}
// This list is duplicated in lapack/cgo. Keep in sync. // This list is duplicated in netlib/lapack/netlib. Keep in sync.
const ( const (
absIncNotOne = "lapack: increment not one or negative one" absIncNotOne = "lapack: increment not one or negative one"
badAlpha = "lapack: bad alpha length" badAlpha = "lapack: bad alpha length"
@@ -44,6 +44,7 @@ const (
badNorm = "lapack: bad norm" badNorm = "lapack: bad norm"
badPivot = "lapack: bad pivot" badPivot = "lapack: bad pivot"
badS = "lapack: s has insufficient length" badS = "lapack: s has insufficient length"
badSchurJob = "lapack: bad SchurJob"
badShifts = "lapack: bad shifts" badShifts = "lapack: bad shifts"
badSide = "lapack: bad side" badSide = "lapack: bad side"
badSlice = "lapack: bad input slice length" badSlice = "lapack: bad input slice length"
@@ -61,6 +62,7 @@ const (
kGTM = "lapack: k > m" kGTM = "lapack: k > m"
kGTN = "lapack: k > n" kGTN = "lapack: k > n"
kLT0 = "lapack: k < 0" kLT0 = "lapack: k < 0"
mLT0 = "lapack: m < 0"
mLTN = "lapack: m < n" mLTN = "lapack: m < n"
nanScale = "lapack: NaN scale factor" nanScale = "lapack: NaN scale factor"
negDimension = "lapack: negative matrix dimension" negDimension = "lapack: negative matrix dimension"

View File

@@ -170,10 +170,12 @@ const (
PermuteScale BalanceJob = 'B' PermuteScale BalanceJob = 'B'
) )
// Job constants for Dhseqr. // SchurJob specifies whether the Schur form is computed in Dhseqr.
type SchurJob byte
const ( const (
EigenvaluesOnly EVJob = 'E' EigenvaluesOnly SchurJob = 'E'
EigenvaluesAndSchur EVJob = 'S' EigenvaluesAndSchur SchurJob = 'S'
) )
// EVSide specifies what eigenvectors will be computed. // EVSide specifies what eigenvectors will be computed.

View File

@@ -16,7 +16,7 @@ import (
) )
type Dhseqrer interface { type Dhseqrer interface {
Dhseqr(job lapack.EVJob, compz lapack.EVComp, n, ilo, ihi int, h []float64, ldh int, wr, wi []float64, Dhseqr(job lapack.SchurJob, compz lapack.EVComp, n, ilo, ihi int, h []float64, ldh int, wr, wi []float64,
z []float64, ldz int, work []float64, lwork int) int z []float64, ldz int, work []float64, lwork int) int
} }
@@ -32,7 +32,7 @@ type dhseqrTest struct {
func DhseqrTest(t *testing.T, impl Dhseqrer) { func DhseqrTest(t *testing.T, impl Dhseqrer) {
for i, tc := range dhseqrTests { for i, tc := range dhseqrTests {
for _, job := range []lapack.EVJob{lapack.EigenvaluesOnly, lapack.EigenvaluesAndSchur} { for _, job := range []lapack.SchurJob{lapack.EigenvaluesOnly, lapack.EigenvaluesAndSchur} {
for _, wantz := range []bool{false, true} { for _, wantz := range []bool{false, true} {
for _, extra := range []int{0, 11} { for _, extra := range []int{0, 11} {
testDhseqr(t, impl, i, tc, job, wantz, extra, true) testDhseqr(t, impl, i, tc, job, wantz, extra, true)
@@ -43,7 +43,7 @@ func DhseqrTest(t *testing.T, impl Dhseqrer) {
} }
} }
func testDhseqr(t *testing.T, impl Dhseqrer, i int, test dhseqrTest, job lapack.EVJob, wantz bool, extra int, optwork bool) { func testDhseqr(t *testing.T, impl Dhseqrer, i int, test dhseqrTest, job lapack.SchurJob, wantz bool, extra int, optwork bool) {
const tol = 1e-14 const tol = 1e-14
evTol := test.tol evTol := test.tol
if evTol == 0 { if evTol == 0 {