SOLVDS Subroutine

subroutine SOLVDS(NN, A, NWK, MAXA, V)

Uses

  • proc~~solvds~~UsesGraph proc~solvds SOLVDS module~real_precision REAL_PRECISION proc~solvds->module~real_precision

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: NN
real(kind=R8), intent(in) :: A(NWK)
integer, intent(in) :: NWK
integer, intent(in) :: MAXA(NN+1)
real(kind=R8), intent(inout) :: V(NN)

Variables

Type Visibility Attributes Name Initial
integer, public :: K
integer, public :: KK
integer, public :: KL
integer, public :: KU
integer, public :: L
integer, public :: N
real(kind=R8), public :: C

Source Code

      SUBROUTINE SOLVDS(NN,A,NWK,MAXA,V)
C
C     This subroutine solves a system of linear equations Bx=b, where
C     B is symmetric, and is represented by its LDU factorization.
C
C     Input variables:
C
C        NN  -- dimension of B.
C
C        A -- one dimensional real array containing the upper
C             triangular skyline portion of the LDU decomposition 
C             of the symmetric matrix B.  
C
C        NWK  -- number of elements in A.
C
C        MAXA -- an integer array of length NN+1 which contains the
C                location in A of the diagonal elements of B.  
C                By convention, MAXA(NN+1) = NWK+1 .
C
C        V -- real array of length NN containing the vector b.
C
C 
C     Output variables:
C
C        V -- solution of the system of equations B x = b .
C
C
C     No working storage is required by this routine.
C
      USE REAL_PRECISION
      INTEGER, INTENT(IN):: NN,MAXA(NN+1),NWK
      REAL (KIND=R8), INTENT(IN):: A(NWK)
      REAL (KIND=R8), INTENT(IN OUT):: V(NN)
C local variables.
      INTEGER:: K,KK,KL,KU,L,N
      REAL (KIND=R8):: C
      DO N=1,NN
         KL=MAXA(N)+1
         KU=MAXA(N+1)-1
         IF (KU-KL < 0) CYCLE
         K=N
         C=0.0
         DO KK=KL,KU
            K=K-1
            C=C+A(KK)*V(K)
         END DO
         V(N)=V(N)-C
      END DO
      DO N=1,NN
         K=MAXA(N)
         V(N)=V(N)/A(K)
      END DO
      IF (NN.EQ.1) RETURN
      N=NN
      DO L=2,NN
         KL=MAXA(N) + 1
         KU=MAXA(N+1) - 1
         IF (KU-KL .GE. 0) THEN
           K=N
           DO KK=KL,KU
             K=K - 1
             V(K)=V(K) - A(KK)*V(N)
           END DO
         END IF
         N = N - 1
      END DO
      RETURN
      END SUBROUTINE SOLVDS