1 // Copyright ©2015 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
8 "gonum.org/v1/gonum/blas"
9 "gonum.org/v1/gonum/blas/blas64"
12 // Dpotrf computes the Cholesky decomposition of the symmetric positive definite
13 // matrix a. If ul == blas.Upper, then a is stored as an upper-triangular matrix,
14 // and a = U^T U is stored in place into a. If ul == blas.Lower, then a = L L^T
15 // is computed and stored in-place into a. If a is not positive definite, false
16 // is returned. This is the blocked version of the algorithm.
17 func (impl Implementation) Dpotrf(ul blas.Uplo, n int, a []float64, lda int) (ok bool) {
18 if ul != blas.Upper && ul != blas.Lower {
21 checkMatrix(n, n, a, lda)
27 nb := impl.Ilaenv(1, "DPOTRF", string(ul), n, -1, -1, -1)
28 if nb <= 1 || n <= nb {
29 return impl.Dpotf2(ul, n, a, lda)
31 bi := blas64.Implementation()
33 for j := 0; j < n; j += nb {
35 bi.Dsyrk(blas.Upper, blas.Trans, jb, j,
38 ok = impl.Dpotf2(blas.Upper, jb, a[j*lda+j:], lda)
43 bi.Dgemm(blas.Trans, blas.NoTrans, jb, n-j-jb, j,
44 -1, a[j:], lda, a[j+jb:], lda,
45 1, a[j*lda+j+jb:], lda)
46 bi.Dtrsm(blas.Left, blas.Upper, blas.Trans, blas.NonUnit, jb, n-j-jb,
53 for j := 0; j < n; j += nb {
55 bi.Dsyrk(blas.Lower, blas.NoTrans, jb, j,
58 ok := impl.Dpotf2(blas.Lower, jb, a[j*lda+j:], lda)
63 bi.Dgemm(blas.NoTrans, blas.Trans, n-j-jb, jb, j,
64 -1, a[(j+jb)*lda:], lda, a[j*lda:], lda,
65 1, a[(j+jb)*lda+j:], lda)
66 bi.Dtrsm(blas.Right, blas.Lower, blas.Trans, blas.NonUnit, n-j-jb, jb,
68 a[(j+jb)*lda+j:], lda)