Skip to content

Commit

Permalink
lapack/testlapack: add implementation comments to Dgebd2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-ch committed Dec 1, 2018
1 parent eb65047 commit a7eb776
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lapack/testlapack/dgebd2.go
Expand Up @@ -30,26 +30,31 @@ func Dgebd2Test(t *testing.T, impl Dgebd2er) {
if lda == 0 {
lda = n
}
nb := min(m, n) // 'nb' name parallel with Dlabrd code.
// Allocate m×n matrix A and fill it with random numbers.
a := make([]float64, m*lda)
for i := range a {
a[i] = rnd.NormFloat64()
}
// Store a copy of A for later comparison.
aCopy := make([]float64, len(a))
copy(aCopy, a)
// Allocate slices for the main and off diagonal.
nb := min(m, n)
d := nanSlice(nb)
e := nanSlice(nb - 1)
// Allocate slices for scalar factors of elementary reflectors
// and fill them with NaNs.
tauP := nanSlice(nb)
tauQ := nanSlice(nb)
// Allocate workspace.
work := nanSlice(max(m, n))
aCopy := make([]float64, len(a))
copy(aCopy, a)

// Reduce A to upper or lower bidiagonal form by an orthogonal
// transformation.
impl.Dgebd2(m, n, a, lda, d, e, tauQ, tauP, work)
if m >= n && nb == n {
tauP[n-1] = 0
}
if m < n && nb == m {
tauQ[m-1] = 0
}

// Check that it holds Q^T * A * P = B where B is represented by
// d and e.
checkBidiagonal(t, m, n, nb, a, lda, d, e, tauP, tauQ, aCopy)
}
}

0 comments on commit a7eb776

Please sign in to comment.