001:       SUBROUTINE SSYR(UPLO,N,ALPHA,X,INCX,A,LDA)
002: *     .. Scalar Arguments ..
003:       REAL ALPHA
004:       INTEGER INCX,LDA,N
005:       CHARACTER UPLO
006: *     ..
007: *     .. Array Arguments ..
008:       REAL A(LDA,*),X(*)
009: *     ..
010: *
011: *  Purpose
012: *  =======
013: *
014: *  SSYR   performs the symmetric rank 1 operation
015: *
016: *     A := alpha*x*x' + A,
017: *
018: *  where alpha is a real scalar, x is an n element vector and A is an
019: *  n by n symmetric matrix.
020: *
021: *  Arguments
022: *  ==========
023: *
024: *  UPLO   - CHARACTER*1.
025: *           On entry, UPLO specifies whether the upper or lower
026: *           triangular part of the array A is to be referenced as
027: *           follows:
028: *
029: *              UPLO = 'U' or 'u'   Only the upper triangular part of A
030: *                                  is to be referenced.
031: *
032: *              UPLO = 'L' or 'l'   Only the lower triangular part of A
033: *                                  is to be referenced.
034: *
035: *           Unchanged on exit.
036: *
037: *  N      - INTEGER.
038: *           On entry, N specifies the order of the matrix A.
039: *           N must be at least zero.
040: *           Unchanged on exit.
041: *
042: *  ALPHA  - REAL            .
043: *           On entry, ALPHA specifies the scalar alpha.
044: *           Unchanged on exit.
045: *
046: *  X      - REAL             array of dimension at least
047: *           ( 1 + ( n - 1 )*abs( INCX ) ).
048: *           Before entry, the incremented array X must contain the n
049: *           element vector x.
050: *           Unchanged on exit.
051: *
052: *  INCX   - INTEGER.
053: *           On entry, INCX specifies the increment for the elements of
054: *           X. INCX must not be zero.
055: *           Unchanged on exit.
056: *
057: *  A      - REAL             array of DIMENSION ( LDA, n ).
058: *           Before entry with  UPLO = 'U' or 'u', the leading n by n
059: *           upper triangular part of the array A must contain the upper
060: *           triangular part of the symmetric matrix and the strictly
061: *           lower triangular part of A is not referenced. On exit, the
062: *           upper triangular part of the array A is overwritten by the
063: *           upper triangular part of the updated matrix.
064: *           Before entry with UPLO = 'L' or 'l', the leading n by n
065: *           lower triangular part of the array A must contain the lower
066: *           triangular part of the symmetric matrix and the strictly
067: *           upper triangular part of A is not referenced. On exit, the
068: *           lower triangular part of the array A is overwritten by the
069: *           lower triangular part of the updated matrix.
070: *
071: *  LDA    - INTEGER.
072: *           On entry, LDA specifies the first dimension of A as declared
073: *           in the calling (sub) program. LDA must be at least
074: *           max( 1, n ).
075: *           Unchanged on exit.
076: *
077: *  Further Details
078: *  ===============
079: *
080: *  Level 2 Blas routine.
081: *
082: *  -- Written on 22-October-1986.
083: *     Jack Dongarra, Argonne National Lab.
084: *     Jeremy Du Croz, Nag Central Office.
085: *     Sven Hammarling, Nag Central Office.
086: *     Richard Hanson, Sandia National Labs.
087: *
088: *  =====================================================================
089: *
090: *     .. Parameters ..
091:       REAL ZERO
092:       PARAMETER (ZERO=0.0E+0)
093: *     ..
094: *     .. Local Scalars ..
095:       REAL TEMP
096:       INTEGER I,INFO,IX,J,JX,KX
097: *     ..
098: *     .. External Functions ..
099:       LOGICAL LSAME
100:       EXTERNAL LSAME
101: *     ..
102: *     .. External Subroutines ..
103:       EXTERNAL XERBLA
104: *     ..
105: *     .. Intrinsic Functions ..
106:       INTRINSIC MAX
107: *     ..
108: *
109: *     Test the input parameters.
110: *
111:       INFO = 0
112:       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
113:           INFO = 1
114:       ELSE IF (N.LT.0) THEN
115:           INFO = 2
116:       ELSE IF (INCX.EQ.0) THEN
117:           INFO = 5
118:       ELSE IF (LDA.LT.MAX(1,N)) THEN
119:           INFO = 7
120:       END IF
121:       IF (INFO.NE.0) THEN
122:           CALL XERBLA('SSYR  ',INFO)
123:           RETURN
124:       END IF
125: *
126: *     Quick return if possible.
127: *
128:       IF ((N.EQ.0) .OR. (ALPHA.EQ.ZERO)) RETURN
129: *
130: *     Set the start point in X if the increment is not unity.
131: *
132:       IF (INCX.LE.0) THEN
133:           KX = 1 - (N-1)*INCX
134:       ELSE IF (INCX.NE.1) THEN
135:           KX = 1
136:       END IF
137: *
138: *     Start the operations. In this version the elements of A are
139: *     accessed sequentially with one pass through the triangular part
140: *     of A.
141: *
142:       IF (LSAME(UPLO,'U')) THEN
143: *
144: *        Form  A  when A is stored in upper triangle.
145: *
146:           IF (INCX.EQ.1) THEN
147:               DO 20 J = 1,N
148:                   IF (X(J).NE.ZERO) THEN
149:                       TEMP = ALPHA*X(J)
150:                       DO 10 I = 1,J
151:                           A(I,J) = A(I,J) + X(I)*TEMP
152:    10                 CONTINUE
153:                   END IF
154:    20         CONTINUE
155:           ELSE
156:               JX = KX
157:               DO 40 J = 1,N
158:                   IF (X(JX).NE.ZERO) THEN
159:                       TEMP = ALPHA*X(JX)
160:                       IX = KX
161:                       DO 30 I = 1,J
162:                           A(I,J) = A(I,J) + X(IX)*TEMP
163:                           IX = IX + INCX
164:    30                 CONTINUE
165:                   END IF
166:                   JX = JX + INCX
167:    40         CONTINUE
168:           END IF
169:       ELSE
170: *
171: *        Form  A  when A is stored in lower triangle.
172: *
173:           IF (INCX.EQ.1) THEN
174:               DO 60 J = 1,N
175:                   IF (X(J).NE.ZERO) THEN
176:                       TEMP = ALPHA*X(J)
177:                       DO 50 I = J,N
178:                           A(I,J) = A(I,J) + X(I)*TEMP
179:    50                 CONTINUE
180:                   END IF
181:    60         CONTINUE
182:           ELSE
183:               JX = KX
184:               DO 80 J = 1,N
185:                   IF (X(JX).NE.ZERO) THEN
186:                       TEMP = ALPHA*X(JX)
187:                       IX = JX
188:                       DO 70 I = J,N
189:                           A(I,J) = A(I,J) + X(IX)*TEMP
190:                           IX = IX + INCX
191:    70                 CONTINUE
192:                   END IF
193:                   JX = JX + INCX
194:    80         CONTINUE
195:           END IF
196:       END IF
197: *
198:       RETURN
199: *
200: *     End of SSYR  .
201: *
202:       END
203: