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.
10 "gonum.org/v1/gonum/blas"
11 "gonum.org/v1/gonum/blas/blas64"
14 // Dpotf2 computes the Cholesky decomposition of the symmetric positive definite
15 // matrix a. If ul == blas.Upper, then a is stored as an upper-triangular matrix,
16 // and a = U^T U is stored in place into a. If ul == blas.Lower, then a = L L^T
17 // is computed and stored in-place into a. If a is not positive definite, false
18 // is returned. This is the unblocked version of the algorithm.
20 // Dpotf2 is an internal routine. It is exported for testing purposes.
21 func (Implementation) Dpotf2(ul blas.Uplo, n int, a []float64, lda int) (ok bool) {
22 if ul != blas.Upper && ul != blas.Lower {
25 checkMatrix(n, n, a, lda)
31 bi := blas64.Implementation()
33 for j := 0; j < n; j++ {
36 ajj -= bi.Ddot(j, a[j:], lda, a[j:], lda)
38 if ajj <= 0 || math.IsNaN(ajj) {
45 bi.Dgemv(blas.Trans, j, n-j-1,
46 -1, a[j+1:], lda, a[j:], lda,
48 bi.Dscal(n-j-1, 1/ajj, a[j*lda+j+1:], 1)
53 for j := 0; j < n; j++ {
56 ajj -= bi.Ddot(j, a[j*lda:], 1, a[j*lda:], 1)
58 if ajj <= 0 || math.IsNaN(ajj) {
65 bi.Dgemv(blas.NoTrans, n-j-1, j,
66 -1, a[(j+1)*lda:], lda, a[j*lda:], 1,
67 1, a[(j+1)*lda+j:], lda)
68 bi.Dscal(n-j-1, 1/ajj, a[(j+1)*lda+j:], lda)