mirror of
https://github.com/gonum/gonum.git
synced 2025-10-06 23:52:47 +08:00
lapack/gonum: clean up implementation comments in Dpbtf2
This commit is contained in:

committed by
Vladimír Chalupecký

parent
3db45405ae
commit
47d77d149e
@@ -47,9 +47,9 @@ import (
|
|||||||
// version.
|
// version.
|
||||||
//
|
//
|
||||||
// Dpbtf2 is an internal routine, exported for testing purposes.
|
// Dpbtf2 is an internal routine, exported for testing purposes.
|
||||||
func (Implementation) Dpbtf2(ul blas.Uplo, n, kd int, ab []float64, ldab int) (ok bool) {
|
func (Implementation) Dpbtf2(uplo blas.Uplo, n, kd int, ab []float64, ldab int) (ok bool) {
|
||||||
switch {
|
switch {
|
||||||
case ul != blas.Upper && ul != blas.Lower:
|
case uplo != blas.Upper && uplo != blas.Lower:
|
||||||
panic(badUplo)
|
panic(badUplo)
|
||||||
case n < 0:
|
case n < 0:
|
||||||
panic(nLT0)
|
panic(nLT0)
|
||||||
@@ -59,6 +59,7 @@ func (Implementation) Dpbtf2(ul blas.Uplo, n, kd int, ab []float64, ldab int) (o
|
|||||||
panic(badLdA)
|
panic(badLdA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quick return if possible.
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -70,16 +71,17 @@ func (Implementation) Dpbtf2(ul blas.Uplo, n, kd int, ab []float64, ldab int) (o
|
|||||||
bi := blas64.Implementation()
|
bi := blas64.Implementation()
|
||||||
|
|
||||||
kld := max(1, ldab-1)
|
kld := max(1, ldab-1)
|
||||||
if ul == blas.Upper {
|
if uplo == blas.Upper {
|
||||||
|
// Compute the Cholesky factorization A = U^T * U.
|
||||||
for j := 0; j < n; j++ {
|
for j := 0; j < n; j++ {
|
||||||
// Compute U(J,J) and test for non positive-definiteness.
|
// Compute U(j,j) and test for non-positive-definiteness.
|
||||||
ajj := ab[j*ldab]
|
ajj := ab[j*ldab]
|
||||||
if ajj <= 0 {
|
if ajj <= 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
ajj = math.Sqrt(ajj)
|
ajj = math.Sqrt(ajj)
|
||||||
ab[j*ldab] = ajj
|
ab[j*ldab] = ajj
|
||||||
// Compute elements j+1:j+kn of row J and update the trailing submatrix
|
// Compute elements j+1:j+kn of row j and update the trailing submatrix
|
||||||
// within the band.
|
// within the band.
|
||||||
kn := min(kd, n-j-1)
|
kn := min(kd, n-j-1)
|
||||||
if kn > 0 {
|
if kn > 0 {
|
||||||
@@ -89,16 +91,16 @@ func (Implementation) Dpbtf2(ul blas.Uplo, n, kd int, ab []float64, ldab int) (o
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// Compute the Cholesky factorization A = L * L^T.
|
||||||
for j := 0; j < n; j++ {
|
for j := 0; j < n; j++ {
|
||||||
// Compute L(J,J) and test for non positive-definiteness.
|
// Compute L(j,j) and test for non-positive-definiteness.
|
||||||
ajj := ab[j*ldab+kd]
|
ajj := ab[j*ldab+kd]
|
||||||
if ajj <= 0 {
|
if ajj <= 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
ajj = math.Sqrt(ajj)
|
ajj = math.Sqrt(ajj)
|
||||||
ab[j*ldab+kd] = ajj
|
ab[j*ldab+kd] = ajj
|
||||||
|
// Compute elements j+1:j+kn of column j and update the trailing submatrix
|
||||||
// Compute elements J+1:J+KN of column J and update the trailing submatrix
|
|
||||||
// within the band.
|
// within the band.
|
||||||
kn := min(kd, n-j-1)
|
kn := min(kd, n-j-1)
|
||||||
if kn > 0 {
|
if kn > 0 {
|
||||||
|
Reference in New Issue
Block a user