1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
      SUBROUTINE CGTSVNNRHSDLDDUBLDBINFO )
*
*  -- LAPACK routine (version 3.3.1) --
*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
*  -- April 2011                                                      --
*
*     .. Scalar Arguments ..
      INTEGER            INFOLDBNNRHS
*     ..
*     .. Array Arguments ..
      COMPLEX            BLDB* ), D* ), DL* ), DU* )
*     ..
*
*  Purpose
*  =======
*
*  CGTSV  solves the equation
*
*     A*X = B,
*
*  where A is an N-by-N tridiagonal matrix, by Gaussian elimination with
*  partial pivoting.
*
*  Note that the equation  A**H *X = B  may be solved by interchanging the
*  order of the arguments DU and DL.
*
*  Arguments
*  =========
*
*  N       (input) INTEGER
*          The order of the matrix A.  N >= 0.
*
*  NRHS    (input) INTEGER
*          The number of right hand sides, i.e., the number of columns
*          of the matrix B.  NRHS >= 0.
*
*  DL      (input/output) COMPLEX array, dimension (N-1)
*          On entry, DL must contain the (n-1) subdiagonal elements of
*          A.
*          On exit, DL is overwritten by the (n-2) elements of the
*          second superdiagonal of the upper triangular matrix U from
*          the LU factorization of A, in DL(1), ..., DL(n-2).
*
*  D       (input/output) COMPLEX array, dimension (N)
*          On entry, D must contain the diagonal elements of A.
*          On exit, D is overwritten by the n diagonal elements of U.
*
*  DU      (input/output) COMPLEX array, dimension (N-1)
*          On entry, DU must contain the (n-1) superdiagonal elements
*          of A.
*          On exit, DU is overwritten by the (n-1) elements of the first
*          superdiagonal of U.
*
*  B       (input/output) COMPLEX array, dimension (LDB,NRHS)
*          On entry, the N-by-NRHS right hand side matrix B.
*          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
*
*  LDB     (input) INTEGER
*          The leading dimension of the array B.  LDB >= max(1,N).
*
*  INFO    (output) INTEGER
*          = 0:  successful exit
*          < 0:  if INFO = -i, the i-th argument had an illegal value
*          > 0:  if INFO = i, U(i,i) is exactly zero, and the solution
*                has not been computed.  The factorization has not been
*                completed unless i = N.
*
*  =====================================================================
*
*     .. Parameters ..
      COMPLEX            ZERO
      PARAMETER          ( ZERO = ( 0.0E+00.0E+0 ) )
*     ..
*     .. Local Scalars ..
      INTEGER            JK
      COMPLEX            MULTTEMPZDUM
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          ABSAIMAGMAXREAL
*     ..
*     .. External Subroutines ..
      EXTERNAL           XERBLA
*     ..
*     .. Statement Functions ..
      REAL               CABS1
*     ..
*     .. Statement Function definitions ..
      CABS1ZDUM ) = ABSREALZDUM ) ) + ABSAIMAGZDUM ) )
*     ..
*     .. Executable Statements ..
*
      INFO = 0
      IFN.LT.0 ) THEN
         INFO = -1
      ELSE IFNRHS.LT.0 ) THEN
         INFO = -2
      ELSE IFLDB.LT.MAX1N ) ) THEN
         INFO = -7
      END IF
      IFINFO.NE.0 ) THEN
         CALL XERBLA'CGTSV '-INFO )
         RETURN
      END IF
*
      IFN.EQ.0 )
     $   RETURN
*
      DO 30 K = 1N - 1
         IFDLK ).EQ.ZERO ) THEN
*
*           Subdiagonal is zero, no elimination is required.
*
            IFDK ).EQ.ZERO ) THEN
*
*              Diagonal is zero: set INFO = K and return; a unique
*              solution can not be found.
*
               INFO = K
               RETURN
            END IF
         ELSE IFCABS1DK ) ).GE.CABS1DLK ) ) ) THEN
*
*           No row interchange required
*
            MULT = DLK ) / DK )
            DK+1 ) = DK+1 ) - MULT*DUK )
            DO 10 J = 1NRHS
               BK+1J ) = BK+1J ) - MULT*BKJ )
   10       CONTINUE
            IFK.LT.N-1 ) )
     $         DLK ) = ZERO
         ELSE
*
*           Interchange rows K and K+1
*
            MULT = DK ) / DLK )
            DK ) = DLK )
            TEMP = DK+1 )
            DK+1 ) = DUK ) - MULT*TEMP
            IFK.LT.N-1 ) ) THEN
               DLK ) = DUK+1 )
               DUK+1 ) = -MULT*DLK )
            END IF
            DUK ) = TEMP
            DO 20 J = 1NRHS
               TEMP = BKJ )
               BKJ ) = BK+1J )
               BK+1J ) = TEMP - MULT*BK+1J )
   20       CONTINUE
         END IF
   30 CONTINUE
      IFDN ).EQ.ZERO ) THEN
         INFO = N
         RETURN
      END IF
*
*     Back solve with the matrix U from the factorization.
*
      DO 50 J = 1NRHS
         BNJ ) = BNJ ) / DN )
         IFN.GT.1 )
     $      BN-1J ) = ( BN-1J )-DUN-1 )*BNJ ) ) / DN-1 )
         DO 40 K = N - 21-1
            BKJ ) = ( BKJ )-DUK )*BK+1J )-DLK )*
     $                  BK+2J ) ) / DK )
   40    CONTINUE
   50 CONTINUE
*
      RETURN
*
*     End of CGTSV
*
      END