LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
ctbsv.f
Go to the documentation of this file.
00001 *> \brief \b CTBSV
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE CTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       INTEGER INCX,K,LDA,N
00015 *       CHARACTER DIAG,TRANS,UPLO
00016 *       ..
00017 *       .. Array Arguments ..
00018 *       COMPLEX A(LDA,*),X(*)
00019 *       ..
00020 *  
00021 *
00022 *> \par Purpose:
00023 *  =============
00024 *>
00025 *> \verbatim
00026 *>
00027 *> CTBSV  solves one of the systems of equations
00028 *>
00029 *>    A*x = b,   or   A**T*x = b,   or   A**H*x = b,
00030 *>
00031 *> where b and x are n element vectors and A is an n by n unit, or
00032 *> non-unit, upper or lower triangular band matrix, with ( k + 1 )
00033 *> diagonals.
00034 *>
00035 *> No test for singularity or near-singularity is included in this
00036 *> routine. Such tests must be performed before calling this routine.
00037 *> \endverbatim
00038 *
00039 *  Arguments:
00040 *  ==========
00041 *
00042 *> \param[in] UPLO
00043 *> \verbatim
00044 *>          UPLO is CHARACTER*1
00045 *>           On entry, UPLO specifies whether the matrix is an upper or
00046 *>           lower triangular matrix as follows:
00047 *>
00048 *>              UPLO = 'U' or 'u'   A is an upper triangular matrix.
00049 *>
00050 *>              UPLO = 'L' or 'l'   A is a lower triangular matrix.
00051 *> \endverbatim
00052 *>
00053 *> \param[in] TRANS
00054 *> \verbatim
00055 *>          TRANS is CHARACTER*1
00056 *>           On entry, TRANS specifies the equations to be solved as
00057 *>           follows:
00058 *>
00059 *>              TRANS = 'N' or 'n'   A*x = b.
00060 *>
00061 *>              TRANS = 'T' or 't'   A**T*x = b.
00062 *>
00063 *>              TRANS = 'C' or 'c'   A**H*x = b.
00064 *> \endverbatim
00065 *>
00066 *> \param[in] DIAG
00067 *> \verbatim
00068 *>          DIAG is CHARACTER*1
00069 *>           On entry, DIAG specifies whether or not A is unit
00070 *>           triangular as follows:
00071 *>
00072 *>              DIAG = 'U' or 'u'   A is assumed to be unit triangular.
00073 *>
00074 *>              DIAG = 'N' or 'n'   A is not assumed to be unit
00075 *>                                  triangular.
00076 *> \endverbatim
00077 *>
00078 *> \param[in] N
00079 *> \verbatim
00080 *>          N is INTEGER
00081 *>           On entry, N specifies the order of the matrix A.
00082 *>           N must be at least zero.
00083 *> \endverbatim
00084 *>
00085 *> \param[in] K
00086 *> \verbatim
00087 *>          K is INTEGER
00088 *>           On entry with UPLO = 'U' or 'u', K specifies the number of
00089 *>           super-diagonals of the matrix A.
00090 *>           On entry with UPLO = 'L' or 'l', K specifies the number of
00091 *>           sub-diagonals of the matrix A.
00092 *>           K must satisfy  0 .le. K.
00093 *> \endverbatim
00094 *>
00095 *> \param[in] A
00096 *> \verbatim
00097 *>          A is COMPLEX array of DIMENSION ( LDA, n ).
00098 *>           Before entry with UPLO = 'U' or 'u', the leading ( k + 1 )
00099 *>           by n part of the array A must contain the upper triangular
00100 *>           band part of the matrix of coefficients, supplied column by
00101 *>           column, with the leading diagonal of the matrix in row
00102 *>           ( k + 1 ) of the array, the first super-diagonal starting at
00103 *>           position 2 in row k, and so on. The top left k by k triangle
00104 *>           of the array A is not referenced.
00105 *>           The following program segment will transfer an upper
00106 *>           triangular band matrix from conventional full matrix storage
00107 *>           to band storage:
00108 *>
00109 *>                 DO 20, J = 1, N
00110 *>                    M = K + 1 - J
00111 *>                    DO 10, I = MAX( 1, J - K ), J
00112 *>                       A( M + I, J ) = matrix( I, J )
00113 *>              10    CONTINUE
00114 *>              20 CONTINUE
00115 *>
00116 *>           Before entry with UPLO = 'L' or 'l', the leading ( k + 1 )
00117 *>           by n part of the array A must contain the lower triangular
00118 *>           band part of the matrix of coefficients, supplied column by
00119 *>           column, with the leading diagonal of the matrix in row 1 of
00120 *>           the array, the first sub-diagonal starting at position 1 in
00121 *>           row 2, and so on. The bottom right k by k triangle of the
00122 *>           array A is not referenced.
00123 *>           The following program segment will transfer a lower
00124 *>           triangular band matrix from conventional full matrix storage
00125 *>           to band storage:
00126 *>
00127 *>                 DO 20, J = 1, N
00128 *>                    M = 1 - J
00129 *>                    DO 10, I = J, MIN( N, J + K )
00130 *>                       A( M + I, J ) = matrix( I, J )
00131 *>              10    CONTINUE
00132 *>              20 CONTINUE
00133 *>
00134 *>           Note that when DIAG = 'U' or 'u' the elements of the array A
00135 *>           corresponding to the diagonal elements of the matrix are not
00136 *>           referenced, but are assumed to be unity.
00137 *> \endverbatim
00138 *>
00139 *> \param[in] LDA
00140 *> \verbatim
00141 *>          LDA is INTEGER
00142 *>           On entry, LDA specifies the first dimension of A as declared
00143 *>           in the calling (sub) program. LDA must be at least
00144 *>           ( k + 1 ).
00145 *> \endverbatim
00146 *>
00147 *> \param[in,out] X
00148 *> \verbatim
00149 *>          X is COMPLEX array of dimension at least
00150 *>           ( 1 + ( n - 1 )*abs( INCX ) ).
00151 *>           Before entry, the incremented array X must contain the n
00152 *>           element right-hand side vector b. On exit, X is overwritten
00153 *>           with the solution vector x.
00154 *> \endverbatim
00155 *>
00156 *> \param[in] INCX
00157 *> \verbatim
00158 *>          INCX is INTEGER
00159 *>           On entry, INCX specifies the increment for the elements of
00160 *>           X. INCX must not be zero.
00161 *> \endverbatim
00162 *
00163 *  Authors:
00164 *  ========
00165 *
00166 *> \author Univ. of Tennessee 
00167 *> \author Univ. of California Berkeley 
00168 *> \author Univ. of Colorado Denver 
00169 *> \author NAG Ltd. 
00170 *
00171 *> \date November 2011
00172 *
00173 *> \ingroup complex_blas_level2
00174 *
00175 *> \par Further Details:
00176 *  =====================
00177 *>
00178 *> \verbatim
00179 *>
00180 *>  Level 2 Blas routine.
00181 *>
00182 *>  -- Written on 22-October-1986.
00183 *>     Jack Dongarra, Argonne National Lab.
00184 *>     Jeremy Du Croz, Nag Central Office.
00185 *>     Sven Hammarling, Nag Central Office.
00186 *>     Richard Hanson, Sandia National Labs.
00187 *> \endverbatim
00188 *>
00189 *  =====================================================================
00190       SUBROUTINE CTBSV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
00191 *
00192 *  -- Reference BLAS level2 routine (version 3.4.0) --
00193 *  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
00194 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00195 *     November 2011
00196 *
00197 *     .. Scalar Arguments ..
00198       INTEGER INCX,K,LDA,N
00199       CHARACTER DIAG,TRANS,UPLO
00200 *     ..
00201 *     .. Array Arguments ..
00202       COMPLEX A(LDA,*),X(*)
00203 *     ..
00204 *
00205 *  =====================================================================
00206 *
00207 *     .. Parameters ..
00208       COMPLEX ZERO
00209       PARAMETER (ZERO= (0.0E+0,0.0E+0))
00210 *     ..
00211 *     .. Local Scalars ..
00212       COMPLEX TEMP
00213       INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
00214       LOGICAL NOCONJ,NOUNIT
00215 *     ..
00216 *     .. External Functions ..
00217       LOGICAL LSAME
00218       EXTERNAL LSAME
00219 *     ..
00220 *     .. External Subroutines ..
00221       EXTERNAL XERBLA
00222 *     ..
00223 *     .. Intrinsic Functions ..
00224       INTRINSIC CONJG,MAX,MIN
00225 *     ..
00226 *
00227 *     Test the input parameters.
00228 *
00229       INFO = 0
00230       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00231           INFO = 1
00232       ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
00233      +         .NOT.LSAME(TRANS,'C')) THEN
00234           INFO = 2
00235       ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
00236           INFO = 3
00237       ELSE IF (N.LT.0) THEN
00238           INFO = 4
00239       ELSE IF (K.LT.0) THEN
00240           INFO = 5
00241       ELSE IF (LDA.LT. (K+1)) THEN
00242           INFO = 7
00243       ELSE IF (INCX.EQ.0) THEN
00244           INFO = 9
00245       END IF
00246       IF (INFO.NE.0) THEN
00247           CALL XERBLA('CTBSV ',INFO)
00248           RETURN
00249       END IF
00250 *
00251 *     Quick return if possible.
00252 *
00253       IF (N.EQ.0) RETURN
00254 *
00255       NOCONJ = LSAME(TRANS,'T')
00256       NOUNIT = LSAME(DIAG,'N')
00257 *
00258 *     Set up the start point in X if the increment is not unity. This
00259 *     will be  ( N - 1 )*INCX  too small for descending loops.
00260 *
00261       IF (INCX.LE.0) THEN
00262           KX = 1 - (N-1)*INCX
00263       ELSE IF (INCX.NE.1) THEN
00264           KX = 1
00265       END IF
00266 *
00267 *     Start the operations. In this version the elements of A are
00268 *     accessed by sequentially with one pass through A.
00269 *
00270       IF (LSAME(TRANS,'N')) THEN
00271 *
00272 *        Form  x := inv( A )*x.
00273 *
00274           IF (LSAME(UPLO,'U')) THEN
00275               KPLUS1 = K + 1
00276               IF (INCX.EQ.1) THEN
00277                   DO 20 J = N,1,-1
00278                       IF (X(J).NE.ZERO) THEN
00279                           L = KPLUS1 - J
00280                           IF (NOUNIT) X(J) = X(J)/A(KPLUS1,J)
00281                           TEMP = X(J)
00282                           DO 10 I = J - 1,MAX(1,J-K),-1
00283                               X(I) = X(I) - TEMP*A(L+I,J)
00284    10                     CONTINUE
00285                       END IF
00286    20             CONTINUE
00287               ELSE
00288                   KX = KX + (N-1)*INCX
00289                   JX = KX
00290                   DO 40 J = N,1,-1
00291                       KX = KX - INCX
00292                       IF (X(JX).NE.ZERO) THEN
00293                           IX = KX
00294                           L = KPLUS1 - J
00295                           IF (NOUNIT) X(JX) = X(JX)/A(KPLUS1,J)
00296                           TEMP = X(JX)
00297                           DO 30 I = J - 1,MAX(1,J-K),-1
00298                               X(IX) = X(IX) - TEMP*A(L+I,J)
00299                               IX = IX - INCX
00300    30                     CONTINUE
00301                       END IF
00302                       JX = JX - INCX
00303    40             CONTINUE
00304               END IF
00305           ELSE
00306               IF (INCX.EQ.1) THEN
00307                   DO 60 J = 1,N
00308                       IF (X(J).NE.ZERO) THEN
00309                           L = 1 - J
00310                           IF (NOUNIT) X(J) = X(J)/A(1,J)
00311                           TEMP = X(J)
00312                           DO 50 I = J + 1,MIN(N,J+K)
00313                               X(I) = X(I) - TEMP*A(L+I,J)
00314    50                     CONTINUE
00315                       END IF
00316    60             CONTINUE
00317               ELSE
00318                   JX = KX
00319                   DO 80 J = 1,N
00320                       KX = KX + INCX
00321                       IF (X(JX).NE.ZERO) THEN
00322                           IX = KX
00323                           L = 1 - J
00324                           IF (NOUNIT) X(JX) = X(JX)/A(1,J)
00325                           TEMP = X(JX)
00326                           DO 70 I = J + 1,MIN(N,J+K)
00327                               X(IX) = X(IX) - TEMP*A(L+I,J)
00328                               IX = IX + INCX
00329    70                     CONTINUE
00330                       END IF
00331                       JX = JX + INCX
00332    80             CONTINUE
00333               END IF
00334           END IF
00335       ELSE
00336 *
00337 *        Form  x := inv( A**T )*x  or  x := inv( A**H )*x.
00338 *
00339           IF (LSAME(UPLO,'U')) THEN
00340               KPLUS1 = K + 1
00341               IF (INCX.EQ.1) THEN
00342                   DO 110 J = 1,N
00343                       TEMP = X(J)
00344                       L = KPLUS1 - J
00345                       IF (NOCONJ) THEN
00346                           DO 90 I = MAX(1,J-K),J - 1
00347                               TEMP = TEMP - A(L+I,J)*X(I)
00348    90                     CONTINUE
00349                           IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
00350                       ELSE
00351                           DO 100 I = MAX(1,J-K),J - 1
00352                               TEMP = TEMP - CONJG(A(L+I,J))*X(I)
00353   100                     CONTINUE
00354                           IF (NOUNIT) TEMP = TEMP/CONJG(A(KPLUS1,J))
00355                       END IF
00356                       X(J) = TEMP
00357   110             CONTINUE
00358               ELSE
00359                   JX = KX
00360                   DO 140 J = 1,N
00361                       TEMP = X(JX)
00362                       IX = KX
00363                       L = KPLUS1 - J
00364                       IF (NOCONJ) THEN
00365                           DO 120 I = MAX(1,J-K),J - 1
00366                               TEMP = TEMP - A(L+I,J)*X(IX)
00367                               IX = IX + INCX
00368   120                     CONTINUE
00369                           IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
00370                       ELSE
00371                           DO 130 I = MAX(1,J-K),J - 1
00372                               TEMP = TEMP - CONJG(A(L+I,J))*X(IX)
00373                               IX = IX + INCX
00374   130                     CONTINUE
00375                           IF (NOUNIT) TEMP = TEMP/CONJG(A(KPLUS1,J))
00376                       END IF
00377                       X(JX) = TEMP
00378                       JX = JX + INCX
00379                       IF (J.GT.K) KX = KX + INCX
00380   140             CONTINUE
00381               END IF
00382           ELSE
00383               IF (INCX.EQ.1) THEN
00384                   DO 170 J = N,1,-1
00385                       TEMP = X(J)
00386                       L = 1 - J
00387                       IF (NOCONJ) THEN
00388                           DO 150 I = MIN(N,J+K),J + 1,-1
00389                               TEMP = TEMP - A(L+I,J)*X(I)
00390   150                     CONTINUE
00391                           IF (NOUNIT) TEMP = TEMP/A(1,J)
00392                       ELSE
00393                           DO 160 I = MIN(N,J+K),J + 1,-1
00394                               TEMP = TEMP - CONJG(A(L+I,J))*X(I)
00395   160                     CONTINUE
00396                           IF (NOUNIT) TEMP = TEMP/CONJG(A(1,J))
00397                       END IF
00398                       X(J) = TEMP
00399   170             CONTINUE
00400               ELSE
00401                   KX = KX + (N-1)*INCX
00402                   JX = KX
00403                   DO 200 J = N,1,-1
00404                       TEMP = X(JX)
00405                       IX = KX
00406                       L = 1 - J
00407                       IF (NOCONJ) THEN
00408                           DO 180 I = MIN(N,J+K),J + 1,-1
00409                               TEMP = TEMP - A(L+I,J)*X(IX)
00410                               IX = IX - INCX
00411   180                     CONTINUE
00412                           IF (NOUNIT) TEMP = TEMP/A(1,J)
00413                       ELSE
00414                           DO 190 I = MIN(N,J+K),J + 1,-1
00415                               TEMP = TEMP - CONJG(A(L+I,J))*X(IX)
00416                               IX = IX - INCX
00417   190                     CONTINUE
00418                           IF (NOUNIT) TEMP = TEMP/CONJG(A(1,J))
00419                       END IF
00420                       X(JX) = TEMP
00421                       JX = JX - INCX
00422                       IF ((N-J).GE.K) KX = KX - INCX
00423   200             CONTINUE
00424               END IF
00425           END IF
00426       END IF
00427 *
00428       RETURN
00429 *
00430 *     End of CTBSV .
00431 *
00432       END
 All Files Functions