LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE CHPR(UPLO,N,ALPHA,X,INCX,AP) 00002 * .. Scalar Arguments .. 00003 REAL ALPHA 00004 INTEGER INCX,N 00005 CHARACTER UPLO 00006 * .. 00007 * .. Array Arguments .. 00008 COMPLEX AP(*),X(*) 00009 * .. 00010 * 00011 * Purpose 00012 * ======= 00013 * 00014 * CHPR performs the hermitian rank 1 operation 00015 * 00016 * A := alpha*x*x**H + A, 00017 * 00018 * where alpha is a real scalar, x is an n element vector and A is an 00019 * 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 - REAL . 00043 * On entry, ALPHA specifies the scalar alpha. 00044 * Unchanged on exit. 00045 * 00046 * X - COMPLEX array of dimension at least 00047 * ( 1 + ( n - 1 )*abs( INCX ) ). 00048 * Before entry, the incremented array X must contain the n 00049 * element vector x. 00050 * Unchanged on exit. 00051 * 00052 * INCX - INTEGER. 00053 * On entry, INCX specifies the increment for the elements of 00054 * X. INCX must not be zero. 00055 * Unchanged on exit. 00056 * 00057 * AP - COMPLEX array of DIMENSION at least 00058 * ( ( n*( n + 1 ) )/2 ). 00059 * Before entry with UPLO = 'U' or 'u', the array AP must 00060 * contain the upper triangular part of the hermitian matrix 00061 * packed sequentially, column by column, so that AP( 1 ) 00062 * contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) 00063 * and a( 2, 2 ) respectively, and so on. On exit, the array 00064 * AP is overwritten by the upper triangular part of the 00065 * updated matrix. 00066 * Before entry with UPLO = 'L' or 'l', the array AP must 00067 * contain the lower triangular part of the hermitian matrix 00068 * packed sequentially, column by column, so that AP( 1 ) 00069 * contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) 00070 * and a( 3, 1 ) respectively, and so on. On exit, the array 00071 * AP is overwritten by the lower triangular part of the 00072 * updated matrix. 00073 * Note that the imaginary parts of the diagonal elements need 00074 * not be set, they are assumed to be zero, and on exit they 00075 * are set to zero. 00076 * 00077 * Further Details 00078 * =============== 00079 * 00080 * Level 2 Blas routine. 00081 * 00082 * -- Written on 22-October-1986. 00083 * Jack Dongarra, Argonne National Lab. 00084 * Jeremy Du Croz, Nag Central Office. 00085 * Sven Hammarling, Nag Central Office. 00086 * Richard Hanson, Sandia National Labs. 00087 * 00088 * ===================================================================== 00089 * 00090 * .. Parameters .. 00091 COMPLEX ZERO 00092 PARAMETER (ZERO= (0.0E+0,0.0E+0)) 00093 * .. 00094 * .. Local Scalars .. 00095 COMPLEX TEMP 00096 INTEGER I,INFO,IX,J,JX,K,KK,KX 00097 * .. 00098 * .. External Functions .. 00099 LOGICAL LSAME 00100 EXTERNAL LSAME 00101 * .. 00102 * .. External Subroutines .. 00103 EXTERNAL XERBLA 00104 * .. 00105 * .. Intrinsic Functions .. 00106 INTRINSIC CONJG,REAL 00107 * .. 00108 * 00109 * Test the input parameters. 00110 * 00111 INFO = 0 00112 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 00113 INFO = 1 00114 ELSE IF (N.LT.0) THEN 00115 INFO = 2 00116 ELSE IF (INCX.EQ.0) THEN 00117 INFO = 5 00118 END IF 00119 IF (INFO.NE.0) THEN 00120 CALL XERBLA('CHPR ',INFO) 00121 RETURN 00122 END IF 00123 * 00124 * Quick return if possible. 00125 * 00126 IF ((N.EQ.0) .OR. (ALPHA.EQ.REAL(ZERO))) RETURN 00127 * 00128 * Set the start point in X if the increment is not unity. 00129 * 00130 IF (INCX.LE.0) THEN 00131 KX = 1 - (N-1)*INCX 00132 ELSE IF (INCX.NE.1) THEN 00133 KX = 1 00134 END IF 00135 * 00136 * Start the operations. In this version the elements of the array AP 00137 * are accessed sequentially with one pass through AP. 00138 * 00139 KK = 1 00140 IF (LSAME(UPLO,'U')) THEN 00141 * 00142 * Form A when upper triangle is stored in AP. 00143 * 00144 IF (INCX.EQ.1) THEN 00145 DO 20 J = 1,N 00146 IF (X(J).NE.ZERO) THEN 00147 TEMP = ALPHA*CONJG(X(J)) 00148 K = KK 00149 DO 10 I = 1,J - 1 00150 AP(K) = AP(K) + X(I)*TEMP 00151 K = K + 1 00152 10 CONTINUE 00153 AP(KK+J-1) = REAL(AP(KK+J-1)) + REAL(X(J)*TEMP) 00154 ELSE 00155 AP(KK+J-1) = REAL(AP(KK+J-1)) 00156 END IF 00157 KK = KK + J 00158 20 CONTINUE 00159 ELSE 00160 JX = KX 00161 DO 40 J = 1,N 00162 IF (X(JX).NE.ZERO) THEN 00163 TEMP = ALPHA*CONJG(X(JX)) 00164 IX = KX 00165 DO 30 K = KK,KK + J - 2 00166 AP(K) = AP(K) + X(IX)*TEMP 00167 IX = IX + INCX 00168 30 CONTINUE 00169 AP(KK+J-1) = REAL(AP(KK+J-1)) + REAL(X(JX)*TEMP) 00170 ELSE 00171 AP(KK+J-1) = REAL(AP(KK+J-1)) 00172 END IF 00173 JX = JX + INCX 00174 KK = KK + J 00175 40 CONTINUE 00176 END IF 00177 ELSE 00178 * 00179 * Form A when lower triangle is stored in AP. 00180 * 00181 IF (INCX.EQ.1) THEN 00182 DO 60 J = 1,N 00183 IF (X(J).NE.ZERO) THEN 00184 TEMP = ALPHA*CONJG(X(J)) 00185 AP(KK) = REAL(AP(KK)) + REAL(TEMP*X(J)) 00186 K = KK + 1 00187 DO 50 I = J + 1,N 00188 AP(K) = AP(K) + X(I)*TEMP 00189 K = K + 1 00190 50 CONTINUE 00191 ELSE 00192 AP(KK) = REAL(AP(KK)) 00193 END IF 00194 KK = KK + N - J + 1 00195 60 CONTINUE 00196 ELSE 00197 JX = KX 00198 DO 80 J = 1,N 00199 IF (X(JX).NE.ZERO) THEN 00200 TEMP = ALPHA*CONJG(X(JX)) 00201 AP(KK) = REAL(AP(KK)) + REAL(TEMP*X(JX)) 00202 IX = JX 00203 DO 70 K = KK + 1,KK + N - J 00204 IX = IX + INCX 00205 AP(K) = AP(K) + X(IX)*TEMP 00206 70 CONTINUE 00207 ELSE 00208 AP(KK) = REAL(AP(KK)) 00209 END IF 00210 JX = JX + INCX 00211 KK = KK + N - J + 1 00212 80 CONTINUE 00213 END IF 00214 END IF 00215 * 00216 RETURN 00217 * 00218 * End of CHPR . 00219 * 00220 END