LAPACK 3.3.0

ctrmv.f

Go to the documentation of this file.
00001       SUBROUTINE CTRMV(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       COMPLEX A(LDA,*),X(*)
00008 *     ..
00009 *
00010 *  Purpose
00011 *  =======
00012 *
00013 *  CTRMV  performs one of the matrix-vector operations
00014 *
00015 *     x := A*x,   or   x := A'*x,   or   x := conjg( 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 := conjg( 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      - COMPLEX          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      - COMPLEX          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       COMPLEX ZERO
00106       PARAMETER (ZERO= (0.0E+0,0.0E+0))
00107 *     ..
00108 *     .. Local Scalars ..
00109       COMPLEX TEMP
00110       INTEGER I,INFO,IX,J,JX,KX
00111       LOGICAL NOCONJ,NOUNIT
00112 *     ..
00113 *     .. External Functions ..
00114       LOGICAL LSAME
00115       EXTERNAL LSAME
00116 *     ..
00117 *     .. External Subroutines ..
00118       EXTERNAL XERBLA
00119 *     ..
00120 *     .. Intrinsic Functions ..
00121       INTRINSIC CONJG,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('CTRMV ',INFO)
00143           RETURN
00144       END IF
00145 *
00146 *     Quick return if possible.
00147 *
00148       IF (N.EQ.0) RETURN
00149 *
00150       NOCONJ = LSAME(TRANS,'T')
00151       NOUNIT = LSAME(DIAG,'N')
00152 *
00153 *     Set up the start point in X if the increment is not unity. This
00154 *     will be  ( N - 1 )*INCX  too small for descending loops.
00155 *
00156       IF (INCX.LE.0) THEN
00157           KX = 1 - (N-1)*INCX
00158       ELSE IF (INCX.NE.1) THEN
00159           KX = 1
00160       END IF
00161 *
00162 *     Start the operations. In this version the elements of A are
00163 *     accessed sequentially with one pass through A.
00164 *
00165       IF (LSAME(TRANS,'N')) THEN
00166 *
00167 *        Form  x := A*x.
00168 *
00169           IF (LSAME(UPLO,'U')) THEN
00170               IF (INCX.EQ.1) THEN
00171                   DO 20 J = 1,N
00172                       IF (X(J).NE.ZERO) THEN
00173                           TEMP = X(J)
00174                           DO 10 I = 1,J - 1
00175                               X(I) = X(I) + TEMP*A(I,J)
00176    10                     CONTINUE
00177                           IF (NOUNIT) X(J) = X(J)*A(J,J)
00178                       END IF
00179    20             CONTINUE
00180               ELSE
00181                   JX = KX
00182                   DO 40 J = 1,N
00183                       IF (X(JX).NE.ZERO) THEN
00184                           TEMP = X(JX)
00185                           IX = KX
00186                           DO 30 I = 1,J - 1
00187                               X(IX) = X(IX) + TEMP*A(I,J)
00188                               IX = IX + INCX
00189    30                     CONTINUE
00190                           IF (NOUNIT) X(JX) = X(JX)*A(J,J)
00191                       END IF
00192                       JX = JX + INCX
00193    40             CONTINUE
00194               END IF
00195           ELSE
00196               IF (INCX.EQ.1) THEN
00197                   DO 60 J = N,1,-1
00198                       IF (X(J).NE.ZERO) THEN
00199                           TEMP = X(J)
00200                           DO 50 I = N,J + 1,-1
00201                               X(I) = X(I) + TEMP*A(I,J)
00202    50                     CONTINUE
00203                           IF (NOUNIT) X(J) = X(J)*A(J,J)
00204                       END IF
00205    60             CONTINUE
00206               ELSE
00207                   KX = KX + (N-1)*INCX
00208                   JX = KX
00209                   DO 80 J = N,1,-1
00210                       IF (X(JX).NE.ZERO) THEN
00211                           TEMP = X(JX)
00212                           IX = KX
00213                           DO 70 I = N,J + 1,-1
00214                               X(IX) = X(IX) + TEMP*A(I,J)
00215                               IX = IX - INCX
00216    70                     CONTINUE
00217                           IF (NOUNIT) X(JX) = X(JX)*A(J,J)
00218                       END IF
00219                       JX = JX - INCX
00220    80             CONTINUE
00221               END IF
00222           END IF
00223       ELSE
00224 *
00225 *        Form  x := A'*x  or  x := conjg( A' )*x.
00226 *
00227           IF (LSAME(UPLO,'U')) THEN
00228               IF (INCX.EQ.1) THEN
00229                   DO 110 J = N,1,-1
00230                       TEMP = X(J)
00231                       IF (NOCONJ) THEN
00232                           IF (NOUNIT) TEMP = TEMP*A(J,J)
00233                           DO 90 I = J - 1,1,-1
00234                               TEMP = TEMP + A(I,J)*X(I)
00235    90                     CONTINUE
00236                       ELSE
00237                           IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J))
00238                           DO 100 I = J - 1,1,-1
00239                               TEMP = TEMP + CONJG(A(I,J))*X(I)
00240   100                     CONTINUE
00241                       END IF
00242                       X(J) = TEMP
00243   110             CONTINUE
00244               ELSE
00245                   JX = KX + (N-1)*INCX
00246                   DO 140 J = N,1,-1
00247                       TEMP = X(JX)
00248                       IX = JX
00249                       IF (NOCONJ) THEN
00250                           IF (NOUNIT) TEMP = TEMP*A(J,J)
00251                           DO 120 I = J - 1,1,-1
00252                               IX = IX - INCX
00253                               TEMP = TEMP + A(I,J)*X(IX)
00254   120                     CONTINUE
00255                       ELSE
00256                           IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J))
00257                           DO 130 I = J - 1,1,-1
00258                               IX = IX - INCX
00259                               TEMP = TEMP + CONJG(A(I,J))*X(IX)
00260   130                     CONTINUE
00261                       END IF
00262                       X(JX) = TEMP
00263                       JX = JX - INCX
00264   140             CONTINUE
00265               END IF
00266           ELSE
00267               IF (INCX.EQ.1) THEN
00268                   DO 170 J = 1,N
00269                       TEMP = X(J)
00270                       IF (NOCONJ) THEN
00271                           IF (NOUNIT) TEMP = TEMP*A(J,J)
00272                           DO 150 I = J + 1,N
00273                               TEMP = TEMP + A(I,J)*X(I)
00274   150                     CONTINUE
00275                       ELSE
00276                           IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J))
00277                           DO 160 I = J + 1,N
00278                               TEMP = TEMP + CONJG(A(I,J))*X(I)
00279   160                     CONTINUE
00280                       END IF
00281                       X(J) = TEMP
00282   170             CONTINUE
00283               ELSE
00284                   JX = KX
00285                   DO 200 J = 1,N
00286                       TEMP = X(JX)
00287                       IX = JX
00288                       IF (NOCONJ) THEN
00289                           IF (NOUNIT) TEMP = TEMP*A(J,J)
00290                           DO 180 I = J + 1,N
00291                               IX = IX + INCX
00292                               TEMP = TEMP + A(I,J)*X(IX)
00293   180                     CONTINUE
00294                       ELSE
00295                           IF (NOUNIT) TEMP = TEMP*CONJG(A(J,J))
00296                           DO 190 I = J + 1,N
00297                               IX = IX + INCX
00298                               TEMP = TEMP + CONJG(A(I,J))*X(IX)
00299   190                     CONTINUE
00300                       END IF
00301                       X(JX) = TEMP
00302                       JX = JX + INCX
00303   200             CONTINUE
00304               END IF
00305           END IF
00306       END IF
00307 *
00308       RETURN
00309 *
00310 *     End of CTRMV .
00311 *
00312       END
 All Files Functions