LAPACK 3.3.1 Linear Algebra PACKage

# 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**T*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**T*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 *  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       REAL ZERO
00144       PARAMETER (ZERO=0.0E+0)
00145 *     ..
00146 *     .. Local Scalars ..
00147       REAL TEMP
00148       INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
00149       LOGICAL NOUNIT
00150 *     ..
00151 *     .. External Functions ..
00152       LOGICAL LSAME
00153       EXTERNAL LSAME
00154 *     ..
00155 *     .. External Subroutines ..
00156       EXTERNAL XERBLA
00157 *     ..
00158 *     .. Intrinsic Functions ..
00159       INTRINSIC 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('STBMV ',INFO)
00183           RETURN
00184       END IF
00185 *
00186 *     Quick return if possible.
00187 *
00188       IF (N.EQ.0) RETURN
00189 *
00190       NOUNIT = LSAME(DIAG,'N')
00191 *
00192 *     Set up the start point in X if the increment is not unity. This
00193 *     will be  ( N - 1 )*INCX   too small for descending loops.
00194 *
00195       IF (INCX.LE.0) THEN
00196           KX = 1 - (N-1)*INCX
00197       ELSE IF (INCX.NE.1) THEN
00198           KX = 1
00199       END IF
00200 *
00201 *     Start the operations. In this version the elements of A are
00202 *     accessed sequentially with one pass through A.
00203 *
00204       IF (LSAME(TRANS,'N')) THEN
00205 *
00206 *         Form  x := A*x.
00207 *
00208           IF (LSAME(UPLO,'U')) THEN
00209               KPLUS1 = K + 1
00210               IF (INCX.EQ.1) THEN
00211                   DO 20 J = 1,N
00212                       IF (X(J).NE.ZERO) THEN
00213                           TEMP = X(J)
00214                           L = KPLUS1 - J
00215                           DO 10 I = MAX(1,J-K),J - 1
00216                               X(I) = X(I) + TEMP*A(L+I,J)
00217    10                     CONTINUE
00218                           IF (NOUNIT) X(J) = X(J)*A(KPLUS1,J)
00219                       END IF
00220    20             CONTINUE
00221               ELSE
00222                   JX = KX
00223                   DO 40 J = 1,N
00224                       IF (X(JX).NE.ZERO) THEN
00225                           TEMP = X(JX)
00226                           IX = KX
00227                           L = KPLUS1 - J
00228                           DO 30 I = MAX(1,J-K),J - 1
00229                               X(IX) = X(IX) + TEMP*A(L+I,J)
00230                               IX = IX + INCX
00231    30                     CONTINUE
00232                           IF (NOUNIT) X(JX) = X(JX)*A(KPLUS1,J)
00233                       END IF
00234                       JX = JX + INCX
00235                       IF (J.GT.K) KX = KX + INCX
00236    40             CONTINUE
00237               END IF
00238           ELSE
00239               IF (INCX.EQ.1) THEN
00240                   DO 60 J = N,1,-1
00241                       IF (X(J).NE.ZERO) THEN
00242                           TEMP = X(J)
00243                           L = 1 - J
00244                           DO 50 I = MIN(N,J+K),J + 1,-1
00245                               X(I) = X(I) + TEMP*A(L+I,J)
00246    50                     CONTINUE
00247                           IF (NOUNIT) X(J) = X(J)*A(1,J)
00248                       END IF
00249    60             CONTINUE
00250               ELSE
00251                   KX = KX + (N-1)*INCX
00252                   JX = KX
00253                   DO 80 J = N,1,-1
00254                       IF (X(JX).NE.ZERO) THEN
00255                           TEMP = X(JX)
00256                           IX = KX
00257                           L = 1 - J
00258                           DO 70 I = MIN(N,J+K),J + 1,-1
00259                               X(IX) = X(IX) + TEMP*A(L+I,J)
00260                               IX = IX - INCX
00261    70                     CONTINUE
00262                           IF (NOUNIT) X(JX) = X(JX)*A(1,J)
00263                       END IF
00264                       JX = JX - INCX
00265                       IF ((N-J).GE.K) KX = KX - INCX
00266    80             CONTINUE
00267               END IF
00268           END IF
00269       ELSE
00270 *
00271 *        Form  x := A**T*x.
00272 *
00273           IF (LSAME(UPLO,'U')) THEN
00274               KPLUS1 = K + 1
00275               IF (INCX.EQ.1) THEN
00276                   DO 100 J = N,1,-1
00277                       TEMP = X(J)
00278                       L = KPLUS1 - J
00279                       IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
00280                       DO 90 I = J - 1,MAX(1,J-K),-1
00281                           TEMP = TEMP + A(L+I,J)*X(I)
00282    90                 CONTINUE
00283                       X(J) = TEMP
00284   100             CONTINUE
00285               ELSE
00286                   KX = KX + (N-1)*INCX
00287                   JX = KX
00288                   DO 120 J = N,1,-1
00289                       TEMP = X(JX)
00290                       KX = KX - INCX
00291                       IX = KX
00292                       L = KPLUS1 - J
00293                       IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
00294                       DO 110 I = J - 1,MAX(1,J-K),-1
00295                           TEMP = TEMP + A(L+I,J)*X(IX)
00296                           IX = IX - INCX
00297   110                 CONTINUE
00298                       X(JX) = TEMP
00299                       JX = JX - INCX
00300   120             CONTINUE
00301               END IF
00302           ELSE
00303               IF (INCX.EQ.1) THEN
00304                   DO 140 J = 1,N
00305                       TEMP = X(J)
00306                       L = 1 - J
00307                       IF (NOUNIT) TEMP = TEMP*A(1,J)
00308                       DO 130 I = J + 1,MIN(N,J+K)
00309                           TEMP = TEMP + A(L+I,J)*X(I)
00310   130                 CONTINUE
00311                       X(J) = TEMP
00312   140             CONTINUE
00313               ELSE
00314                   JX = KX
00315                   DO 160 J = 1,N
00316                       TEMP = X(JX)
00317                       KX = KX + INCX
00318                       IX = KX
00319                       L = 1 - J
00320                       IF (NOUNIT) TEMP = TEMP*A(1,J)
00321                       DO 150 I = J + 1,MIN(N,J+K)
00322                           TEMP = TEMP + A(L+I,J)*X(IX)
00323                           IX = IX + INCX
00324   150                 CONTINUE
00325                       X(JX) = TEMP
00326                       JX = JX + INCX
00327   160             CONTINUE
00328               END IF
00329           END IF
00330       END IF
00331 *
00332       RETURN
00333 *
00334 *     End of STBMV .
00335 *
00336       END
```