LAPACK 3.3.1
Linear Algebra PACKage

ctbmv.f

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