lapack: rename DecompUpdate and add GenOrtho types and consts
MODIFY
lapack/gonum/dgesvd.go
lapack/gonum/dgesvd.go
@@ -112,9 +112,9 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
lwork_dorgqr_m := int(work[0])
impl.Dgebrd(n, n, a, lda, s, nil, nil, nil, work, -1)
lwork_dgebrd := int(work[0])
- impl.Dorgbr(lapack.ApplyP, n, n, n, a, lda, nil, work, -1)
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, a, lda, nil, work, -1)
lwork_dorgbr_p := int(work[0])
- impl.Dorgbr(lapack.ApplyQ, n, n, n, a, lda, nil, work, -1)
+ impl.Dorgbr(lapack.GenerateQ, n, n, n, a, lda, nil, work, -1)
lwork_dorgbr_q := int(work[0])
if m >= mnthr {
@@ -203,12 +203,12 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
lwork_dgebrd := int(work[0])
maxwrk = 3*n + lwork_dgebrd
if wantus || wantuo {
- impl.Dorgbr(lapack.ApplyQ, m, n, n, a, lda, nil, work, -1)
+ impl.Dorgbr(lapack.GenerateQ, m, n, n, a, lda, nil, work, -1)
lwork_dorgbr_q = int(work[0])
maxwrk = max(maxwrk, 3*n+lwork_dorgbr_q)
}
if wantua {
- impl.Dorgbr(lapack.ApplyQ, m, m, n, a, lda, nil, work, -1)
+ impl.Dorgbr(lapack.GenerateQ, m, m, n, a, lda, nil, work, -1)
lwork_dorgbr_q := int(work[0])
maxwrk = max(maxwrk, 3*n+lwork_dorgbr_q)
}
@@ -229,9 +229,9 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
lwork_dorglq_m := int(work[0])
impl.Dgebrd(m, m, a, lda, s, nil, nil, nil, work, -1)
lwork_dgebrd := int(work[0])
- impl.Dorgbr(lapack.ApplyP, m, m, m, a, n, nil, work, -1)
+ impl.Dorgbr(lapack.GeneratePT, m, m, m, a, n, nil, work, -1)
lwork_dorgbr_p := int(work[0])
- impl.Dorgbr(lapack.ApplyQ, m, m, m, a, n, nil, work, -1)
+ impl.Dorgbr(lapack.GenerateQ, m, m, m, a, n, nil, work, -1)
lwork_dorgbr_q := int(work[0])
if n >= mnthr {
// n >> m
@@ -319,12 +319,12 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
lwork_dgebrd = int(work[0])
maxwrk = 3*m + lwork_dgebrd
if wantvs || wantvo {
- impl.Dorgbr(lapack.ApplyP, m, n, m, a, n, nil, work, -1)
+ impl.Dorgbr(lapack.GeneratePT, m, n, m, a, n, nil, work, -1)
lwork_dorgbr_p = int(work[0])
maxwrk = max(maxwrk, 3*m+lwork_dorgbr_p)
}
if wantva {
- impl.Dorgbr(lapack.ApplyP, n, n, m, a, n, nil, work, -1)
+ impl.Dorgbr(lapack.GeneratePT, n, n, m, a, n, nil, work, -1)
lwork_dorgbr_p = int(work[0])
maxwrk = max(maxwrk, 3*m+lwork_dorgbr_p)
}
@@ -398,8 +398,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
work[itaup:], work[iwork:], lwork-iwork)
ncvt := 0
if wantvo || wantvas {
- // Generate P^T.
- impl.Dorgbr(lapack.ApplyP, n, n, n, a, lda, work[itaup:],
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, a, lda, work[itaup:],
work[iwork:], lwork-iwork)
ncvt = n
}
@@ -453,7 +452,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
work[itauq:], work[itaup:], work[iwork:], lwork-iwork)
// Generate left vectors bidiagonalizing R in work[ir:].
- impl.Dorgbr(lapack.ApplyQ, n, n, n, work[ir:], ldworkr,
+ impl.Dorgbr(lapack.GenerateQ, n, n, n, work[ir:], ldworkr,
work[itauq:], work[iwork:], lwork-iwork)
iwork = ie + n
@@ -536,11 +535,11 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
impl.Dlacpy(blas.Upper, n, n, work[iu:], ldworku, vt, ldvt)
// Generate left bidiagonalizing vectors in work[iu:].
- impl.Dorgbr(lapack.ApplyQ, n, n, n, work[iu:], ldworku,
+ impl.Dorgbr(lapack.GenerateQ, n, n, n, work[iu:], ldworku,
work[itauq:], work[iwork:], lwork-iwork)
// Generate right bidiagonalizing vectors in VT.
- impl.Dorgbr(lapack.ApplyP, n, n, n, vt, ldvt,
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, vt, ldvt,
work[itaup:], work[iwork:], lwork-iwork)
iwork = ie + n
@@ -584,7 +583,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
vt, ldvt, work[itauq:], u, ldu, work[iwork:], lwork-iwork)
// Generate right bidiagonalizing vectors in VT.
- impl.Dorgbr(lapack.ApplyP, n, n, n, vt, ldvt,
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, vt, ldvt,
work[itaup:], work[iwork:], lwork-iwork)
iwork = ie + n
@@ -630,7 +629,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
work[itauq:], work[itaup:], work[iwork:], lwork-iwork)
// Generate left bidiagonalizing vectors in work[ir:].
- impl.Dorgbr(lapack.ApplyQ, n, n, n, work[ir:], ldworkr,
+ impl.Dorgbr(lapack.GenerateQ, n, n, n, work[ir:], ldworkr,
work[itauq:], work[iwork:], lwork-iwork)
iwork = ie + n
@@ -718,11 +717,11 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
impl.Dlacpy(blas.Upper, n, n, work[iu:], ldworku, vt, ldvt)
// Generate left bidiagonalizing vectors in work[iu:].
- impl.Dorgbr(lapack.ApplyQ, n, n, n, work[iu:], ldworku,
+ impl.Dorgbr(lapack.GenerateQ, n, n, n, work[iu:], ldworku,
work[itauq:], work[iwork:], lwork-iwork)
// Generate right bidiagonalizing vectors in VT.
- impl.Dorgbr(lapack.ApplyP, n, n, n, vt, ldvt,
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, vt, ldvt,
work[itaup:], work[iwork:], lwork-iwork)
iwork = ie + n
@@ -750,7 +749,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
m, n, n, vt, ldvt, work[itauq:], u, ldu, work[iwork:], lwork-iwork)
// Generate right bidiagonalizing vectors in VT.
- impl.Dorgbr(lapack.ApplyP, n, n, n, vt, ldvt,
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, vt, ldvt,
work[itaup:], work[iwork:], lwork-iwork)
iwork = ie + n
@@ -790,7 +789,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
m, n, n, vt, ldvt, work[itauq:], u, ldu, work[iwork:], lwork-iwork)
// Generate right bidiagonizing vectors in VT.
- impl.Dorgbr(lapack.ApplyP, n, n, n, vt, ldvt,
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, vt, ldvt,
work[itaup:], work[iwork:], lwork-iwork)
iwork = ie + n
@@ -824,13 +823,13 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
if wantua {
ncu = m
}
- impl.Dorgbr(lapack.ApplyQ, m, ncu, n, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GenerateQ, m, ncu, n, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
}
if wantvas {
// Right singular vectors are desired in VT. Copy result to VT and
// generate left biadiagonalizing vectors in VT.
impl.Dlacpy(blas.Upper, n, n, a, lda, vt, ldvt)
- impl.Dorgbr(lapack.ApplyP, n, n, n, vt, ldvt, work[itaup:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GeneratePT, n, n, n, vt, ldvt, work[itaup:], work[iwork:], lwork-iwork)
}
if wantuo {
panic(noSVDO)
@@ -886,7 +885,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
impl.Dgebrd(m, m, a, lda, s, work[ie:itauq],
work[itauq:itaup], work[itaup:iwork], work[iwork:], lwork-iwork)
if wantuo || wantuas {
- impl.Dorgbr(lapack.ApplyQ, m, m, m, a, lda,
+ impl.Dorgbr(lapack.GenerateQ, m, m, m, a, lda,
work[itauq:], work[iwork:], lwork-iwork)
}
iwork = ie + m
@@ -944,7 +943,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
work[itauq:], work[itaup:], work[iwork:], lwork-iwork)
// Generate right vectors bidiagonalizing L in work[ir:].
- impl.Dorgbr(lapack.ApplyP, m, m, m, work[ir:], ldworkr,
+ impl.Dorgbr(lapack.GeneratePT, m, m, m, work[ir:], ldworkr,
work[itaup:], work[iwork:], lwork-iwork)
iwork = ie + m
@@ -1029,11 +1028,11 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
impl.Dlacpy(blas.Lower, m, m, work[iu:], ldworku, u, ldu)
// Generate right bidiagionalizing vectors in work[iu:].
- impl.Dorgbr(lapack.ApplyP, m, m, m, work[iu:], ldworku,
+ impl.Dorgbr(lapack.GeneratePT, m, m, m, work[iu:], ldworku,
work[itaup:], work[iwork:], lwork-iwork)
// Generate left bidiagonalizing vectors in U.
- impl.Dorgbr(lapack.ApplyQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GenerateQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
iwork = ie + m
// Perform bidiagonal QR iteration, computing left singular
@@ -1076,7 +1075,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
u, ldu, work[itaup:], vt, ldvt, work[iwork:], lwork-iwork)
// Generate left bidiagonalizing vectors in U.
- impl.Dorgbr(lapack.ApplyQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GenerateQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
iwork = ie + m
// Perform bidiagonal QR iteration, computing left singular
@@ -1122,7 +1121,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
work[itauq:], work[itaup:], work[iwork:], lwork-iwork)
// Generate right bidiagonalizing vectors in work[ir:].
- impl.Dorgbr(lapack.ApplyP, m, m, m, work[ir:], ldworkr,
+ impl.Dorgbr(lapack.GeneratePT, m, m, m, work[ir:], ldworkr,
work[itaup:], work[iwork:], lwork-iwork)
iwork = ie + m
@@ -1209,11 +1208,11 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
impl.Dlacpy(blas.Lower, m, m, work[iu:], ldworku, u, ldu)
// Generate right bidiagonalizing vectors in work[iu:].
- impl.Dorgbr(lapack.ApplyP, m, m, m, work[iu:], ldworku,
+ impl.Dorgbr(lapack.GeneratePT, m, m, m, work[iu:], ldworku,
work[itaup:], work[iwork:], lwork-iwork)
// Generate left bidiagonalizing vectors in U.
- impl.Dorgbr(lapack.ApplyQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GenerateQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
iwork = ie + m
// Perform bidiagonal QR iteration, computing left singular
@@ -1259,7 +1258,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
u, ldu, work[itaup:], vt, ldvt, work[iwork:], lwork-iwork)
// Generate left bidiagonalizing vectors in U.
- impl.Dorgbr(lapack.ApplyQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GenerateQ, m, m, m, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
iwork = ie + m
// Perform bidiagonal QR iteration, computing left singular
@@ -1284,7 +1283,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
// If left singular vectors desired in U, copy result to U and
// generate left bidiagonalizing vectors in U.
impl.Dlacpy(blas.Lower, m, m, a, lda, u, ldu)
- impl.Dorgbr(lapack.ApplyQ, m, m, n, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GenerateQ, m, m, n, u, ldu, work[itauq:], work[iwork:], lwork-iwork)
}
if wantvas {
// If right singular vectors desired in VT, copy result to VT
@@ -1296,7 +1295,7 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
} else {
nrvt = m
}
- impl.Dorgbr(lapack.ApplyP, nrvt, n, m, vt, ldvt, work[itaup:], work[iwork:], lwork-iwork)
+ impl.Dorgbr(lapack.GeneratePT, nrvt, n, m, vt, ldvt, work[itaup:], work[iwork:], lwork-iwork)
}
if wantuo {
panic(noSVDO)

MODIFY
lapack/gonum/dormbr.go
lapack/gonum/dormbr.go
@@ -44,7 +44,7 @@ import (
// returns it in work[0].
//
// Dormbr is an internal routine. It is exported for testing purposes.
-func (impl Implementation) Dormbr(vect lapack.DecompUpdate, side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int) {
+func (impl Implementation) Dormbr(vect lapack.ApplyOrtho, side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int) {
if side != blas.Left && side != blas.Right {
panic(badSide)
}
@@ -52,7 +52,7 @@ func (impl Implementation) Dormbr(vect lapack.DecompUpdate, side blas.Side, tran
panic(badTrans)
}
if vect != lapack.ApplyP && vect != lapack.ApplyQ {
- panic(badDecompUpdate)
+ panic(badApplyOrtho)
}
nq := n
nw := m

MODIFY
lapack/gonum/general.go
lapack/gonum/general.go
@@ -19,10 +19,10 @@ var _ lapack.Float64 = Implementation{}
const (
absIncNotOne = "lapack: increment not one or negative one"
badAlpha = "lapack: bad alpha length"
+ badApplyOrtho = "lapack: bad ApplyOrtho"
badAuxv = "lapack: auxv has insufficient length"
badBeta = "lapack: bad beta length"
badD = "lapack: d has insufficient length"
- badDecompUpdate = "lapack: bad decomp update"
badDiag = "lapack: bad diag"
badDims = "lapack: bad input dimensions"
badDirect = "lapack: bad direct"
@@ -31,6 +31,7 @@ const (
badEVHowMany = "lapack: bad EVHowMany"
badEVJob = "lapack: bad EVJob"
badEVSide = "lapack: bad EVSide"
+ badGenOrtho = "lapack: bad GenOrtho"
badGSVDJob = "lapack: bad GSVDJob"
badIlo = "lapack: ilo out of range"
badIhi = "lapack: ihi out of range"

MODIFY
lapack/lapack.go
lapack/lapack.go
@@ -90,11 +90,20 @@ const (
Bottom Pivot = 'B'
)
-type DecompUpdate byte
+// ApplyOrtho specifies which orthogonal matrix is applied in Dormbr.
+type ApplyOrtho byte
const (
- ApplyP DecompUpdate = 'P'
- ApplyQ DecompUpdate = 'Q'
+ ApplyP ApplyOrtho = 'P' // Apply P or P^T.
+ ApplyQ ApplyOrtho = 'Q' // Apply Q or Q^T.
+)
+
+// GenOrtho specifies which orthogonal matrix is generated in Dorgbr.
+type GenOrtho byte
+
+const (
+ GeneratePT GenOrtho = 'P' // Generate P^T.
+ GenerateQ GenOrtho = 'Q' // Generate Q.
)
// SVDJob specifies the singular vector computation type for SVD.

MODIFY
lapack/testlapack/dorgbr.go
lapack/testlapack/dorgbr.go
@@ -15,13 +15,13 @@ import (
)
type Dorgbrer interface {
- Dorgbr(vect lapack.DecompUpdate, m, n, k int, a []float64, lda int, tau, work []float64, lwork int)
+ Dorgbr(vect lapack.GenOrtho, m, n, k int, a []float64, lda int, tau, work []float64, lwork int)
Dgebrder
}
func DorgbrTest(t *testing.T, impl Dorgbrer) {
rnd := rand.New(rand.NewSource(1))
- for _, vect := range []lapack.DecompUpdate{lapack.ApplyQ, lapack.ApplyP} {
+ for _, vect := range []lapack.GenOrtho{lapack.GenerateQ, lapack.GeneratePT} {
for _, test := range []struct {
m, n, k, lda int
}{
@@ -52,7 +52,7 @@ func DorgbrTest(t *testing.T, impl Dorgbrer) {
k := test.k
lda := test.lda
// Filter out bad tests
- if vect == lapack.ApplyQ {
+ if vect == lapack.GenerateQ {
if m < n || n < min(m, k) || m < min(m, k) {
continue
}
@@ -63,7 +63,7 @@ func DorgbrTest(t *testing.T, impl Dorgbrer) {
}
// Sizes for Dorgbr.
var ma, na int
- if vect == lapack.ApplyQ {
+ if vect == lapack.GenerateQ {
if m >= k {
ma = m
na = k
@@ -83,7 +83,7 @@ func DorgbrTest(t *testing.T, impl Dorgbrer) {
// a eventually needs to store either P or Q, so it must be
// sufficiently big.
var a []float64
- if vect == lapack.ApplyQ {
+ if vect == lapack.GenerateQ {
lda = max(m, lda)
a = make([]float64, m*lda)
} else {
@@ -110,7 +110,7 @@ func DorgbrTest(t *testing.T, impl Dorgbrer) {
copy(aCopy, a)
var tau []float64
- if vect == lapack.ApplyQ {
+ if vect == lapack.GenerateQ {
tau = tauQ
} else {
tau = tauP
@@ -124,20 +124,20 @@ func DorgbrTest(t *testing.T, impl Dorgbrer) {
var ans blas64.General
var nRows, nCols int
equal := true
- if vect == lapack.ApplyQ {
+ if vect == lapack.GenerateQ {
nRows = m
nCols = m
if m >= k {
nCols = n
}
- ans = constructQPBidiagonal(vect, ma, na, min(m, k), aCopy, lda, tau)
+ ans = constructQPBidiagonal(lapack.ApplyQ, ma, na, min(m, k), aCopy, lda, tau)
} else {
nRows = n
if k < n {
nRows = m
}
nCols = n
- ansTmp := constructQPBidiagonal(vect, ma, na, min(k, n), aCopy, lda, tau)
+ ansTmp := constructQPBidiagonal(lapack.ApplyP, ma, na, min(k, n), aCopy, lda, tau)
// Dorgbr actually computes P^T
ans = transposeGeneral(ansTmp)
}
@@ -149,8 +149,7 @@ func DorgbrTest(t *testing.T, impl Dorgbrer) {
}
}
if !equal {
- applyQ := vect == lapack.ApplyQ
- t.Errorf("Extracted matrix mismatch. applyQ: %v, m = %v, n = %v, k = %v", applyQ, m, n, k)
+ t.Errorf("Extracted matrix mismatch. gen = %v, m = %v, n = %v, k = %v", string(vect), m, n, k)
}
}
}

MODIFY
lapack/testlapack/dormbr.go
lapack/testlapack/dormbr.go
@@ -16,14 +16,14 @@ import (
)
type Dormbrer interface {
- Dormbr(vect lapack.DecompUpdate, side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int)
+ Dormbr(vect lapack.ApplyOrtho, side blas.Side, trans blas.Transpose, m, n, k int, a []float64, lda int, tau, c []float64, ldc int, work []float64, lwork int)
Dgebrder
}
func DormbrTest(t *testing.T, impl Dormbrer) {
rnd := rand.New(rand.NewSource(1))
bi := blas64.Implementation()
- for _, vect := range []lapack.DecompUpdate{lapack.ApplyQ, lapack.ApplyP} {
+ for _, vect := range []lapack.ApplyOrtho{lapack.ApplyQ, lapack.ApplyP} {
for _, side := range []blas.Side{blas.Left, blas.Right} {
for _, trans := range []blas.Transpose{blas.NoTrans, blas.Trans} {
for _, wl := range []worklen{minimumWork, mediumWork, optimumWork} {

MODIFY
lapack/testlapack/general.go
lapack/testlapack/general.go
@@ -681,7 +681,7 @@ func checkBidiagonal(t *testing.T, m, n, nb int, a []float64, lda int, d, e, tau
// constructQPBidiagonal constructs Q or P from the Bidiagonal decomposition
// computed by dlabrd and bgebd2.
-func constructQPBidiagonal(vect lapack.DecompUpdate, m, n, nb int, a []float64, lda int, tau []float64) blas64.General {
+func constructQPBidiagonal(vect lapack.ApplyOrtho, m, n, nb int, a []float64, lda int, tau []float64) blas64.General {
sz := n
if vect == lapack.ApplyQ {
sz = m

lapack: rename DecompUpdate and add GenOrtho types and consts