LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dsyr2.f
Go to the documentation of this file.
00001 *> \brief \b DSYR2
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 DSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       DOUBLE PRECISION ALPHA
00015 *       INTEGER INCX,INCY,LDA,N
00016 *       CHARACTER UPLO
00017 *       ..
00018 *       .. Array Arguments ..
00019 *       DOUBLE PRECISION A(LDA,*),X(*),Y(*)
00020 *       ..
00021 *  
00022 *
00023 *> \par Purpose:
00024 *  =============
00025 *>
00026 *> \verbatim
00027 *>
00028 *> DSYR2  performs the symmetric rank 2 operation
00029 *>
00030 *>    A := alpha*x*y**T + alpha*y*x**T + A,
00031 *>
00032 *> where alpha is a scalar, x and y are n element vectors and A is an n
00033 *> by n symmetric matrix.
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 array A is to be referenced as
00044 *>           follows:
00045 *>
00046 *>              UPLO = 'U' or 'u'   Only the upper triangular part of A
00047 *>                                  is to be referenced.
00048 *>
00049 *>              UPLO = 'L' or 'l'   Only the lower triangular part of A
00050 *>                                  is to be referenced.
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 DOUBLE PRECISION.
00063 *>           On entry, ALPHA specifies the scalar alpha.
00064 *> \endverbatim
00065 *>
00066 *> \param[in] X
00067 *> \verbatim
00068 *>          X is DOUBLE PRECISION 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 DOUBLE PRECISION 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] A
00097 *> \verbatim
00098 *>          A is DOUBLE PRECISION array of DIMENSION ( LDA, n ).
00099 *>           Before entry with  UPLO = 'U' or 'u', the leading n by n
00100 *>           upper triangular part of the array A must contain the upper
00101 *>           triangular part of the symmetric matrix and the strictly
00102 *>           lower triangular part of A is not referenced. On exit, the
00103 *>           upper triangular part of the array A is overwritten by the
00104 *>           upper triangular part of the updated matrix.
00105 *>           Before entry with UPLO = 'L' or 'l', the leading n by n
00106 *>           lower triangular part of the array A must contain the lower
00107 *>           triangular part of the symmetric matrix and the strictly
00108 *>           upper triangular part of A is not referenced. On exit, the
00109 *>           lower triangular part of the array A is overwritten by the
00110 *>           lower triangular part of the updated matrix.
00111 *> \endverbatim
00112 *>
00113 *> \param[in] LDA
00114 *> \verbatim
00115 *>          LDA is INTEGER
00116 *>           On entry, LDA specifies the first dimension of A as declared
00117 *>           in the calling (sub) program. LDA must be at least
00118 *>           max( 1, n ).
00119 *> \endverbatim
00120 *
00121 *  Authors:
00122 *  ========
00123 *
00124 *> \author Univ. of Tennessee 
00125 *> \author Univ. of California Berkeley 
00126 *> \author Univ. of Colorado Denver 
00127 *> \author NAG Ltd. 
00128 *
00129 *> \date November 2011
00130 *
00131 *> \ingroup double_blas_level2
00132 *
00133 *> \par Further Details:
00134 *  =====================
00135 *>
00136 *> \verbatim
00137 *>
00138 *>  Level 2 Blas routine.
00139 *>
00140 *>  -- Written on 22-October-1986.
00141 *>     Jack Dongarra, Argonne National Lab.
00142 *>     Jeremy Du Croz, Nag Central Office.
00143 *>     Sven Hammarling, Nag Central Office.
00144 *>     Richard Hanson, Sandia National Labs.
00145 *> \endverbatim
00146 *>
00147 *  =====================================================================
00148       SUBROUTINE DSYR2(UPLO,N,ALPHA,X,INCX,Y,INCY,A,LDA)
00149 *
00150 *  -- Reference BLAS level2 routine (version 3.4.0) --
00151 *  -- Reference BLAS is a software package provided by Univ. of Tennessee,    --
00152 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00153 *     November 2011
00154 *
00155 *     .. Scalar Arguments ..
00156       DOUBLE PRECISION ALPHA
00157       INTEGER INCX,INCY,LDA,N
00158       CHARACTER UPLO
00159 *     ..
00160 *     .. Array Arguments ..
00161       DOUBLE PRECISION A(LDA,*),X(*),Y(*)
00162 *     ..
00163 *
00164 *  =====================================================================
00165 *
00166 *     .. Parameters ..
00167       DOUBLE PRECISION ZERO
00168       PARAMETER (ZERO=0.0D+0)
00169 *     ..
00170 *     .. Local Scalars ..
00171       DOUBLE PRECISION TEMP1,TEMP2
00172       INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY
00173 *     ..
00174 *     .. External Functions ..
00175       LOGICAL LSAME
00176       EXTERNAL LSAME
00177 *     ..
00178 *     .. External Subroutines ..
00179       EXTERNAL XERBLA
00180 *     ..
00181 *     .. Intrinsic Functions ..
00182       INTRINSIC MAX
00183 *     ..
00184 *
00185 *     Test the input parameters.
00186 *
00187       INFO = 0
00188       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00189           INFO = 1
00190       ELSE IF (N.LT.0) THEN
00191           INFO = 2
00192       ELSE IF (INCX.EQ.0) THEN
00193           INFO = 5
00194       ELSE IF (INCY.EQ.0) THEN
00195           INFO = 7
00196       ELSE IF (LDA.LT.MAX(1,N)) THEN
00197           INFO = 9
00198       END IF
00199       IF (INFO.NE.0) THEN
00200           CALL XERBLA('DSYR2 ',INFO)
00201           RETURN
00202       END IF
00203 *
00204 *     Quick return if possible.
00205 *
00206       IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
00207 *
00208 *     Set up the start points in X and Y if the increments are not both
00209 *     unity.
00210 *
00211       IF ((INCX.NE.1) .OR. (INCY.NE.1)) THEN
00212           IF (INCX.GT.0) THEN
00213               KX = 1
00214           ELSE
00215               KX = 1 - (N-1)*INCX
00216           END IF
00217           IF (INCY.GT.0) THEN
00218               KY = 1
00219           ELSE
00220               KY = 1 - (N-1)*INCY
00221           END IF
00222           JX = KX
00223           JY = KY
00224       END IF
00225 *
00226 *     Start the operations. In this version the elements of A are
00227 *     accessed sequentially with one pass through the triangular part
00228 *     of A.
00229 *
00230       IF (LSAME(UPLO,'U')) THEN
00231 *
00232 *        Form  A  when A is stored in the upper triangle.
00233 *
00234           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00235               DO 20 J = 1,N
00236                   IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
00237                       TEMP1 = ALPHA*Y(J)
00238                       TEMP2 = ALPHA*X(J)
00239                       DO 10 I = 1,J
00240                           A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
00241    10                 CONTINUE
00242                   END IF
00243    20         CONTINUE
00244           ELSE
00245               DO 40 J = 1,N
00246                   IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
00247                       TEMP1 = ALPHA*Y(JY)
00248                       TEMP2 = ALPHA*X(JX)
00249                       IX = KX
00250                       IY = KY
00251                       DO 30 I = 1,J
00252                           A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2
00253                           IX = IX + INCX
00254                           IY = IY + INCY
00255    30                 CONTINUE
00256                   END IF
00257                   JX = JX + INCX
00258                   JY = JY + INCY
00259    40         CONTINUE
00260           END IF
00261       ELSE
00262 *
00263 *        Form  A  when A is stored in the lower triangle.
00264 *
00265           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00266               DO 60 J = 1,N
00267                   IF ((X(J).NE.ZERO) .OR. (Y(J).NE.ZERO)) THEN
00268                       TEMP1 = ALPHA*Y(J)
00269                       TEMP2 = ALPHA*X(J)
00270                       DO 50 I = J,N
00271                           A(I,J) = A(I,J) + X(I)*TEMP1 + Y(I)*TEMP2
00272    50                 CONTINUE
00273                   END IF
00274    60         CONTINUE
00275           ELSE
00276               DO 80 J = 1,N
00277                   IF ((X(JX).NE.ZERO) .OR. (Y(JY).NE.ZERO)) THEN
00278                       TEMP1 = ALPHA*Y(JY)
00279                       TEMP2 = ALPHA*X(JX)
00280                       IX = JX
00281                       IY = JY
00282                       DO 70 I = J,N
00283                           A(I,J) = A(I,J) + X(IX)*TEMP1 + Y(IY)*TEMP2
00284                           IX = IX + INCX
00285                           IY = IY + INCY
00286    70                 CONTINUE
00287                   END IF
00288                   JX = JX + INCX
00289                   JY = JY + INCY
00290    80         CONTINUE
00291           END IF
00292       END IF
00293 *
00294       RETURN
00295 *
00296 *     End of DSYR2 .
00297 *
00298       END
 All Files Functions