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