LAPACK 3.3.0

zhpmv.f

Go to the documentation of this file.
00001       SUBROUTINE ZHPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
00002 *     .. Scalar Arguments ..
00003       DOUBLE COMPLEX ALPHA,BETA
00004       INTEGER INCX,INCY,N
00005       CHARACTER UPLO
00006 *     ..
00007 *     .. Array Arguments ..
00008       DOUBLE COMPLEX AP(*),X(*),Y(*)
00009 *     ..
00010 *
00011 *  Purpose
00012 *  =======
00013 *
00014 *  ZHPMV  performs the matrix-vector operation
00015 *
00016 *     y := alpha*A*x + beta*y,
00017 *
00018 *  where alpha and beta are scalars, x and y are n element vectors and
00019 *  A is an n by n hermitian matrix, supplied in packed form.
00020 *
00021 *  Arguments
00022 *  ==========
00023 *
00024 *  UPLO   - CHARACTER*1.
00025 *           On entry, UPLO specifies whether the upper or lower
00026 *           triangular part of the matrix A is supplied in the packed
00027 *           array AP as follows:
00028 *
00029 *              UPLO = 'U' or 'u'   The upper triangular part of A is
00030 *                                  supplied in AP.
00031 *
00032 *              UPLO = 'L' or 'l'   The lower triangular part of A is
00033 *                                  supplied in AP.
00034 *
00035 *           Unchanged on exit.
00036 *
00037 *  N      - INTEGER.
00038 *           On entry, N specifies the order of the matrix A.
00039 *           N must be at least zero.
00040 *           Unchanged on exit.
00041 *
00042 *  ALPHA  - COMPLEX*16      .
00043 *           On entry, ALPHA specifies the scalar alpha.
00044 *           Unchanged on exit.
00045 *
00046 *  AP     - COMPLEX*16       array of DIMENSION at least
00047 *           ( ( n*( n + 1 ) )/2 ).
00048 *           Before entry with UPLO = 'U' or 'u', the array AP must
00049 *           contain the upper triangular part of the hermitian matrix
00050 *           packed sequentially, column by column, so that AP( 1 )
00051 *           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
00052 *           and a( 2, 2 ) respectively, and so on.
00053 *           Before entry with UPLO = 'L' or 'l', the array AP must
00054 *           contain the lower triangular part of the hermitian matrix
00055 *           packed sequentially, column by column, so that AP( 1 )
00056 *           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
00057 *           and a( 3, 1 ) respectively, and so on.
00058 *           Note that the imaginary parts of the diagonal elements need
00059 *           not be set and are assumed to be zero.
00060 *           Unchanged on exit.
00061 *
00062 *  X      - COMPLEX*16       array of dimension at least
00063 *           ( 1 + ( n - 1 )*abs( INCX ) ).
00064 *           Before entry, the incremented array X must contain the n
00065 *           element vector x.
00066 *           Unchanged on exit.
00067 *
00068 *  INCX   - INTEGER.
00069 *           On entry, INCX specifies the increment for the elements of
00070 *           X. INCX must not be zero.
00071 *           Unchanged on exit.
00072 *
00073 *  BETA   - COMPLEX*16      .
00074 *           On entry, BETA specifies the scalar beta. When BETA is
00075 *           supplied as zero then Y need not be set on input.
00076 *           Unchanged on exit.
00077 *
00078 *  Y      - COMPLEX*16       array of dimension at least
00079 *           ( 1 + ( n - 1 )*abs( INCY ) ).
00080 *           Before entry, the incremented array Y must contain the n
00081 *           element vector y. On exit, Y is overwritten by the updated
00082 *           vector y.
00083 *
00084 *  INCY   - INTEGER.
00085 *           On entry, INCY specifies the increment for the elements of
00086 *           Y. INCY must not be zero.
00087 *           Unchanged on exit.
00088 *
00089 *  Further Details
00090 *  ===============
00091 *
00092 *  Level 2 Blas routine.
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 ONE
00104       PARAMETER (ONE= (1.0D+0,0.0D+0))
00105       DOUBLE COMPLEX ZERO
00106       PARAMETER (ZERO= (0.0D+0,0.0D+0))
00107 *     ..
00108 *     .. Local Scalars ..
00109       DOUBLE COMPLEX TEMP1,TEMP2
00110       INTEGER I,INFO,IX,IY,J,JX,JY,K,KK,KX,KY
00111 *     ..
00112 *     .. External Functions ..
00113       LOGICAL LSAME
00114       EXTERNAL LSAME
00115 *     ..
00116 *     .. External Subroutines ..
00117       EXTERNAL XERBLA
00118 *     ..
00119 *     .. Intrinsic Functions ..
00120       INTRINSIC DBLE,DCONJG
00121 *     ..
00122 *
00123 *     Test the input parameters.
00124 *
00125       INFO = 0
00126       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00127           INFO = 1
00128       ELSE IF (N.LT.0) THEN
00129           INFO = 2
00130       ELSE IF (INCX.EQ.0) THEN
00131           INFO = 6
00132       ELSE IF (INCY.EQ.0) THEN
00133           INFO = 9
00134       END IF
00135       IF (INFO.NE.0) THEN
00136           CALL XERBLA('ZHPMV ',INFO)
00137           RETURN
00138       END IF
00139 *
00140 *     Quick return if possible.
00141 *
00142       IF ((N.EQ.0) .OR. ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN
00143 *
00144 *     Set up the start points in  X  and  Y.
00145 *
00146       IF (INCX.GT.0) THEN
00147           KX = 1
00148       ELSE
00149           KX = 1 - (N-1)*INCX
00150       END IF
00151       IF (INCY.GT.0) THEN
00152           KY = 1
00153       ELSE
00154           KY = 1 - (N-1)*INCY
00155       END IF
00156 *
00157 *     Start the operations. In this version the elements of the array AP
00158 *     are accessed sequentially with one pass through AP.
00159 *
00160 *     First form  y := beta*y.
00161 *
00162       IF (BETA.NE.ONE) THEN
00163           IF (INCY.EQ.1) THEN
00164               IF (BETA.EQ.ZERO) THEN
00165                   DO 10 I = 1,N
00166                       Y(I) = ZERO
00167    10             CONTINUE
00168               ELSE
00169                   DO 20 I = 1,N
00170                       Y(I) = BETA*Y(I)
00171    20             CONTINUE
00172               END IF
00173           ELSE
00174               IY = KY
00175               IF (BETA.EQ.ZERO) THEN
00176                   DO 30 I = 1,N
00177                       Y(IY) = ZERO
00178                       IY = IY + INCY
00179    30             CONTINUE
00180               ELSE
00181                   DO 40 I = 1,N
00182                       Y(IY) = BETA*Y(IY)
00183                       IY = IY + INCY
00184    40             CONTINUE
00185               END IF
00186           END IF
00187       END IF
00188       IF (ALPHA.EQ.ZERO) RETURN
00189       KK = 1
00190       IF (LSAME(UPLO,'U')) THEN
00191 *
00192 *        Form  y  when AP contains the upper triangle.
00193 *
00194           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00195               DO 60 J = 1,N
00196                   TEMP1 = ALPHA*X(J)
00197                   TEMP2 = ZERO
00198                   K = KK
00199                   DO 50 I = 1,J - 1
00200                       Y(I) = Y(I) + TEMP1*AP(K)
00201                       TEMP2 = TEMP2 + DCONJG(AP(K))*X(I)
00202                       K = K + 1
00203    50             CONTINUE
00204                   Y(J) = Y(J) + TEMP1*DBLE(AP(KK+J-1)) + ALPHA*TEMP2
00205                   KK = KK + J
00206    60         CONTINUE
00207           ELSE
00208               JX = KX
00209               JY = KY
00210               DO 80 J = 1,N
00211                   TEMP1 = ALPHA*X(JX)
00212                   TEMP2 = ZERO
00213                   IX = KX
00214                   IY = KY
00215                   DO 70 K = KK,KK + J - 2
00216                       Y(IY) = Y(IY) + TEMP1*AP(K)
00217                       TEMP2 = TEMP2 + DCONJG(AP(K))*X(IX)
00218                       IX = IX + INCX
00219                       IY = IY + INCY
00220    70             CONTINUE
00221                   Y(JY) = Y(JY) + TEMP1*DBLE(AP(KK+J-1)) + ALPHA*TEMP2
00222                   JX = JX + INCX
00223                   JY = JY + INCY
00224                   KK = KK + J
00225    80         CONTINUE
00226           END IF
00227       ELSE
00228 *
00229 *        Form  y  when AP contains the lower triangle.
00230 *
00231           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00232               DO 100 J = 1,N
00233                   TEMP1 = ALPHA*X(J)
00234                   TEMP2 = ZERO
00235                   Y(J) = Y(J) + TEMP1*DBLE(AP(KK))
00236                   K = KK + 1
00237                   DO 90 I = J + 1,N
00238                       Y(I) = Y(I) + TEMP1*AP(K)
00239                       TEMP2 = TEMP2 + DCONJG(AP(K))*X(I)
00240                       K = K + 1
00241    90             CONTINUE
00242                   Y(J) = Y(J) + ALPHA*TEMP2
00243                   KK = KK + (N-J+1)
00244   100         CONTINUE
00245           ELSE
00246               JX = KX
00247               JY = KY
00248               DO 120 J = 1,N
00249                   TEMP1 = ALPHA*X(JX)
00250                   TEMP2 = ZERO
00251                   Y(JY) = Y(JY) + TEMP1*DBLE(AP(KK))
00252                   IX = JX
00253                   IY = JY
00254                   DO 110 K = KK + 1,KK + N - J
00255                       IX = IX + INCX
00256                       IY = IY + INCY
00257                       Y(IY) = Y(IY) + TEMP1*AP(K)
00258                       TEMP2 = TEMP2 + DCONJG(AP(K))*X(IX)
00259   110             CONTINUE
00260                   Y(JY) = Y(JY) + ALPHA*TEMP2
00261                   JX = JX + INCX
00262                   JY = JY + INCY
00263                   KK = KK + (N-J+1)
00264   120         CONTINUE
00265           END IF
00266       END IF
00267 *
00268       RETURN
00269 *
00270 *     End of ZHPMV .
00271 *
00272       END
 All Files Functions