3 /* Subroutine */ int ssyr2_(char *uplo, integer *n, real *alpha, real *x,
4 integer *incx, real *y, integer *incy, real *a, integer *lda)
6 /* System generated locals */
7 integer a_dim1, a_offset, i__1, i__2;
10 integer i__, j, ix, iy, jx, jy, kx, ky, info;
12 extern logical lsame_(char *, char *);
13 extern /* Subroutine */ int xerbla_(char *, integer *);
15 /* .. Scalar Arguments .. */
17 /* .. Array Arguments .. */
23 /* SSYR2 performs the symmetric rank 2 operation */
25 /* A := alpha*x*y' + alpha*y*x' + A, */
27 /* where alpha is a scalar, x and y are n element vectors and A is an n */
28 /* by n symmetric matrix. */
33 /* UPLO - CHARACTER*1. */
34 /* On entry, UPLO specifies whether the upper or lower */
35 /* triangular part of the array A is to be referenced as */
38 /* UPLO = 'U' or 'u' Only the upper triangular part of A */
39 /* is to be referenced. */
41 /* UPLO = 'L' or 'l' Only the lower triangular part of A */
42 /* is to be referenced. */
44 /* Unchanged on exit. */
47 /* On entry, N specifies the order of the matrix A. */
48 /* N must be at least zero. */
49 /* Unchanged on exit. */
52 /* On entry, ALPHA specifies the scalar alpha. */
53 /* Unchanged on exit. */
55 /* X - REAL array of dimension at least */
56 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
57 /* Before entry, the incremented array X must contain the n */
58 /* element vector x. */
59 /* Unchanged on exit. */
62 /* On entry, INCX specifies the increment for the elements of */
63 /* X. INCX must not be zero. */
64 /* Unchanged on exit. */
66 /* Y - REAL array of dimension at least */
67 /* ( 1 + ( n - 1 )*abs( INCY ) ). */
68 /* Before entry, the incremented array Y must contain the n */
69 /* element vector y. */
70 /* Unchanged on exit. */
73 /* On entry, INCY specifies the increment for the elements of */
74 /* Y. INCY must not be zero. */
75 /* Unchanged on exit. */
77 /* A - REAL array of DIMENSION ( LDA, n ). */
78 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
79 /* upper triangular part of the array A must contain the upper */
80 /* triangular part of the symmetric matrix and the strictly */
81 /* lower triangular part of A is not referenced. On exit, the */
82 /* upper triangular part of the array A is overwritten by the */
83 /* upper triangular part of the updated matrix. */
84 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
85 /* lower triangular part of the array A must contain the lower */
86 /* triangular part of the symmetric matrix and the strictly */
87 /* upper triangular part of A is not referenced. On exit, the */
88 /* lower triangular part of the array A is overwritten by the */
89 /* lower triangular part of the updated matrix. */
92 /* On entry, LDA specifies the first dimension of A as declared */
93 /* in the calling (sub) program. LDA must be at least */
95 /* Unchanged on exit. */
98 /* Level 2 Blas routine. */
100 /* -- Written on 22-October-1986. */
101 /* Jack Dongarra, Argonne National Lab. */
102 /* Jeremy Du Croz, Nag Central Office. */
103 /* Sven Hammarling, Nag Central Office. */
104 /* Richard Hanson, Sandia National Labs. */
107 /* .. Parameters .. */
109 /* .. Local Scalars .. */
111 /* .. External Functions .. */
113 /* .. External Subroutines .. */
115 /* .. Intrinsic Functions .. */
118 /* Test the input parameters. */
120 /* Parameter adjustments */
124 a_offset = 1 + a_dim1;
129 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
133 } else if (*incx == 0) {
135 } else if (*incy == 0) {
137 } else if (*lda < max(1,*n)) {
141 xerbla_("SSYR2 ", &info);
145 /* Quick return if possible. */
147 if (*n == 0 || *alpha == 0.f) {
151 /* Set up the start points in X and Y if the increments are not both */
154 if (*incx != 1 || *incy != 1) {
158 kx = 1 - (*n - 1) * *incx;
163 ky = 1 - (*n - 1) * *incy;
169 /* Start the operations. In this version the elements of A are */
170 /* accessed sequentially with one pass through the triangular part */
173 if (lsame_(uplo, "U")) {
175 /* Form A when A is stored in the upper triangle. */
177 if (*incx == 1 && *incy == 1) {
179 for (j = 1; j <= i__1; ++j) {
180 if (x[j] != 0.f || y[j] != 0.f) {
181 temp1 = *alpha * y[j];
182 temp2 = *alpha * x[j];
184 for (i__ = 1; i__ <= i__2; ++i__) {
185 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
186 temp1 + y[i__] * temp2;
194 for (j = 1; j <= i__1; ++j) {
195 if (x[jx] != 0.f || y[jy] != 0.f) {
196 temp1 = *alpha * y[jy];
197 temp2 = *alpha * x[jx];
201 for (i__ = 1; i__ <= i__2; ++i__) {
202 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
203 temp1 + y[iy] * temp2;
216 /* Form A when A is stored in the lower triangle. */
218 if (*incx == 1 && *incy == 1) {
220 for (j = 1; j <= i__1; ++j) {
221 if (x[j] != 0.f || y[j] != 0.f) {
222 temp1 = *alpha * y[j];
223 temp2 = *alpha * x[j];
225 for (i__ = j; i__ <= i__2; ++i__) {
226 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
227 temp1 + y[i__] * temp2;
235 for (j = 1; j <= i__1; ++j) {
236 if (x[jx] != 0.f || y[jy] != 0.f) {
237 temp1 = *alpha * y[jy];
238 temp2 = *alpha * x[jx];
242 for (i__ = j; i__ <= i__2; ++i__) {
243 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
244 temp1 + y[iy] * temp2;