LAPACK 3.3.0

stbmv.f

Go to the documentation of this file.
00001       SUBROUTINE STBMV(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       REAL A(LDA,*),X(*)
00008 *     ..
00009 *
00010 *  Purpose
00011 *  =======
00012 *
00013 *  STBMV  performs one of the matrix-vector operations
00014 *
00015 *     x := A*x,   or   x := A'*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'*x.
00040 *
00041 *              TRANS = 'C' or 'c'   x := A'*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      - REAL             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      - REAL             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 *
00133 *  -- Written on 22-October-1986.
00134 *     Jack Dongarra, Argonne National Lab.
00135 *     Jeremy Du Croz, Nag Central Office.
00136 *     Sven Hammarling, Nag Central Office.
00137 *     Richard Hanson, Sandia National Labs.
00138 *
00139 *  =====================================================================
00140 *
00141 *     .. Parameters ..
00142       REAL ZERO
00143       PARAMETER (ZERO=0.0E+0)
00144 *     ..
00145 *     .. Local Scalars ..
00146       REAL TEMP
00147       INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
00148       LOGICAL NOUNIT
00149 *     ..
00150 *     .. External Functions ..
00151       LOGICAL LSAME
00152       EXTERNAL LSAME
00153 *     ..
00154 *     .. External Subroutines ..
00155       EXTERNAL XERBLA
00156 *     ..
00157 *     .. Intrinsic Functions ..
00158       INTRINSIC MAX,MIN
00159 *     ..
00160 *
00161 *     Test the input parameters.
00162 *
00163       INFO = 0
00164       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00165           INFO = 1
00166       ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
00167      +         .NOT.LSAME(TRANS,'C')) THEN
00168           INFO = 2
00169       ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
00170           INFO = 3
00171       ELSE IF (N.LT.0) THEN
00172           INFO = 4
00173       ELSE IF (K.LT.0) THEN
00174           INFO = 5
00175       ELSE IF (LDA.LT. (K+1)) THEN
00176           INFO = 7
00177       ELSE IF (INCX.EQ.0) THEN
00178           INFO = 9
00179       END IF
00180       IF (INFO.NE.0) THEN
00181           CALL XERBLA('STBMV ',INFO)
00182           RETURN
00183       END IF
00184 *
00185 *     Quick return if possible.
00186 *
00187       IF (N.EQ.0) RETURN
00188 *
00189       NOUNIT = LSAME(DIAG,'N')
00190 *
00191 *     Set up the start point in X if the increment is not unity. This
00192 *     will be  ( N - 1 )*INCX   too small for descending loops.
00193 *
00194       IF (INCX.LE.0) THEN
00195           KX = 1 - (N-1)*INCX
00196       ELSE IF (INCX.NE.1) THEN
00197           KX = 1
00198       END IF
00199 *
00200 *     Start the operations. In this version the elements of A are
00201 *     accessed sequentially with one pass through A.
00202 *
00203       IF (LSAME(TRANS,'N')) THEN
00204 *
00205 *         Form  x := A*x.
00206 *
00207           IF (LSAME(UPLO,'U')) THEN
00208               KPLUS1 = K + 1
00209               IF (INCX.EQ.1) THEN
00210                   DO 20 J = 1,N
00211                       IF (X(J).NE.ZERO) THEN
00212                           TEMP = X(J)
00213                           L = KPLUS1 - J
00214                           DO 10 I = MAX(1,J-K),J - 1
00215                               X(I) = X(I) + TEMP*A(L+I,J)
00216    10                     CONTINUE
00217                           IF (NOUNIT) X(J) = X(J)*A(KPLUS1,J)
00218                       END IF
00219    20             CONTINUE
00220               ELSE
00221                   JX = KX
00222                   DO 40 J = 1,N
00223                       IF (X(JX).NE.ZERO) THEN
00224                           TEMP = X(JX)
00225                           IX = KX
00226                           L = KPLUS1 - J
00227                           DO 30 I = MAX(1,J-K),J - 1
00228                               X(IX) = X(IX) + TEMP*A(L+I,J)
00229                               IX = IX + INCX
00230    30                     CONTINUE
00231                           IF (NOUNIT) X(JX) = X(JX)*A(KPLUS1,J)
00232                       END IF
00233                       JX = JX + INCX
00234                       IF (J.GT.K) KX = KX + INCX
00235    40             CONTINUE
00236               END IF
00237           ELSE
00238               IF (INCX.EQ.1) THEN
00239                   DO 60 J = N,1,-1
00240                       IF (X(J).NE.ZERO) THEN
00241                           TEMP = X(J)
00242                           L = 1 - J
00243                           DO 50 I = MIN(N,J+K),J + 1,-1
00244                               X(I) = X(I) + TEMP*A(L+I,J)
00245    50                     CONTINUE
00246                           IF (NOUNIT) X(J) = X(J)*A(1,J)
00247                       END IF
00248    60             CONTINUE
00249               ELSE
00250                   KX = KX + (N-1)*INCX
00251                   JX = KX
00252                   DO 80 J = N,1,-1
00253                       IF (X(JX).NE.ZERO) THEN
00254                           TEMP = X(JX)
00255                           IX = KX
00256                           L = 1 - J
00257                           DO 70 I = MIN(N,J+K),J + 1,-1
00258                               X(IX) = X(IX) + TEMP*A(L+I,J)
00259                               IX = IX - INCX
00260    70                     CONTINUE
00261                           IF (NOUNIT) X(JX) = X(JX)*A(1,J)
00262                       END IF
00263                       JX = JX - INCX
00264                       IF ((N-J).GE.K) KX = KX - INCX
00265    80             CONTINUE
00266               END IF
00267           END IF
00268       ELSE
00269 *
00270 *        Form  x := A'*x.
00271 *
00272           IF (LSAME(UPLO,'U')) THEN
00273               KPLUS1 = K + 1
00274               IF (INCX.EQ.1) THEN
00275                   DO 100 J = N,1,-1
00276                       TEMP = X(J)
00277                       L = KPLUS1 - J
00278                       IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
00279                       DO 90 I = J - 1,MAX(1,J-K),-1
00280                           TEMP = TEMP + A(L+I,J)*X(I)
00281    90                 CONTINUE
00282                       X(J) = TEMP
00283   100             CONTINUE
00284               ELSE
00285                   KX = KX + (N-1)*INCX
00286                   JX = KX
00287                   DO 120 J = N,1,-1
00288                       TEMP = X(JX)
00289                       KX = KX - INCX
00290                       IX = KX
00291                       L = KPLUS1 - J
00292                       IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
00293                       DO 110 I = J - 1,MAX(1,J-K),-1
00294                           TEMP = TEMP + A(L+I,J)*X(IX)
00295                           IX = IX - INCX
00296   110                 CONTINUE
00297                       X(JX) = TEMP
00298                       JX = JX - INCX
00299   120             CONTINUE
00300               END IF
00301           ELSE
00302               IF (INCX.EQ.1) THEN
00303                   DO 140 J = 1,N
00304                       TEMP = X(J)
00305                       L = 1 - J
00306                       IF (NOUNIT) TEMP = TEMP*A(1,J)
00307                       DO 130 I = J + 1,MIN(N,J+K)
00308                           TEMP = TEMP + A(L+I,J)*X(I)
00309   130                 CONTINUE
00310                       X(J) = TEMP
00311   140             CONTINUE
00312               ELSE
00313                   JX = KX
00314                   DO 160 J = 1,N
00315                       TEMP = X(JX)
00316                       KX = KX + INCX
00317                       IX = KX
00318                       L = 1 - J
00319                       IF (NOUNIT) TEMP = TEMP*A(1,J)
00320                       DO 150 I = J + 1,MIN(N,J+K)
00321                           TEMP = TEMP + A(L+I,J)*X(IX)
00322                           IX = IX + INCX
00323   150                 CONTINUE
00324                       X(JX) = TEMP
00325                       JX = JX + INCX
00326   160             CONTINUE
00327               END IF
00328           END IF
00329       END IF
00330 *
00331       RETURN
00332 *
00333 *     End of STBMV .
00334 *
00335       END
 All Files Functions