LAPACK 3.3.0

dtrmv.f

Go to the documentation of this file.
00001       SUBROUTINE DTRMV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
00002 *     .. Scalar Arguments ..
00003       INTEGER INCX,LDA,N
00004       CHARACTER DIAG,TRANS,UPLO
00005 *     ..
00006 *     .. Array Arguments ..
00007       DOUBLE PRECISION A(LDA,*),X(*)
00008 *     ..
00009 *
00010 *  Purpose
00011 *  =======
00012 *
00013 *  DTRMV  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 matrix.
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 *  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
00062 *           Before entry with  UPLO = 'U' or 'u', the leading n by n
00063 *           upper triangular part of the array A must contain the upper
00064 *           triangular matrix and the strictly lower triangular part of
00065 *           A is not referenced.
00066 *           Before entry with UPLO = 'L' or 'l', the leading n by n
00067 *           lower triangular part of the array A must contain the lower
00068 *           triangular matrix and the strictly upper triangular part of
00069 *           A is not referenced.
00070 *           Note that when  DIAG = 'U' or 'u', the diagonal elements of
00071 *           A are not referenced either, but are assumed to be unity.
00072 *           Unchanged on exit.
00073 *
00074 *  LDA    - INTEGER.
00075 *           On entry, LDA specifies the first dimension of A as declared
00076 *           in the calling (sub) program. LDA must be at least
00077 *           max( 1, n ).
00078 *           Unchanged on exit.
00079 *
00080 *  X      - DOUBLE PRECISION array of dimension at least
00081 *           ( 1 + ( n - 1 )*abs( INCX ) ).
00082 *           Before entry, the incremented array X must contain the n
00083 *           element vector x. On exit, X is overwritten with the
00084 *           tranformed vector x.
00085 *
00086 *  INCX   - INTEGER.
00087 *           On entry, INCX specifies the increment for the elements of
00088 *           X. INCX must not be zero.
00089 *           Unchanged on exit.
00090 *
00091 *  Further Details
00092 *  ===============
00093 *
00094 *  Level 2 Blas routine.
00095 *
00096 *  -- Written on 22-October-1986.
00097 *     Jack Dongarra, Argonne National Lab.
00098 *     Jeremy Du Croz, Nag Central Office.
00099 *     Sven Hammarling, Nag Central Office.
00100 *     Richard Hanson, Sandia National Labs.
00101 *
00102 *  =====================================================================
00103 *
00104 *     .. Parameters ..
00105       DOUBLE PRECISION ZERO
00106       PARAMETER (ZERO=0.0D+0)
00107 *     ..
00108 *     .. Local Scalars ..
00109       DOUBLE PRECISION TEMP
00110       INTEGER I,INFO,IX,J,JX,KX
00111       LOGICAL NOUNIT
00112 *     ..
00113 *     .. External Functions ..
00114       LOGICAL LSAME
00115       EXTERNAL LSAME
00116 *     ..
00117 *     .. External Subroutines ..
00118       EXTERNAL XERBLA
00119 *     ..
00120 *     .. Intrinsic Functions ..
00121       INTRINSIC MAX
00122 *     ..
00123 *
00124 *     Test the input parameters.
00125 *
00126       INFO = 0
00127       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00128           INFO = 1
00129       ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
00130      +         .NOT.LSAME(TRANS,'C')) THEN
00131           INFO = 2
00132       ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
00133           INFO = 3
00134       ELSE IF (N.LT.0) THEN
00135           INFO = 4
00136       ELSE IF (LDA.LT.MAX(1,N)) THEN
00137           INFO = 6
00138       ELSE IF (INCX.EQ.0) THEN
00139           INFO = 8
00140       END IF
00141       IF (INFO.NE.0) THEN
00142           CALL XERBLA('DTRMV ',INFO)
00143           RETURN
00144       END IF
00145 *
00146 *     Quick return if possible.
00147 *
00148       IF (N.EQ.0) RETURN
00149 *
00150       NOUNIT = LSAME(DIAG,'N')
00151 *
00152 *     Set up the start point in X if the increment is not unity. This
00153 *     will be  ( N - 1 )*INCX  too small for descending loops.
00154 *
00155       IF (INCX.LE.0) THEN
00156           KX = 1 - (N-1)*INCX
00157       ELSE IF (INCX.NE.1) THEN
00158           KX = 1
00159       END IF
00160 *
00161 *     Start the operations. In this version the elements of A are
00162 *     accessed sequentially with one pass through A.
00163 *
00164       IF (LSAME(TRANS,'N')) THEN
00165 *
00166 *        Form  x := A*x.
00167 *
00168           IF (LSAME(UPLO,'U')) THEN
00169               IF (INCX.EQ.1) THEN
00170                   DO 20 J = 1,N
00171                       IF (X(J).NE.ZERO) THEN
00172                           TEMP = X(J)
00173                           DO 10 I = 1,J - 1
00174                               X(I) = X(I) + TEMP*A(I,J)
00175    10                     CONTINUE
00176                           IF (NOUNIT) X(J) = X(J)*A(J,J)
00177                       END IF
00178    20             CONTINUE
00179               ELSE
00180                   JX = KX
00181                   DO 40 J = 1,N
00182                       IF (X(JX).NE.ZERO) THEN
00183                           TEMP = X(JX)
00184                           IX = KX
00185                           DO 30 I = 1,J - 1
00186                               X(IX) = X(IX) + TEMP*A(I,J)
00187                               IX = IX + INCX
00188    30                     CONTINUE
00189                           IF (NOUNIT) X(JX) = X(JX)*A(J,J)
00190                       END IF
00191                       JX = JX + INCX
00192    40             CONTINUE
00193               END IF
00194           ELSE
00195               IF (INCX.EQ.1) THEN
00196                   DO 60 J = N,1,-1
00197                       IF (X(J).NE.ZERO) THEN
00198                           TEMP = X(J)
00199                           DO 50 I = N,J + 1,-1
00200                               X(I) = X(I) + TEMP*A(I,J)
00201    50                     CONTINUE
00202                           IF (NOUNIT) X(J) = X(J)*A(J,J)
00203                       END IF
00204    60             CONTINUE
00205               ELSE
00206                   KX = KX + (N-1)*INCX
00207                   JX = KX
00208                   DO 80 J = N,1,-1
00209                       IF (X(JX).NE.ZERO) THEN
00210                           TEMP = X(JX)
00211                           IX = KX
00212                           DO 70 I = N,J + 1,-1
00213                               X(IX) = X(IX) + TEMP*A(I,J)
00214                               IX = IX - INCX
00215    70                     CONTINUE
00216                           IF (NOUNIT) X(JX) = X(JX)*A(J,J)
00217                       END IF
00218                       JX = JX - INCX
00219    80             CONTINUE
00220               END IF
00221           END IF
00222       ELSE
00223 *
00224 *        Form  x := A'*x.
00225 *
00226           IF (LSAME(UPLO,'U')) THEN
00227               IF (INCX.EQ.1) THEN
00228                   DO 100 J = N,1,-1
00229                       TEMP = X(J)
00230                       IF (NOUNIT) TEMP = TEMP*A(J,J)
00231                       DO 90 I = J - 1,1,-1
00232                           TEMP = TEMP + A(I,J)*X(I)
00233    90                 CONTINUE
00234                       X(J) = TEMP
00235   100             CONTINUE
00236               ELSE
00237                   JX = KX + (N-1)*INCX
00238                   DO 120 J = N,1,-1
00239                       TEMP = X(JX)
00240                       IX = JX
00241                       IF (NOUNIT) TEMP = TEMP*A(J,J)
00242                       DO 110 I = J - 1,1,-1
00243                           IX = IX - INCX
00244                           TEMP = TEMP + A(I,J)*X(IX)
00245   110                 CONTINUE
00246                       X(JX) = TEMP
00247                       JX = JX - INCX
00248   120             CONTINUE
00249               END IF
00250           ELSE
00251               IF (INCX.EQ.1) THEN
00252                   DO 140 J = 1,N
00253                       TEMP = X(J)
00254                       IF (NOUNIT) TEMP = TEMP*A(J,J)
00255                       DO 130 I = J + 1,N
00256                           TEMP = TEMP + A(I,J)*X(I)
00257   130                 CONTINUE
00258                       X(J) = TEMP
00259   140             CONTINUE
00260               ELSE
00261                   JX = KX
00262                   DO 160 J = 1,N
00263                       TEMP = X(JX)
00264                       IX = JX
00265                       IF (NOUNIT) TEMP = TEMP*A(J,J)
00266                       DO 150 I = J + 1,N
00267                           IX = IX + INCX
00268                           TEMP = TEMP + A(I,J)*X(IX)
00269   150                 CONTINUE
00270                       X(JX) = TEMP
00271                       JX = JX + INCX
00272   160             CONTINUE
00273               END IF
00274           END IF
00275       END IF
00276 *
00277       RETURN
00278 *
00279 *     End of DTRMV .
00280 *
00281       END
 All Files Functions