solution of a system of linear equations with a dense symmetric positive definite matrix a using the factorization a=trans(r)*r.
back substitution
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | n |
order of the matrix a. |
||
| real(kind=wp), | intent(in) | :: | a(*) |
a(n(n+1)/2) factorization a=trans(r)r. |
||
| real(kind=wp), | intent(inout) | :: | x(*) |
x(n) on input the right hand side of a system of linear equations. on output the solution of a system of linear equations. |
||
| integer, | intent(in) | :: | job |
option
|
pure subroutine mxdprb(n,a,x,job) integer,intent(in) :: job !! option !! !! * if job=0 then x:=a**(-1)*x. !! * if job>0 then x:=trans(r)**(-1)*x. !! * if job<0 then x:=r**(-1)*x. integer,intent(in) :: n !! order of the matrix a. real(wp),intent(in) :: a(*) !! a(n*(n+1)/2) factorization a=trans(r)*r. real(wp),intent(inout) :: x(*) !! x(n) on input the right hand side of a system of linear !! equations. on output the solution of a system of linear !! equations. integer :: i , ii , ij , j if ( job>=0 ) then ! phase 1 : x:=trans(r)**(-1)*x ij = 0 do i = 1 , n do j = 1 , i - 1 ij = ij + 1 x(i) = x(i) - a(ij)*x(j) end do ij = ij + 1 x(i) = x(i)/a(ij) end do endif if ( job<=0 ) then ! phase 2 : x:=r**(-1)*x ii = n*(n+1)/2 do i = n , 1 , -1 ij = ii do j = i + 1 , n ij = ij + j - 1 x(i) = x(i) - a(ij)*x(j) end do x(i) = x(i)/a(ii) ii = ii - i end do endif end subroutine mxdprb