LAPACK 3.3.1
Linear Algebra PACKage

ztpmv.f

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