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