3 /* Subroutine */ int dsyr2_(char *uplo, integer *n, doublereal *alpha,
4 doublereal *x, integer *incx, doublereal *y, integer *incy,
5 doublereal *a, integer *lda)
7 /* System generated locals */
8 integer a_dim1, a_offset, i__1, i__2;
11 integer i__, j, ix, iy, jx, jy, kx, ky, info;
12 doublereal temp1, temp2;
13 extern logical lsame_(char *, char *);
14 extern /* Subroutine */ int xerbla_(char *, integer *);
16 /* .. Scalar Arguments .. */
18 /* .. Array Arguments .. */
24 /* DSYR2 performs the symmetric rank 2 operation */
26 /* A := alpha*x*y' + alpha*y*x' + A, */
28 /* where alpha is a scalar, x and y are n element vectors and A is an n */
29 /* by n symmetric matrix. */
34 /* UPLO - CHARACTER*1. */
35 /* On entry, UPLO specifies whether the upper or lower */
36 /* triangular part of the array A is to be referenced as */
39 /* UPLO = 'U' or 'u' Only the upper triangular part of A */
40 /* is to be referenced. */
42 /* UPLO = 'L' or 'l' Only the lower triangular part of A */
43 /* is to be referenced. */
45 /* Unchanged on exit. */
48 /* On entry, N specifies the order of the matrix A. */
49 /* N must be at least zero. */
50 /* Unchanged on exit. */
52 /* ALPHA - DOUBLE PRECISION. */
53 /* On entry, ALPHA specifies the scalar alpha. */
54 /* Unchanged on exit. */
56 /* X - DOUBLE PRECISION array of dimension at least */
57 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
58 /* Before entry, the incremented array X must contain the n */
59 /* element vector x. */
60 /* Unchanged on exit. */
63 /* On entry, INCX specifies the increment for the elements of */
64 /* X. INCX must not be zero. */
65 /* Unchanged on exit. */
67 /* Y - DOUBLE PRECISION array of dimension at least */
68 /* ( 1 + ( n - 1 )*abs( INCY ) ). */
69 /* Before entry, the incremented array Y must contain the n */
70 /* element vector y. */
71 /* Unchanged on exit. */
74 /* On entry, INCY specifies the increment for the elements of */
75 /* Y. INCY must not be zero. */
76 /* Unchanged on exit. */
78 /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ). */
79 /* Before entry with UPLO = 'U' or 'u', the leading n by n */
80 /* upper triangular part of the array A must contain the upper */
81 /* triangular part of the symmetric matrix and the strictly */
82 /* lower triangular part of A is not referenced. On exit, the */
83 /* upper triangular part of the array A is overwritten by the */
84 /* upper triangular part of the updated matrix. */
85 /* Before entry with UPLO = 'L' or 'l', the leading n by n */
86 /* lower triangular part of the array A must contain the lower */
87 /* triangular part of the symmetric matrix and the strictly */
88 /* upper triangular part of A is not referenced. On exit, the */
89 /* lower triangular part of the array A is overwritten by the */
90 /* lower triangular part of the updated matrix. */
93 /* On entry, LDA specifies the first dimension of A as declared */
94 /* in the calling (sub) program. LDA must be at least */
96 /* Unchanged on exit. */
99 /* Level 2 Blas routine. */
101 /* -- Written on 22-October-1986. */
102 /* Jack Dongarra, Argonne National Lab. */
103 /* Jeremy Du Croz, Nag Central Office. */
104 /* Sven Hammarling, Nag Central Office. */
105 /* Richard Hanson, Sandia National Labs. */
108 /* .. Parameters .. */
110 /* .. Local Scalars .. */
112 /* .. External Functions .. */
114 /* .. External Subroutines .. */
116 /* .. Intrinsic Functions .. */
119 /* Test the input parameters. */
121 /* Parameter adjustments */
125 a_offset = 1 + a_dim1;
130 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
134 } else if (*incx == 0) {
136 } else if (*incy == 0) {
138 } else if (*lda < max(1,*n)) {
142 xerbla_("DSYR2 ", &info);
146 /* Quick return if possible. */
148 if (*n == 0 || *alpha == 0.) {
152 /* Set up the start points in X and Y if the increments are not both */
155 if (*incx != 1 || *incy != 1) {
159 kx = 1 - (*n - 1) * *incx;
164 ky = 1 - (*n - 1) * *incy;
170 /* Start the operations. In this version the elements of A are */
171 /* accessed sequentially with one pass through the triangular part */
174 if (lsame_(uplo, "U")) {
176 /* Form A when A is stored in the upper triangle. */
178 if (*incx == 1 && *incy == 1) {
180 for (j = 1; j <= i__1; ++j) {
181 if (x[j] != 0. || y[j] != 0.) {
182 temp1 = *alpha * y[j];
183 temp2 = *alpha * x[j];
185 for (i__ = 1; i__ <= i__2; ++i__) {
186 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
187 temp1 + y[i__] * temp2;
195 for (j = 1; j <= i__1; ++j) {
196 if (x[jx] != 0. || y[jy] != 0.) {
197 temp1 = *alpha * y[jy];
198 temp2 = *alpha * x[jx];
202 for (i__ = 1; i__ <= i__2; ++i__) {
203 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
204 temp1 + y[iy] * temp2;
217 /* Form A when A is stored in the lower triangle. */
219 if (*incx == 1 && *incy == 1) {
221 for (j = 1; j <= i__1; ++j) {
222 if (x[j] != 0. || y[j] != 0.) {
223 temp1 = *alpha * y[j];
224 temp2 = *alpha * x[j];
226 for (i__ = j; i__ <= i__2; ++i__) {
227 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[i__] *
228 temp1 + y[i__] * temp2;
236 for (j = 1; j <= i__1; ++j) {
237 if (x[jx] != 0. || y[jy] != 0.) {
238 temp1 = *alpha * y[jy];
239 temp2 = *alpha * x[jx];
243 for (i__ = j; i__ <= i__2; ++i__) {
244 a[i__ + j * a_dim1] = a[i__ + j * a_dim1] + x[ix] *
245 temp1 + y[iy] * temp2;