dpofa factors a real symmetric positive definite matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout) | :: | a(lda,*) |
Dimension
|
||
integer, | intent(in) | :: | lda |
the leading dimension of the array |
||
integer, | intent(in) | :: | n |
the order of the matrix a. |
||
integer, | intent(out) | :: | info |
|
subroutine dpofa(a,lda,n,info) integer,intent(in) :: lda !! the leading dimension of the array `a`. integer,intent(in) :: n !! the order of the matrix a. integer,intent(out) :: info !! * `info = 0` for normal return. !! * `info = k` signals an error condition. the leading minor !! of order `k` is not positive definite. real(wp),intent(inout) :: a(lda,*) !! Dimension `(lda, n)`: !! !! * On entry: the symmetric matrix to be factored. only the !! diagonal and upper triangle are used. !! * On return: an upper triangular matrix `r` so that `a = trans(r)*r` !! where `trans(r)` is the transpose. !! the strict lower triangle is unaltered. !! if `info /= 0`, the factorization is not complete. real(wp) :: t real(wp) :: s integer :: j,jm1,k do j = 1, n info = j s = 0.0_wp jm1 = j - 1 if (jm1 >= 1) then do k = 1, jm1 t = a(k,j) - ddot(k-1,a(1,k),1,a(1,j),1) t = t/a(k,k) a(k,j) = t s = s + t*t end do end if s = a(j,j) - s if (s <= 0.0_wp) return a(j,j) = sqrt(s) end do info = 0 end subroutine dpofa