Debian Codegraph @

debian/external_deps/fetk/punc/src/blas/dspr.c

raw
1 /* ./src_f77/dspr.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* Subroutine */ int dspr_(char *uplo, integer *n, doublereal *alpha,
9 doublereal *x, integer *incx, doublereal *ap, ftnlen uplo_len)
10 {
11 /* System generated locals */
12 integer i__1, i__2;
13
14 /* Local variables */
15 static integer i__, j, k, kk, ix, jx, kx, info;
16 static doublereal temp;
17 extern logical lsame_(char *, char *, ftnlen, ftnlen);
18 extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
19
20 /* .. Scalar Arguments .. */
21 /* .. Array Arguments .. */
22 /* .. */
23
24 /* Purpose */
25 /* ======= */
26
27 /* DSPR performs the symmetric rank 1 operation */
28
29 /* A := alpha*x*x' + A, */
30
31 /* where alpha is a real scalar, x is an n element vector and A is an */
32 /* n by n symmetric matrix, supplied in packed form. */
33
34 /* Parameters */
35 /* ========== */
36
37 /* UPLO - CHARACTER*1. */
38 /* On entry, UPLO specifies whether the upper or lower */
39 /* triangular part of the matrix A is supplied in the packed */
40 /* array AP as follows: */
41
42 /* UPLO = 'U' or 'u' The upper triangular part of A is */
43 /* supplied in AP. */
44
45 /* UPLO = 'L' or 'l' The lower triangular part of A is */
46 /* supplied in AP. */
47
48 /* Unchanged on exit. */
49
50 /* N - INTEGER. */
51 /* On entry, N specifies the order of the matrix A. */
52 /* N must be at least zero. */
53 /* Unchanged on exit. */
54
55 /* ALPHA - DOUBLE PRECISION. */
56 /* On entry, ALPHA specifies the scalar alpha. */
57 /* Unchanged on exit. */
58
59 /* X - DOUBLE PRECISION array of dimension at least */
60 /* ( 1 + ( n - 1 )*abs( INCX ) ). */
61 /* Before entry, the incremented array X must contain the n */
62 /* element vector x. */
63 /* Unchanged on exit. */
64
65 /* INCX - INTEGER. */
66 /* On entry, INCX specifies the increment for the elements of */
67 /* X. INCX must not be zero. */
68 /* Unchanged on exit. */
69
70 /* AP - DOUBLE PRECISION array of DIMENSION at least */
71 /* ( ( n*( n + 1 ) )/2 ). */
72 /* Before entry with UPLO = 'U' or 'u', the array AP must */
73 /* contain the upper triangular part of the symmetric matrix */
74 /* packed sequentially, column by column, so that AP( 1 ) */
75 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 ) */
76 /* and a( 2, 2 ) respectively, and so on. On exit, the array */
77 /* AP is overwritten by the upper triangular part of the */
78 /* updated matrix. */
79 /* Before entry with UPLO = 'L' or 'l', the array AP must */
80 /* contain the lower triangular part of the symmetric matrix */
81 /* packed sequentially, column by column, so that AP( 1 ) */
82 /* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 ) */
83 /* and a( 3, 1 ) respectively, and so on. On exit, the array */
84 /* AP is overwritten by the lower triangular part of the */
85 /* updated matrix. */
86
87
88 /* Level 2 Blas routine. */
89
90 /* -- Written on 22-October-1986. */
91 /* Jack Dongarra, Argonne National Lab. */
92 /* Jeremy Du Croz, Nag Central Office. */
93 /* Sven Hammarling, Nag Central Office. */
94 /* Richard Hanson, Sandia National Labs. */
95
96
97 /* .. Parameters .. */
98 /* .. Local Scalars .. */
99 /* .. External Functions .. */
100 /* .. External Subroutines .. */
101 /* .. */
102 /* .. Executable Statements .. */
103
104 /* Test the input parameters. */
105
106 /* Parameter adjustments */
107 --ap;
108 --x;
109
110 /* Function Body */
111 info = 0;
112 if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
113 ftnlen)1, (ftnlen)1)) {
114 info = 1;
115 } else if (*n < 0) {
116 info = 2;
117 } else if (*incx == 0) {
118 info = 5;
119 }
120 if (info != 0) {
121 xerbla_("DSPR ", &info, (ftnlen)6);
122 return 0;
123 }
124
125 /* Quick return if possible. */
126
127 if (*n == 0 || *alpha == 0.) {
128 return 0;
129 }
130
131 /* Set the start point in X if the increment is not unity. */
132
133 if (*incx <= 0) {
134 kx = 1 - (*n - 1) * *incx;
135 } else if (*incx != 1) {
136 kx = 1;
137 }
138
139 /* Start the operations. In this version the elements of the array AP */
140 /* are accessed sequentially with one pass through AP. */
141
142 kk = 1;
143 if (lsame_(uplo, "U", (ftnlen)1, (ftnlen)1)) {
144
145 /* Form A when upper triangle is stored in AP. */
146
147 if (*incx == 1) {
148 i__1 = *n;
149 for (j = 1; j <= i__1; ++j) {
150 if (x[j] != 0.) {
151 temp = *alpha * x[j];
152 k = kk;
153 i__2 = j;
154 for (i__ = 1; i__ <= i__2; ++i__) {
155 ap[k] += x[i__] * temp;
156 ++k;
157 /* L10: */
158 }
159 }
160 kk += j;
161 /* L20: */
162 }
163 } else {
164 jx = kx;
165 i__1 = *n;
166 for (j = 1; j <= i__1; ++j) {
167 if (x[jx] != 0.) {
168 temp = *alpha * x[jx];
169 ix = kx;
170 i__2 = kk + j - 1;
171 for (k = kk; k <= i__2; ++k) {
172 ap[k] += x[ix] * temp;
173 ix += *incx;
174 /* L30: */
175 }
176 }
177 jx += *incx;
178 kk += j;
179 /* L40: */
180 }
181 }
182 } else {
183
184 /* Form A when lower triangle is stored in AP. */
185
186 if (*incx == 1) {
187 i__1 = *n;
188 for (j = 1; j <= i__1; ++j) {
189 if (x[j] != 0.) {
190 temp = *alpha * x[j];
191 k = kk;
192 i__2 = *n;
193 for (i__ = j; i__ <= i__2; ++i__) {
194 ap[k] += x[i__] * temp;
195 ++k;
196 /* L50: */
197 }
198 }
199 kk = kk + *n - j + 1;
200 /* L60: */
201 }
202 } else {
203 jx = kx;
204 i__1 = *n;
205 for (j = 1; j <= i__1; ++j) {
206 if (x[jx] != 0.) {
207 temp = *alpha * x[jx];
208 ix = jx;
209 i__2 = kk + *n - j;
210 for (k = kk; k <= i__2; ++k) {
211 ap[k] += x[ix] * temp;
212 ix += *incx;
213 /* L70: */
214 }
215 }
216 jx += *incx;
217 kk = kk + *n - j + 1;
218 /* L80: */
219 }
220 }
221 }
222
223 return 0;
224
225 /* End of DSPR . */
226
227 } /* dspr_ */
228