github.com/gopherd/gonum@v0.0.4/lapack/gonum/dpotri.go (about) 1 // Copyright ©2019 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. 4 5 package gonum 6 7 import "github.com/gopherd/gonum/blas" 8 9 // Dpotri computes the inverse of a real symmetric positive definite matrix A 10 // using its Cholesky factorization. 11 // 12 // On entry, a contains the triangular factor U or L from the Cholesky 13 // factorization A = Uᵀ*U or A = L*Lᵀ, as computed by Dpotrf. 14 // On return, a contains the upper or lower triangle of the (symmetric) 15 // inverse of A, overwriting the input factor U or L. 16 func (impl Implementation) Dpotri(uplo blas.Uplo, n int, a []float64, lda int) (ok bool) { 17 switch { 18 case uplo != blas.Upper && uplo != blas.Lower: 19 panic(badUplo) 20 case n < 0: 21 panic(nLT0) 22 case lda < max(1, n): 23 panic(badLdA) 24 } 25 26 // Quick return if possible. 27 if n == 0 { 28 return true 29 } 30 31 if len(a) < (n-1)*lda+n { 32 panic(shortA) 33 } 34 35 // Invert the triangular Cholesky factor U or L. 36 ok = impl.Dtrtri(uplo, blas.NonUnit, n, a, lda) 37 if !ok { 38 return false 39 } 40 41 // Form inv(U)*inv(U)ᵀ or inv(L)ᵀ*inv(L). 42 impl.Dlauum(uplo, n, a, lda) 43 return true 44 }