C-------------------------------------------------------------     ************
C                                                                      FOLR
C                                                                  ************
      SUBROUTINE FOLR(N,A,INCA,B,INCB)
C
C     Solves first order linear recurrences of the form:
C             c(i) = -a(i)*c(i-1) + b(i)
C     Martin J. McBride.  8/8/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,IA,IB
      REAL A(1),B(1),CUR,PRV

C  Set up initial conditions.
      IF (N .LT. 1) RETURN
      IA = 1
      IB = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCB .NE. 0) GO TO 20

C  First order linear recurrence where the increment to the recurrence vector
C  is equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    FOLR.  Output will reproduce CRAY SCILIB action.   *'
      PRINT*,'*********************************************************'
      PRINT*
      CUR = B(IB+INCB)
      PRV = B(IB)
      DO 10 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         B(IB) = -A(IA)*CUR + PRV
         PRV = CUR
         CUR = B(IB)
   10 CONTINUE
      RETURN

C  First order linear recurrence with vector B becoming the result vector.
   20 DO 30 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         B(IB) = -A(IA)*B(IB-INCB) + B(IB)
   30 CONTINUE
      RETURN
      END

C-------------------------------------------------------------     ************
C                                                                     FOLRP
C                                                                  ************
      SUBROUTINE FOLRP(N,A,INCA,B,INCB)
C
C     Solves first order linear recurrences of the form:
C             c(i) = a(i)*c(i-1) + b(i)
C     Martin J. McBride.  8/9/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,IA,IB
      REAL A(1),B(1),CUR,PRV

C  Set up initial conditions.
      IF (N .LT. 1) RETURN
      IA = 1
      IB = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCB .NE. 0) GO TO 20

C  First order linear recurrence where the increment to the recurrence vector
C  is equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    FOLRP.  Output will reproduce CRAY SCILIB action.  *'
      PRINT*,'*********************************************************'
      PRINT*
      CUR = B(IB+INCB)
      PRV = B(IB)
      DO 10 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         B(IB) = A(IA)*CUR + PRV
         PRV = CUR
         CUR = B(IB)
   10 CONTINUE
      RETURN

C  First order linear recurrence with vector B becoming the result vector.
   20 DO 30 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         B(IB) = A(IA)*B(IB-INCB) + B(IB)
   30 CONTINUE
      RETURN
      END

C-------------------------------------------------------------     ************
C                                                                     FOLR2
C                                                                  ************
      SUBROUTINE FOLR2(N,A,INCA,B,INCB,C,INCC)
C
C     Solves first order linear recurrences of the form:
C             c(i) = -a(i)*c(i-1) + b(i)
C     Martin J. McBride.  8/9/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,INCC,IA,IB,IC
      REAL A(1),B(1),C(1),CUR,PRV

C  Set up initial conditions.
      IF (N .LT. 1) RETURN
      IA = 1
      IB = 1
      IC = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCC .LT. 0) IC = (-N+1)*INCC + 1
      C(IC) = B(IB)
      IF (INCC .NE. 0) GO TO 20
      
C  First order linear recurrence where the increment to the recurrence vector
C  is equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    FOLR2.  Output will reproduce CRAY SCILIB action.  *'
      PRINT*,'*********************************************************'
      PRINT*
      CUR = B(IB+INCB)
      PRV = B(IB)
      DO 10 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         IC = IC + INCC
         C(IC) = -A(IA)*CUR + PRV
         PRV = CUR
         CUR = C(IC)
   10 CONTINUE
      RETURN

C  First order linear recurrence with result vector C.
   20 DO 30 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         IC = IC + INCC
         C(IC) = -A(IA)*C(IC-INCC) + B(IB)
   30 CONTINUE
      RETURN
      END

C-------------------------------------------------------------     ************
C                                                                     FOLR2P
C                                                                  ************
      SUBROUTINE FOLR2P(N,A,INCA,B,INCB,C,INCC)
C
C     Solves first order linear recurrences of the form:
C             c(i) = a(i)*c(i-1) + b(i)
C     Martin J. McBride.  8/9/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,INCC,IA,IB,IC
      REAL A(1),B(1),C(1),CUR,PRV

C  Set up initial conditions.
      IF (N .LT. 1) RETURN
      IA = 1
      IB = 1
      IC = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCC .LT. 0) IC = (-N+1)*INCC + 1
      C(IC) = B(IB)
      IF (INCC .NE. 0) GO TO 20
      
C  First order linear recurrence where the increment to the recurrence vector
C  is equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    FOLR2P.  Output will reproduce CRAY SCILIB action. *'
      PRINT*,'*********************************************************'
      PRINT*
      CUR = B(IB+INCB)
      PRV = B(IB)
      DO 10 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         IC = IC + INCC
         C(IC) = A(IA)*CUR + PRV
         PRV = CUR
         CUR = C(IC)
   10 CONTINUE
      RETURN

C  First order linear recurrence with result vector C.
   20 DO 30 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         IC = IC + INCC
         C(IC) = A(IA)*C(IC-INCC) + B(IB)
   30 CONTINUE
      RETURN
      END

C-------------------------------------------------------------     ************
C                                                                     FOLRN
C                                                                  ************
      REAL FUNCTION FOLRN(N,A,INCA,B,INCB)
C
C     Solves for only the last term of first order linear
C          recurrences of the form:
C             c(i) = -a(i)*c(i-1) + b(i)
C     Martin J. McBride.  8/8/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,IA,IB
      REAL A(1),B(1),C

