LAPACK 3.3.0

ctpmv.f

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