lapack/testlapack: add implementation comments to Dtrtri test

This commit is contained in:
Vladimir Chalupecky
2018-11-20 19:06:43 +01:00
committed by Vladimír Chalupecký
parent 5b0db962f3
commit c8e06d77e8

View File

@@ -40,6 +40,7 @@ func DtrtriTest(t *testing.T, impl Dtrtrier) {
if lda == 0 {
lda = n
}
// Allocate n×n matrix A and fill it with random numbers.
a := make([]float64, n*lda)
for i := range a {
a[i] = rnd.Float64()
@@ -50,7 +51,9 @@ func DtrtriTest(t *testing.T, impl Dtrtrier) {
}
aCopy := make([]float64, len(a))
copy(aCopy, a)
// Compute the inverse of the uplo triangle.
impl.Dtrtri(uplo, diag, n, a, lda)
// Zero out the opposite triangle.
if uplo == blas.Upper {
for i := 1; i < n; i++ {
for j := 0; j < i; j++ {
@@ -67,13 +70,16 @@ func DtrtriTest(t *testing.T, impl Dtrtrier) {
}
}
if diag == blas.Unit {
// Set the diagonal explicitly to 1.
for i := 0; i < n; i++ {
a[i*lda+i] = 1
aCopy[i*lda+i] = 1
}
}
// Compute A^{-1} * A and store the result in ans.
ans := make([]float64, len(a))
bi.Dgemm(blas.NoTrans, blas.NoTrans, n, n, n, 1, a, lda, aCopy, lda, 0, ans, lda)
// Check that ans is the identity matrix.
iseye := true
for i := 0; i < n; i++ {
for j := 0; j < n; j++ {