C  Set up initial conditions.
      FOLRN = 0.0
      IF (N .LT. 1) RETURN
      IA = 1
      IB = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCB .NE. 0) GO TO 10

C  Warning message for increment of recurrence vector, B, equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    FOLRN.  Output will reproduce CRAY SCILIB action.  *'
      PRINT*,'*********************************************************'
      PRINT*

C  Linear recurrence with C used to determine the last term.
   10 C = B(IB)
      DO 20 I = 2,N
         IA = IA + INCA
         IB = IB + INCB
         C = -A(IA)*C + B(IB)
   20 CONTINUE
      FOLRN = C
      RETURN
      END

C-------------------------------------------------------------     ************
C                                                                      SOLR
C                                                                  ************
      SUBROUTINE SOLR(N,A,INCA,B,INCB,C,INCC)
C
C     Solves second order linear recurrences of the form:
C             c(i+2) = a(i)*c(i+1) + b(i)*c(i)
C     Martin J. McBride.  8/9/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,INCC,IA,IB,IC
      REAL A(1),B(1),C(1)

C  Set up initial conditions.
      IF (N .LT. 1) RETURN
      IA = 1
      IB = 1
      IC = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCC .LT. 0) IC = (-N+1)*INCC + 1
      IC = IC + INCC
      IF (INCC .NE. 0) GO TO 20

C  Second order linear recurrence where the increment to the recurrence
C  vector, C, is equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    SOLR.  Output will reproduce CRAY SCILIB action.   *'
      PRINT*,'*********************************************************'
      PRINT*
      CUR = C(IC)
      PRV = C(IC-INCC)
      DO 10 I = 3,N
         IC = IC + INCC
         C(IC) = A(IA)*CUR + B(IB)*PRV
         PRV = CUR
         CUR = C(IC)
         IA = IA + INCA
         IB = IB + INCB
   10 CONTINUE
      RETURN

C  Second order linear recurrence with result vector C.
   20 DO 30 I = 3,N
         IC = IC + INCC
         C(IC) = A(IA)*C(IC-INCC) + B(IB)*C(IC-2*INCC)
         IA = IA + INCA
         IB = IB + INCB
   30 CONTINUE
      RETURN
      END

C-------------------------------------------------------------     ************
C                                                                     SOLRN
C                                                                  ************
      REAL FUNCTION SOLRN(N,A,INCA,B,INCB,C,INCC)
C
C     Solves for only the last term of second order linear
C          recurrences of the form:
C             c(i+2) = a(i)*c(i+1) + b(i)*c(i)
C     Martin J. McBride.  8/13/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,INCC,IA,IB,IC
      REAL A(1),B(1),C(1),C1,C2,C3

C  Set up initial conditions.
      SOLRN = 0.0
      IF (N .LT. 2) RETURN
      IA = 1
      IB = 1
      IC = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCC .LT. 0) IC = (-N+1)*INCC + 1
      IF (INCC .NE. 0) GO TO 10

C  Warning message for increment of recurrence vector, C, equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    SOLRN.  Output will reproduce CRAY SCILIB action.  *'
      PRINT*,'*********************************************************'
      PRINT*

C  Second order linear recurrence with result vector C and the last term,
C  SOLRN.
   10 C1 = C(IC)
      C2 = C(IC+INCC)
      C3 = C2
      DO 20 I = 3,N
         C3 = A(IA)*C2 + B(IB)*C1
         C1 = C2
         C2 = C3
         IA = IA + INCA
         IB = IB + INCB
   20 CONTINUE
      SOLRN = C3
      RETURN
      END

C-------------------------------------------------------------     ************
C                                                                     SOLR3
C                                                                  ************
      SUBROUTINE SOLR3(N,A,INCA,B,INCB,C,INCC)
C
C     Solves second order linear recurrences of the form:
C             c(i+2) = c(i+2) + a(i)*c(i+1) + b(i)*c(i)
C     Martin J. McBride.  8/9/85.
C     General Electric CRD, Information System Operation.
C
      INTEGER N,INCA,INCB,INCC,IA,IB,IC
      REAL A(1),B(1),C(1)

C  Set up initial conditions.
      IF (N .LT. 1) RETURN
      IA = 1
      IB = 1
      IC = 1
      IF (INCA .LT. 0) IA = (-N+1)*INCA + 1
      IF (INCB .LT. 0) IB = (-N+1)*INCB + 1
      IF (INCC .LT. 0) IC = (-N+1)*INCC + 1
      IC = IC + INCC
      IF (INCC .NE. 0) GO TO 20

C  Second order linear recurrence where the increment to the recurrence
C  vector, C, is equal to zero.
      PRINT*
      PRINT*,'*********************************************************'
      PRINT*,'*  Possible user error - 0 increment encountered in     *'
      PRINT*,'*    SOLR3.  Output will reproduce CRAY SCILIB action.  *'
      PRINT*,'*********************************************************'
      PRINT*
      CUR = C(IC)
      PRV = C(IC-INCC)
      DO 10 I = 3,N
         IC = IC + INCC
         C(IC) = C(IC) + A(IA)*CUR + B(IB)*PRV
         PRV = CUR
         CUR = C(IC)
         IA = IA + INCA
         IB = IB + INCB
   10 CONTINUE
      RETURN

C  Second order linear recurrence with result vector C.
   20 DO 30 I = 3,N
         IC = IC + INCC
         C(IC) = C(IC) + A(IA)*C(IC-INCC) + B(IB)*C(IC-2*INCC)
         IA = IA + INCA
         IB = IB + INCB
   30 CONTINUE
      RETURN
      END
