lapack/testlapack: fix comments and error messages about orthogonality

This commit is contained in:
Vladimir Chalupecky
2018-07-24 15:48:19 +02:00
committed by Vladimír Chalupecký
parent 22345aeeda
commit 25826f7966
4 changed files with 6 additions and 5 deletions

View File

@@ -72,7 +72,7 @@ func Dgeql2Test(t *testing.T, impl Dgeql2er) {
blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, h, qTmp, 0, q) blas64.Gemm(blas.NoTrans, blas.NoTrans, 1, h, qTmp, 0, q)
} }
if !isOrthogonal(q) { if !isOrthogonal(q) {
t.Errorf("Q is not orthonormal") t.Errorf("Q is not orthogonal")
} }
l := blas64.General{ l := blas64.General{
Rows: m, Rows: m,

View File

@@ -134,7 +134,7 @@ func DlatrdTest(t *testing.T, impl Dlatrder) {
} }
errStr := fmt.Sprintf("isUpper = %v, n = %v, nb = %v", uplo == blas.Upper, n, nb) errStr := fmt.Sprintf("isUpper = %v, n = %v, nb = %v", uplo == blas.Upper, n, nb)
if !isOrthogonal(q) { if !isOrthogonal(q) {
t.Errorf("Q not orthonormal. %s", errStr) t.Errorf("Q not orthogonal. %s", errStr)
} }
aGen := genFromSym(blas64.Symmetric{N: n, Stride: lda, Uplo: uplo, Data: aCopy}) aGen := genFromSym(blas64.Symmetric{N: n, Stride: lda, Uplo: uplo, Data: aCopy})
if !dlatrdCheckDecomposition(t, uplo, n, nb, e, tau, a, lda, aGen, q) { if !dlatrdCheckDecomposition(t, uplo, n, nb, e, tau, a, lda, aGen, q) {

View File

@@ -48,12 +48,12 @@ func Dorg2lTest(t *testing.T, impl Dorg2ler) {
copy(aCopy, a) copy(aCopy, a)
impl.Dorg2l(m, n, k, a, lda, tau[n-k:], work) impl.Dorg2l(m, n, k, a, lda, tau[n-k:], work)
if !hasOrthonormalColumns(m, n, a, lda) { if !hasOrthonormalColumns(m, n, a, lda) {
t.Errorf("Q is not orthonormal. m = %v, n = %v, k = %v", m, n, k) t.Errorf("Case m=%v, n=%v, k=%v: columns of Q not orthonormal", m, n, k)
} }
} }
} }
// hasOrthornormalColumns checks that the columns of a are orthonormal. // hasOrthonormalColumns returns whether the columns of A are orthonormal.
func hasOrthonormalColumns(m, n int, a []float64, lda int) bool { func hasOrthonormalColumns(m, n int, a []float64, lda int) bool {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
for j := i; j < n; j++ { for j := i; j < n; j++ {

View File

@@ -60,13 +60,14 @@ func DsteqrTest(t *testing.T, impl Dsteqrer) {
aCopy := make([]float64, len(a)) aCopy := make([]float64, len(a))
copy(aCopy, a) copy(aCopy, a)
if compz == lapack.OriginalEV { if compz == lapack.OriginalEV {
// Compute triangular decomposition and orthonormal matrix.
uplo := blas.Upper uplo := blas.Upper
tau := make([]float64, n) tau := make([]float64, n)
work := make([]float64, 1) work := make([]float64, 1)
impl.Dsytrd(blas.Upper, n, a, lda, d, e, tau, work, -1) impl.Dsytrd(blas.Upper, n, a, lda, d, e, tau, work, -1)
work = make([]float64, int(work[0])) work = make([]float64, int(work[0]))
// Reduce A to symmetric tridiagonal form.
impl.Dsytrd(uplo, n, a, lda, d, e, tau, work, len(work)) impl.Dsytrd(uplo, n, a, lda, d, e, tau, work, len(work))
// Compute the orthogonal matrix Q.
impl.Dorgtr(uplo, n, a, lda, tau, work, len(work)) impl.Dorgtr(uplo, n, a, lda, tau, work, len(work))
} else { } else {
for i := 0; i < n; i++ { for i := 0; i < n; i++ {