LAPACK 3.3.1 Linear Algebra PACKage

# sspr.f

Go to the documentation of this file.
```00001       SUBROUTINE SSPR(UPLO,N,ALPHA,X,INCX,AP)
00002 *     .. Scalar Arguments ..
00003       REAL ALPHA
00004       INTEGER INCX,N
00005       CHARACTER UPLO
00006 *     ..
00007 *     .. Array Arguments ..
00008       REAL AP(*),X(*)
00009 *     ..
00010 *
00011 *  Purpose
00012 *  =======
00013 *
00014 *  SSPR    performs the symmetric rank 1 operation
00015 *
00016 *     A := alpha*x*x**T + A,
00017 *
00018 *  where alpha is a real scalar, x is an n element vector and A is an
00019 *  n by n symmetric 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      - REAL             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     - REAL             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 symmetric 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 symmetric 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 *
00074 *  Further Details
00075 *  ===============
00076 *
00077 *  Level 2 Blas routine.
00078 *
00079 *  -- Written on 22-October-1986.
00080 *     Jack Dongarra, Argonne National Lab.
00081 *     Jeremy Du Croz, Nag Central Office.
00082 *     Sven Hammarling, Nag Central Office.
00083 *     Richard Hanson, Sandia National Labs.
00084 *
00085 *  =====================================================================
00086 *
00087 *     .. Parameters ..
00088       REAL ZERO
00089       PARAMETER (ZERO=0.0E+0)
00090 *     ..
00091 *     .. Local Scalars ..
00092       REAL TEMP
00093       INTEGER I,INFO,IX,J,JX,K,KK,KX
00094 *     ..
00095 *     .. External Functions ..
00096       LOGICAL LSAME
00097       EXTERNAL LSAME
00098 *     ..
00099 *     .. External Subroutines ..
00100       EXTERNAL XERBLA
00101 *     ..
00102 *
00103 *     Test the input parameters.
00104 *
00105       INFO = 0
00106       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00107           INFO = 1
00108       ELSE IF (N.LT.0) THEN
00109           INFO = 2
00110       ELSE IF (INCX.EQ.0) THEN
00111           INFO = 5
00112       END IF
00113       IF (INFO.NE.0) THEN
00114           CALL XERBLA('SSPR  ',INFO)
00115           RETURN
00116       END IF
00117 *
00118 *     Quick return if possible.
00119 *
00120       IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
00121 *
00122 *     Set the start point in X if the increment is not unity.
00123 *
00124       IF (INCX.LE.0) THEN
00125           KX = 1 - (N-1)*INCX
00126       ELSE IF (INCX.NE.1) THEN
00127           KX = 1
00128       END IF
00129 *
00130 *     Start the operations. In this version the elements of the array AP
00131 *     are accessed sequentially with one pass through AP.
00132 *
00133       KK = 1
00134       IF (LSAME(UPLO,'U')) THEN
00135 *
00136 *        Form  A  when upper triangle is stored in AP.
00137 *
00138           IF (INCX.EQ.1) THEN
00139               DO 20 J = 1,N
00140                   IF (X(J).NE.ZERO) THEN
00141                       TEMP = ALPHA*X(J)
00142                       K = KK
00143                       DO 10 I = 1,J
00144                           AP(K) = AP(K) + X(I)*TEMP
00145                           K = K + 1
00146    10                 CONTINUE
00147                   END IF
00148                   KK = KK + J
00149    20         CONTINUE
00150           ELSE
00151               JX = KX
00152               DO 40 J = 1,N
00153                   IF (X(JX).NE.ZERO) THEN
00154                       TEMP = ALPHA*X(JX)
00155                       IX = KX
00156                       DO 30 K = KK,KK + J - 1
00157                           AP(K) = AP(K) + X(IX)*TEMP
00158                           IX = IX + INCX
00159    30                 CONTINUE
00160                   END IF
00161                   JX = JX + INCX
00162                   KK = KK + J
00163    40         CONTINUE
00164           END IF
00165       ELSE
00166 *
00167 *        Form  A  when lower triangle is stored in AP.
00168 *
00169           IF (INCX.EQ.1) THEN
00170               DO 60 J = 1,N
00171                   IF (X(J).NE.ZERO) THEN
00172                       TEMP = ALPHA*X(J)
00173                       K = KK
00174                       DO 50 I = J,N
00175                           AP(K) = AP(K) + X(I)*TEMP
00176                           K = K + 1
00177    50                 CONTINUE
00178                   END IF
00179                   KK = KK + N - J + 1
00180    60         CONTINUE
00181           ELSE
00182               JX = KX
00183               DO 80 J = 1,N
00184                   IF (X(JX).NE.ZERO) THEN
00185                       TEMP = ALPHA*X(JX)
00186                       IX = JX
00187                       DO 70 K = KK,KK + N - J
00188                           AP(K) = AP(K) + X(IX)*TEMP
00189                           IX = IX + INCX
00190    70                 CONTINUE
00191                   END IF
00192                   JX = JX + INCX
00193                   KK = KK + N - J + 1
00194    80         CONTINUE
00195           END IF
00196       END IF
00197 *
00198       RETURN
00199 *
00200 *     End of SSPR  .
00201 *
00202       END
```