lapack,mat: rename SVDInPlace constant to SVDStore

This commit is contained in:
Vladimir Chalupecky
2018-10-14 07:37:09 +02:00
committed by Vladimír Chalupecký
parent ac10ac454b
commit 3a1f3daf9f
5 changed files with 23 additions and 24 deletions

View File

@@ -26,7 +26,7 @@ const noSVDO = "dgesvd: not coded for overwrite"
// jobU and jobVT are options for computing the singular vectors. The behavior
// is as follows
// jobU == lapack.SVDAll All m columns of U are returned in u
// jobU == lapack.SVDInPlace The first min(m,n) columns are returned in u
// jobU == lapack.SVDStore The first min(m,n) columns are returned in u
// jobU == lapack.SVDOverwrite The first min(m,n) columns of U are written into a
// jobU == lapack.SVDNone The columns of U are not computed.
// The behavior is the same for jobVT and the rows of V^T. At most one of jobU
@@ -40,12 +40,12 @@ const noSVDO = "dgesvd: not coded for overwrite"
// values in decreasing order.
//
// u contains the left singular vectors on exit, stored column-wise. If
// jobU == lapack.SVDAll, u is of size m×m. If jobU == lapack.SVDInPlace u is
// jobU == lapack.SVDAll, u is of size m×m. If jobU == lapack.SVDStore u is
// of size m×min(m,n). If jobU == lapack.SVDOverwrite or lapack.SVDNone, u is
// not used.
//
// vt contains the left singular vectors on exit, stored row-wise. If
// jobV == lapack.SVDAll, vt is of size n×m. If jobVT == lapack.SVDInPlace vt is
// jobV == lapack.SVDAll, vt is of size n×m. If jobVT == lapack.SVDStore vt is
// of size min(m,n)×n. If jobVT == lapack.SVDOverwrite or lapack.SVDNone, vt is
// not used.
//
@@ -61,12 +61,12 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
checkMatrix(m, n, a, lda)
if jobU == lapack.SVDAll {
checkMatrix(m, m, u, ldu)
} else if jobU == lapack.SVDInPlace {
} else if jobU == lapack.SVDStore {
checkMatrix(m, minmn, u, ldu)
}
if jobVT == lapack.SVDAll {
checkMatrix(n, n, vt, ldvt)
} else if jobVT == lapack.SVDInPlace {
} else if jobVT == lapack.SVDStore {
checkMatrix(minmn, n, vt, ldvt)
}
if jobU == lapack.SVDOverwrite && jobVT == lapack.SVDOverwrite {
@@ -83,13 +83,13 @@ func (impl Implementation) Dgesvd(jobU, jobVT lapack.SVDJob, m, n int, a []float
}
wantua := jobU == lapack.SVDAll
wantus := jobU == lapack.SVDInPlace
wantus := jobU == lapack.SVDStore
wantuas := wantua || wantus
wantuo := jobU == lapack.SVDOverwrite
wantun := jobU == lapack.SVDNone
wantva := jobVT == lapack.SVDAll
wantvs := jobVT == lapack.SVDInPlace
wantvs := jobVT == lapack.SVDStore
wantvas := wantva || wantvs
wantvo := jobVT == lapack.SVDOverwrite
wantvn := jobVT == lapack.SVDNone

View File

@@ -108,10 +108,10 @@ const (
type SVDJob byte
const (
SVDAll SVDJob = 'A' // Compute all singular vectors
SVDInPlace SVDJob = 'S' // Compute the first singular vectors and store them in provided storage.
SVDOverwrite SVDJob = 'O' // Compute the singular vectors and store them in input matrix
SVDNone SVDJob = 'N' // Do not compute singular vectors
SVDAll SVDJob = 'A' // Compute all columns of the matrix U or V.
SVDStore SVDJob = 'S' // Compute the singular vectors and store them in the matrix U or V.
SVDOverwrite SVDJob = 'O' // Compute the singular vectors and overwrite them on the input matrix A.
SVDNone SVDJob = 'N' // Do not compute singular vectors.
)
// GSVDJob specifies the singular vector computation type for Generalized SVD.

View File

@@ -152,7 +152,7 @@ func Gelqf(a blas64.General, tau, work []float64, lwork int) {
// jobU and jobVT are options for computing the singular vectors. The behavior
// is as follows
// jobU == lapack.SVDAll All m columns of U are returned in u
// jobU == lapack.SVDInPlace The first min(m,n) columns are returned in u
// jobU == lapack.SVDStore The first min(m,n) columns are returned in u
// jobU == lapack.SVDOverwrite The first min(m,n) columns of U are written into a
// jobU == lapack.SVDNone The columns of U are not computed.
// The behavior is the same for jobVT and the rows of V^T. At most one of jobU
@@ -166,12 +166,12 @@ func Gelqf(a blas64.General, tau, work []float64, lwork int) {
// values in decreasing order.
//
// u contains the left singular vectors on exit, stored columnwise. If
// jobU == lapack.SVDAll, u is of size m×m. If jobU == lapack.SVDInPlace u is
// jobU == lapack.SVDAll, u is of size m×m. If jobU == lapack.SVDStore u is
// of size m×min(m,n). If jobU == lapack.SVDOverwrite or lapack.SVDNone, u is
// not used.
//
// vt contains the left singular vectors on exit, stored rowwise. If
// jobV == lapack.SVDAll, vt is of size n×m. If jobVT == lapack.SVDInPlace vt is
// jobV == lapack.SVDAll, vt is of size n×m. If jobVT == lapack.SVDStore vt is
// of size min(m,n)×n. If jobVT == lapack.SVDOverwrite or lapack.SVDNone, vt is
// not used.
//

View File

@@ -111,16 +111,16 @@ func DgesvdTest(t *testing.T, impl Dgesvder) {
svdCheck(t, false, errStr, m, n, s, a, u, ldu, vt, ldvt, aCopy, lda)
svdCheckPartial(t, impl, lapack.SVDAll, errStr, uAllOrig, vtAllOrig, aCopy, m, n, a, lda, s, u, ldu, vt, ldvt, work, false)
// Test InPlace
jobU = lapack.SVDInPlace
jobVT = lapack.SVDInPlace
// Test SVDStore
jobU = lapack.SVDStore
jobVT = lapack.SVDStore
copy(a, aCopy)
copy(u, uAllOrig)
copy(vt, vtAllOrig)
impl.Dgesvd(jobU, jobVT, m, n, a, lda, s, u, ldu, vt, ldvt, work, len(work))
svdCheck(t, true, errStr, m, n, s, a, u, ldu, vt, ldvt, aCopy, lda)
svdCheckPartial(t, impl, lapack.SVDInPlace, errStr, uAllOrig, vtAllOrig, aCopy, m, n, a, lda, s, u, ldu, vt, ldvt, work, false)
svdCheckPartial(t, impl, lapack.SVDStore, errStr, uAllOrig, vtAllOrig, aCopy, m, n, a, lda, s, u, ldu, vt, ldvt, work, false)
}
}

View File

@@ -26,15 +26,14 @@ type SVD struct {
//
// The full singular value decomposition (kind == SVDFull) deconstructs A as
// A = U * Σ * V^T
// where Σ is an m×n diagonal matrix of singular vectors, U is an m×m unitary
// where Σ is an m×n diagonal matrix of singular values, U is an m×m unitary
// matrix of left singular vectors, and V is an n×n matrix of right singular vectors.
//
// It is frequently not necessary to compute the full SVD. Computation time and
// storage costs can be reduced using the appropriate kind. Only the singular
// values can be computed (kind == SVDNone), or a "thin" representation of the
// singular vectors (kind = SVDThin). The thin representation can save a significant
// amount of memory if m >> n. See the documentation for the lapack.SVDKind values
// for more information.
// amount of memory if m >> n.
//
// Factorize returns whether the decomposition succeeded. If the decomposition
// failed, routines that require a successful factorization will panic.
@@ -81,8 +80,8 @@ func (svd *SVD) Factorize(a Matrix, kind SVDKind) (ok bool) {
Stride: n,
Data: use(svd.vt.Data, min(m, n)*n),
}
jobU = lapack.SVDInPlace
jobVT = lapack.SVDInPlace
jobU = lapack.SVDStore
jobVT = lapack.SVDStore
}
// A is destroyed on call, so copy the matrix.
@@ -119,7 +118,7 @@ func (svd *SVD) Cond() float64 {
// Values returns the singular values of the factorized matrix in decreasing order.
// If the input slice is non-nil, the values will be stored in-place into the slice.
// In this case, the slice must have length min(m,n), and Values will panic with
// matrix.ErrSliceLengthMismatch otherwise. If the input slice is nil,
// ErrSliceLengthMismatch otherwise. If the input slice is nil,
// a new slice of the appropriate length will be allocated and returned.
//
// Values will panic if the receiver does not contain a successful factorization.