LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
zhpr2.f
Go to the documentation of this file.
00001 *> \brief \b ZHPR2
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE ZHPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       COMPLEX*16 ALPHA
00015 *       INTEGER INCX,INCY,N
00016 *       CHARACTER UPLO
00017 *       ..
00018 *       .. Array Arguments ..
00019 *       COMPLEX*16 AP(*),X(*),Y(*)
00020 *       ..
00021 *  
00022 *
00023 *> \par Purpose:
00024 *  =============
00025 *>
00026 *> \verbatim
00027 *>
00028 *> ZHPR2  performs the hermitian rank 2 operation
00029 *>
00030 *>    A := alpha*x*y**H + conjg( alpha )*y*x**H + A,
00031 *>
00032 *> where alpha is a scalar, x and y are n element vectors and A is an
00033 *> n by n hermitian matrix, supplied in packed form.
00034 *> \endverbatim
00035 *
00036 *  Arguments:
00037 *  ==========
00038 *
00039 *> \param[in] UPLO
00040 *> \verbatim
00041 *>          UPLO is CHARACTER*1
00042 *>           On entry, UPLO specifies whether the upper or lower
00043 *>           triangular part of the matrix A is supplied in the packed
00044 *>           array AP as follows:
00045 *>
00046 *>              UPLO = 'U' or 'u'   The upper triangular part of A is
00047 *>                                  supplied in AP.
00048 *>
00049 *>              UPLO = 'L' or 'l'   The lower triangular part of A is
00050 *>                                  supplied in AP.
00051 *> \endverbatim
00052 *>
00053 *> \param[in] N
00054 *> \verbatim
00055 *>          N is INTEGER
00056 *>           On entry, N specifies the order of the matrix A.
00057 *>           N must be at least zero.
00058 *> \endverbatim
00059 *>
00060 *> \param[in] ALPHA
00061 *> \verbatim
00062 *>          ALPHA is COMPLEX*16
00063 *>           On entry, ALPHA specifies the scalar alpha.
00064 *> \endverbatim
00065 *>
00066 *> \param[in] X
00067 *> \verbatim
00068 *>          X is COMPLEX*16 array of dimension at least
00069 *>           ( 1 + ( n - 1 )*abs( INCX ) ).
00070 *>           Before entry, the incremented array X must contain the n
00071 *>           element vector x.
00072 *> \endverbatim
00073 *>
00074 *> \param[in] INCX
00075 *> \verbatim
00076 *>          INCX is INTEGER
00077 *>           On entry, INCX specifies the increment for the elements of
00078 *>           X. INCX must not be zero.
00079 *> \endverbatim
00080 *>
00081 *> \param[in] Y
00082 *> \verbatim
00083 *>          Y is COMPLEX*16 array of dimension at least
00084 *>           ( 1 + ( n - 1 )*abs( INCY ) ).
00085 *>           Before entry, the incremented array Y must contain the n
00086 *>           element vector y.
00087 *> \endverbatim
00088 *>
00089 *> \param[in] INCY
00090 *> \verbatim
00091 *>          INCY is INTEGER
00092 *>           On entry, INCY specifies the increment for the elements of
00093 *>           Y. INCY must not be zero.
00094 *> \endverbatim
00095 *>
00096 *> \param[in,out] AP
00097 *> \verbatim
00098 *>          AP is COMPLEX*16 array of DIMENSION at least
00099 *>           ( ( n*( n + 1 ) )/2 ).
00100 *>           Before entry with  UPLO = 'U' or 'u', the array AP must
00101 *>           contain the upper triangular part of the hermitian matrix
00102 *>           packed sequentially, column by column, so that AP( 1 )
00103 *>           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
00104 *>           and a( 2, 2 ) respectively, and so on. On exit, the array
00105 *>           AP is overwritten by the upper triangular part of the
00106 *>           updated matrix.
00107 *>           Before entry with UPLO = 'L' or 'l', the array AP must
00108 *>           contain the lower triangular part of the hermitian matrix
00109 *>           packed sequentially, column by column, so that AP( 1 )
00110 *>           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
00111 *>           and a( 3, 1 ) respectively, and so on. On exit, the array
00112 *>           AP is overwritten by the lower triangular part of the
00113 *>           updated matrix.
00114 *>           Note that the imaginary parts of the diagonal elements need
00115 *>           not be set, they are assumed to be zero, and on exit they
00116 *>           are set to zero.
00117 *> \endverbatim
00118 *
00119 *  Authors:
00120 *  ========
00121 *
00122 *> \author Univ. of Tennessee 
00123 *> \author Univ. of California Berkeley 
00124 *> \author Univ. of Colorado Denver 
00125 *> \author NAG Ltd. 
00126 *
00127 *> \date November 2011
00128 *
00129 *> \ingroup complex16_blas_level2
00130 *
00131 *> \par Further Details:
00132 *  =====================
00133 *>
00134 *> \verbatim
00135 *>
00136 *>  Level 2 Blas routine.
00137 *>
00138 *>  -- Written on 22-October-1986.
00139 *>     Jack Dongarra, Argonne National Lab.
00140 *>     Jeremy Du Croz, Nag Central Office.
00141 *>     Sven Hammarling, Nag Central Office.
00142 *>     Richard Hanson, Sandia National Labs.
00143 *> \endverbatim
00144 *>
00145 *  =====================================================================
00146       SUBROUTINE ZHPR2(UPLO,N,ALPHA,X,INCX,Y,INCY,AP)
00147 *
00148 *  -- Reference BLAS level2 routine (version 3.4.0) --
00149 *  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
00150 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00151 *     November 2011
00152 *
00153 *     .. Scalar Arguments ..
00154       COMPLEX*16 ALPHA
00155       INTEGER INCX,INCY,N
00156       CHARACTER UPLO
00157 *     ..
00158 *     .. Array Arguments ..
00159       COMPLEX*16 AP(*),X(*),Y(*)
00160 *     ..
00161 *
00162 *  =====================================================================
00163 *
00164 *     .. Parameters ..
00165       COMPLEX*16 ZERO
00166       PARAMETER (ZERO= (0.0D+0,0.0D+0))
00167 *     ..
00168 *     .. Local Scalars ..
00169       COMPLEX*16 TEMP1,TEMP2
00170       INTEGER I,INFO,IX,IY,J,JX,JY,K,KK,KX,KY
00171 *     ..
00172 *     .. External Functions ..
00173       LOGICAL LSAME
00174       EXTERNAL LSAME
00175 *     ..
00176 *     .. External Subroutines ..
00177       EXTERNAL XERBLA
00178 *     ..
00179 *     .. Intrinsic Functions ..
00180       INTRINSIC DBLE,DCONJG
00181 *     ..
00182 *
00183 *     Test the input parameters.
00184 *
00185       INFO = 0
00186       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00187           INFO = 1
00188       ELSE IF (N.LT.0) THEN
00189           INFO = 2
00190       ELSE IF (INCX.EQ.0) THEN
00191           INFO = 5
00192       ELSE IF (INCY.EQ.0) THEN
00193           INFO = 7
00194       END IF
00195       IF (INFO.NE.0) THEN
00196           CALL XERBLA('ZHPR2 ',INFO)
00197           RETURN
00198       END IF
00199 *
00200 *     Quick return if possible.
00201 *
00202       IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
00203 *
00204 *     Set up the start points in X and Y if the increments are not both
00205 *     unity.
00206 *
00207       IF ((INCX.NE.1) .OR. (INCY.NE.1)) THEN
00208           IF (INCX.GT.0) THEN
00209               KX = 1
00210           ELSE
00211               KX = 1 - (N-1)*INCX
00212           END IF
00213           IF (INCY.GT.0) THEN
00214               KY = 1
00215           ELSE
00216               KY = 1 - (N-1)*INCY
00217           END IF
00218           JX = KX
00219           JY = KY
00220       END IF
00221 *
00222 *     Start the operations. In this version the elements of the array AP
00223 *     are accessed sequentially with one pass through AP.
00224 *
00225       KK = 1
00226       IF (LSAME(UPLO,'U')) THEN
00227 *
00228 *        Form  A  when upper triangle is stored in AP.
00229 *
00230           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00231               DO 20 J = 1,N
00232                   IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
00233                       TEMP1 = ALPHA*DCONJG(Y(J))
00234                       TEMP2 = DCONJG(ALPHA*X(J))
00235                       K = KK
00236                       DO 10 I = 1,J - 1
00237                           AP(K) = AP(K) + X(I)*TEMP1 + Y(I)*TEMP2
00238                           K = K + 1
00239    10                 CONTINUE
00240                       AP(KK+J-1) = DBLE(AP(KK+J-1)) +
00241      +                             DBLE(X(J)*TEMP1+Y(J)*TEMP2)
00242                   ELSE
00243                       AP(KK+J-1) = DBLE(AP(KK+J-1))
00244                   END IF
00245                   KK = KK + J
00246    20         CONTINUE
00247           ELSE
00248               DO 40 J = 1,N
00249                   IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
00250                       TEMP1 = ALPHA*DCONJG(Y(JY))
00251                       TEMP2 = DCONJG(ALPHA*X(JX))
00252                       IX = KX
00253                       IY = KY
00254                       DO 30 K = KK,KK + J - 2
00255                           AP(K) = AP(K) + X(IX)*TEMP1 + Y(IY)*TEMP2
00256                           IX = IX + INCX
00257                           IY = IY + INCY
00258    30                 CONTINUE
00259                       AP(KK+J-1) = DBLE(AP(KK+J-1)) +
00260      +                             DBLE(X(JX)*TEMP1+Y(JY)*TEMP2)
00261                   ELSE
00262                       AP(KK+J-1) = DBLE(AP(KK+J-1))
00263                   END IF
00264                   JX = JX + INCX
00265                   JY = JY + INCY
00266                   KK = KK + J
00267    40         CONTINUE
00268           END IF
00269       ELSE
00270 *
00271 *        Form  A  when lower triangle is stored in AP.
00272 *
00273           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00274               DO 60 J = 1,N
00275                   IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
00276                       TEMP1 = ALPHA*DCONJG(Y(J))
00277                       TEMP2 = DCONJG(ALPHA*X(J))
00278                       AP(KK) = DBLE(AP(KK)) +
00279      +                         DBLE(X(J)*TEMP1+Y(J)*TEMP2)
00280                       K = KK + 1
00281                       DO 50 I = J + 1,N
00282                           AP(K) = AP(K) + X(I)*TEMP1 + Y(I)*TEMP2
00283                           K = K + 1
00284    50                 CONTINUE
00285                   ELSE
00286                       AP(KK) = DBLE(AP(KK))
00287                   END IF
00288                   KK = KK + N - J + 1
00289    60         CONTINUE
00290           ELSE
00291               DO 80 J = 1,N
00292                   IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
00293                       TEMP1 = ALPHA*DCONJG(Y(JY))
00294                       TEMP2 = DCONJG(ALPHA*X(JX))
00295                       AP(KK) = DBLE(AP(KK)) +
00296      +                         DBLE(X(JX)*TEMP1+Y(JY)*TEMP2)
00297                       IX = JX
00298                       IY = JY
00299                       DO 70 K = KK + 1,KK + N - J
00300                           IX = IX + INCX
00301                           IY = IY + INCY
00302                           AP(K) = AP(K) + X(IX)*TEMP1 + Y(IY)*TEMP2
00303    70                 CONTINUE
00304                   ELSE
00305                       AP(KK) = DBLE(AP(KK))
00306                   END IF
00307                   JX = JX + INCX
00308                   JY = JY + INCY
00309                   KK = KK + N - J + 1
00310    80         CONTINUE
00311           END IF
00312       END IF
00313 *
00314       RETURN
00315 *
00316 *     End of ZHPR2 .
00317 *
00318       END
 All Files Functions