LAPACK 3.3.0

chemv.f

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