From c8e06d77e86d429200a471da3a600aa173e67b47 Mon Sep 17 00:00:00 2001 From: Vladimir Chalupecky Date: Tue, 20 Nov 2018 19:06:43 +0100 Subject: [PATCH] lapack/testlapack: add implementation comments to Dtrtri test --- lapack/testlapack/dtrtri.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lapack/testlapack/dtrtri.go b/lapack/testlapack/dtrtri.go index 71bfc367..3eaa3f82 100644 --- a/lapack/testlapack/dtrtri.go +++ b/lapack/testlapack/dtrtri.go @@ -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++ {