LAPACK 3.3.0
|
00001 SUBROUTINE DSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA) 00002 * .. Scalar Arguments .. 00003 DOUBLE PRECISION ALPHA 00004 INTEGER INCX,INCY,LDA,N 00005 CHARACTER UPLO 00006 * .. 00007 * .. Array Arguments .. 00008 DOUBLE PRECISION A(LDA,*),X(*),Y(*) 00009 * .. 00010 * 00011 * Purpose 00012 * ======= 00013 * 00014 * DSYR2 performs the symmetric rank 2 operation 00015 * 00016 * A := alpha*x*y' + alpha*y*x' + A, 00017 * 00018 * where alpha is a scalar, x and y are n element vectors and A is an n 00019 * by n symmetric 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 - DOUBLE PRECISION. 00043 * On entry, ALPHA specifies the scalar alpha. 00044 * Unchanged on exit. 00045 * 00046 * X - DOUBLE PRECISION 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 * Y - DOUBLE PRECISION array of dimension at least 00058 * ( 1 + ( n - 1 )*abs( INCY ) ). 00059 * Before entry, the incremented array Y must contain the n 00060 * element vector y. 00061 * Unchanged on exit. 00062 * 00063 * INCY - INTEGER. 00064 * On entry, INCY specifies the increment for the elements of 00065 * Y. INCY must not be zero. 00066 * Unchanged on exit. 00067 * 00068 * A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). 00069 * Before entry with UPLO = 'U' or 'u', the leading n by n 00070 * upper triangular part of the array A must contain the upper 00071 * triangular part of the symmetric matrix and the strictly 00072 * lower triangular part of A is not referenced. On exit, the 00073 * upper triangular part of the array A is overwritten by the 00074 * upper triangular part of the updated matrix. 00075 * Before entry with UPLO = 'L' or 'l', the leading n by n 00076 * lower triangular part of the array A must contain the lower 00077 * triangular part of the symmetric matrix and the strictly 00078 * upper triangular part of A is not referenced. On exit, the 00079 * lower triangular part of the array A is overwritten by the 00080 * lower triangular part of the updated matrix. 00081 * 00082 * LDA - INTEGER. 00083 * On entry, LDA specifies the first dimension of A as declared 00084 * in the calling (sub) program. LDA must be at least 00085 * max( 1, n ). 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 DOUBLE PRECISION ZERO 00103 PARAMETER (ZERO=0.0D+0) 00104 * .. 00105 * .. Local Scalars .. 00106 DOUBLE PRECISION TEMP1,TEMP2 00107 INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY 00108 * .. 00109 * .. External Functions .. 00110 LOGICAL LSAME 00111 EXTERNAL LSAME 00112 * .. 00113 * .. External Subroutines .. 00114 EXTERNAL XERBLA 00115 * .. 00116 * .. Intrinsic Functions .. 00117 INTRINSIC MAX 00118 * .. 00119 * 00120 * Test the input parameters. 00121 * 00122 INFO = 0 00123 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN 00124 INFO = 1 00125 ELSE IF (N.LT.0) THEN 00126 INFO = 2 00127 ELSE IF (INCX.EQ.0) THEN 00128 INFO = 5 00129 ELSE IF (INCY.EQ.0) THEN 00130 INFO = 7 00131 ELSE IF (LDA.LT.MAX(1,N)) THEN 00132 INFO = 9 00133 END IF 00134 IF (INFO.NE.0) THEN 00135 CALL XERBLA('DSYR2 ',INFO) 00136 RETURN 00137 END IF 00138 * 00139 * Quick return if possible. 00140 * 00141 IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN 00142 * 00143 * Set up the start points in X and Y if the increments are not both 00144 * unity. 00145 * 00146 IF ((INCX.NE.1) .OR. (INCY.NE.1)) THEN 00147 IF (INCX.GT.0) THEN 00148 KX = 1 00149 ELSE 00150 KX = 1 - (N-1)*INCX 00151 END IF 00152 IF (INCY.GT.0) THEN 00153 KY = 1 00154 ELSE 00155 KY = 1 - (N-1)*INCY 00156 END IF 00157 JX = KX 00158 JY = KY 00159 END IF 00160 * 00161 * Start the operations. In this version the elements of A are 00162 * accessed sequentially with one pass through the triangular part 00163 * of A. 00164 * 00165 IF (LSAME(UPLO,'U')) THEN 00166 * 00167 * Form A when A is stored in the upper triangle. 00168 * 00169 IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN 00170 DO 20 J = 1,N 00171 IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN 00172 TEMP1 = ALPHA*Y(J) 00173 TEMP2 = ALPHA*X(J) 00174 DO 10 I = 1,J 00175 A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2 00176 10 CONTINUE 00177 END IF 00178 20 CONTINUE 00179 ELSE 00180 DO 40 J = 1,N 00181 IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN 00182 TEMP1 = ALPHA*Y(JY) 00183 TEMP2 = ALPHA*X(JX) 00184 IX = KX 00185 IY = KY 00186 DO 30 I = 1,J 00187 A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2 00188 IX = IX + INCX 00189 IY = IY + INCY 00190 30 CONTINUE 00191 END IF 00192 JX = JX + INCX 00193 JY = JY + INCY 00194 40 CONTINUE 00195 END IF 00196 ELSE 00197 * 00198 * Form A when A is stored in the lower triangle. 00199 * 00200 IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN 00201 DO 60 J = 1,N 00202 IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN 00203 TEMP1 = ALPHA*Y(J) 00204 TEMP2 = ALPHA*X(J) 00205 DO 50 I = J,N 00206 A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2 00207 50 CONTINUE 00208 END IF 00209 60 CONTINUE 00210 ELSE 00211 DO 80 J = 1,N 00212 IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN 00213 TEMP1 = ALPHA*Y(JY) 00214 TEMP2 = ALPHA*X(JX) 00215 IX = JX 00216 IY = JY 00217 DO 70 I = J,N 00218 A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2 00219 IX = IX + INCX 00220 IY = IY + INCY 00221 70 CONTINUE 00222 END IF 00223 JX = JX + INCX 00224 JY = JY + INCY 00225 80 CONTINUE 00226 END IF 00227 END IF 00228 * 00229 RETURN 00230 * 00231 * End of DSYR2 . 00232 * 00233 END