3 /* Table of constant values */
5 static doublereal c_b5 = -1.;
6 static doublereal c_b6 = 1.;
7 static integer c__1 = 1;
8 static doublereal c_b16 = 0.;
10 /* Subroutine */ int dlatrd_(char *uplo, integer *n, integer *nb, doublereal *
11 a, integer *lda, doublereal *e, doublereal *tau, doublereal *w,
14 /* System generated locals */
15 integer a_dim1, a_offset, w_dim1, w_offset, i__1, i__2, i__3;
19 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
22 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
24 extern logical lsame_(char *, char *);
25 extern /* Subroutine */ int dgemv_(char *, integer *, integer *,
26 doublereal *, doublereal *, integer *, doublereal *, integer *,
27 doublereal *, doublereal *, integer *), daxpy_(integer *,
28 doublereal *, doublereal *, integer *, doublereal *, integer *),
29 dsymv_(char *, integer *, doublereal *, doublereal *, integer *,
30 doublereal *, integer *, doublereal *, doublereal *, integer *), dlarfg_(integer *, doublereal *, doublereal *, integer *,
34 /* -- LAPACK auxiliary routine (version 3.1) -- */
35 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
38 /* .. Scalar Arguments .. */
40 /* .. Array Arguments .. */
46 /* DLATRD reduces NB rows and columns of a real symmetric matrix A to */
47 /* symmetric tridiagonal form by an orthogonal similarity */
48 /* transformation Q' * A * Q, and returns the matrices V and W which are */
49 /* needed to apply the transformation to the unreduced part of A. */
51 /* If UPLO = 'U', DLATRD reduces the last NB rows and columns of a */
52 /* matrix, of which the upper triangle is supplied; */
53 /* if UPLO = 'L', DLATRD reduces the first NB rows and columns of a */
54 /* matrix, of which the lower triangle is supplied. */
56 /* This is an auxiliary routine called by DSYTRD. */
61 /* UPLO (input) CHARACTER*1 */
62 /* Specifies whether the upper or lower triangular part of the */
63 /* symmetric matrix A is stored: */
64 /* = 'U': Upper triangular */
65 /* = 'L': Lower triangular */
67 /* N (input) INTEGER */
68 /* The order of the matrix A. */
70 /* NB (input) INTEGER */
71 /* The number of rows and columns to be reduced. */
73 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
74 /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
75 /* n-by-n upper triangular part of A contains the upper */
76 /* triangular part of the matrix A, and the strictly lower */
77 /* triangular part of A is not referenced. If UPLO = 'L', the */
78 /* leading n-by-n lower triangular part of A contains the lower */
79 /* triangular part of the matrix A, and the strictly upper */
80 /* triangular part of A is not referenced. */
82 /* if UPLO = 'U', the last NB columns have been reduced to */
83 /* tridiagonal form, with the diagonal elements overwriting */
84 /* the diagonal elements of A; the elements above the diagonal */
85 /* with the array TAU, represent the orthogonal matrix Q as a */
86 /* product of elementary reflectors; */
87 /* if UPLO = 'L', the first NB columns have been reduced to */
88 /* tridiagonal form, with the diagonal elements overwriting */
89 /* the diagonal elements of A; the elements below the diagonal */
90 /* with the array TAU, represent the orthogonal matrix Q as a */
91 /* product of elementary reflectors. */
92 /* See Further Details. */
94 /* LDA (input) INTEGER */
95 /* The leading dimension of the array A. LDA >= (1,N). */
97 /* E (output) DOUBLE PRECISION array, dimension (N-1) */
98 /* If UPLO = 'U', E(n-nb:n-1) contains the superdiagonal */
99 /* elements of the last NB columns of the reduced matrix; */
100 /* if UPLO = 'L', E(1:nb) contains the subdiagonal elements of */
101 /* the first NB columns of the reduced matrix. */
103 /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */
104 /* The scalar factors of the elementary reflectors, stored in */
105 /* TAU(n-nb:n-1) if UPLO = 'U', and in TAU(1:nb) if UPLO = 'L'. */
106 /* See Further Details. */
108 /* W (output) DOUBLE PRECISION array, dimension (LDW,NB) */
109 /* The n-by-nb matrix W required to update the unreduced part */
112 /* LDW (input) INTEGER */
113 /* The leading dimension of the array W. LDW >= max(1,N). */
115 /* Further Details */
116 /* =============== */
118 /* If UPLO = 'U', the matrix Q is represented as a product of elementary */
121 /* Q = H(n) H(n-1) . . . H(n-nb+1). */
123 /* Each H(i) has the form */
125 /* H(i) = I - tau * v * v' */
127 /* where tau is a real scalar, and v is a real vector with */
128 /* v(i:n) = 0 and v(i-1) = 1; v(1:i-1) is stored on exit in A(1:i-1,i), */
129 /* and tau in TAU(i-1). */
131 /* If UPLO = 'L', the matrix Q is represented as a product of elementary */
134 /* Q = H(1) H(2) . . . H(nb). */
136 /* Each H(i) has the form */
138 /* H(i) = I - tau * v * v' */
140 /* where tau is a real scalar, and v is a real vector with */
141 /* v(1:i) = 0 and v(i+1) = 1; v(i+1:n) is stored on exit in A(i+1:n,i), */
142 /* and tau in TAU(i). */
144 /* The elements of the vectors v together form the n-by-nb matrix V */
145 /* which is needed, with W, to apply the transformation to the unreduced */
146 /* part of the matrix, using a symmetric rank-2k update of the form: */
147 /* A := A - V*W' - W*V'. */
149 /* The contents of A on exit are illustrated by the following examples */
150 /* with n = 5 and nb = 2: */
152 /* if UPLO = 'U': if UPLO = 'L': */
154 /* ( a a a v4 v5 ) ( d ) */
155 /* ( a a v4 v5 ) ( 1 d ) */
156 /* ( a 1 v5 ) ( v1 1 a ) */
157 /* ( d 1 ) ( v1 v2 a a ) */
158 /* ( d ) ( v1 v2 a a a ) */
160 /* where d denotes a diagonal element of the reduced matrix, a denotes */
161 /* an element of the original matrix that is unchanged, and vi denotes */
162 /* an element of the vector defining H(i). */
164 /* ===================================================================== */
166 /* .. Parameters .. */
168 /* .. Local Scalars .. */
170 /* .. External Subroutines .. */
172 /* .. External Functions .. */
174 /* .. Intrinsic Functions .. */
176 /* .. Executable Statements .. */
178 /* Quick return if possible */
180 /* Parameter adjustments */
182 a_offset = 1 + a_dim1;
187 w_offset = 1 + w_dim1;
195 if (lsame_(uplo, "U")) {
197 /* Reduce last NB columns of upper triangle */
200 for (i__ = *n; i__ >= i__1; --i__) {
204 /* Update A(1:i,i) */
207 dgemv_("No transpose", &i__, &i__2, &c_b5, &a[(i__ + 1) *
208 a_dim1 + 1], lda, &w[i__ + (iw + 1) * w_dim1], ldw, &
209 c_b6, &a[i__ * a_dim1 + 1], &c__1);
211 dgemv_("No transpose", &i__, &i__2, &c_b5, &w[(iw + 1) *
212 w_dim1 + 1], ldw, &a[i__ + (i__ + 1) * a_dim1], lda, &
213 c_b6, &a[i__ * a_dim1 + 1], &c__1);
217 /* Generate elementary reflector H(i) to annihilate */
221 dlarfg_(&i__2, &a[i__ - 1 + i__ * a_dim1], &a[i__ * a_dim1 +
222 1], &c__1, &tau[i__ - 1]);
223 e[i__ - 1] = a[i__ - 1 + i__ * a_dim1];
224 a[i__ - 1 + i__ * a_dim1] = 1.;
226 /* Compute W(1:i-1,i) */
229 dsymv_("Upper", &i__2, &c_b6, &a[a_offset], lda, &a[i__ *
230 a_dim1 + 1], &c__1, &c_b16, &w[iw * w_dim1 + 1], &
235 dgemv_("Transpose", &i__2, &i__3, &c_b6, &w[(iw + 1) *
236 w_dim1 + 1], ldw, &a[i__ * a_dim1 + 1], &c__1, &
237 c_b16, &w[i__ + 1 + iw * w_dim1], &c__1);
240 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[(i__ + 1) *
241 a_dim1 + 1], lda, &w[i__ + 1 + iw * w_dim1], &
242 c__1, &c_b6, &w[iw * w_dim1 + 1], &c__1);
245 dgemv_("Transpose", &i__2, &i__3, &c_b6, &a[(i__ + 1) *
246 a_dim1 + 1], lda, &a[i__ * a_dim1 + 1], &c__1, &
247 c_b16, &w[i__ + 1 + iw * w_dim1], &c__1);
250 dgemv_("No transpose", &i__2, &i__3, &c_b5, &w[(iw + 1) *
251 w_dim1 + 1], ldw, &w[i__ + 1 + iw * w_dim1], &
252 c__1, &c_b6, &w[iw * w_dim1 + 1], &c__1);
255 dscal_(&i__2, &tau[i__ - 1], &w[iw * w_dim1 + 1], &c__1);
257 alpha = tau[i__ - 1] * -.5 * ddot_(&i__2, &w[iw * w_dim1 + 1],
258 &c__1, &a[i__ * a_dim1 + 1], &c__1);
260 daxpy_(&i__2, &alpha, &a[i__ * a_dim1 + 1], &c__1, &w[iw *
268 /* Reduce first NB columns of lower triangle */
271 for (i__ = 1; i__ <= i__1; ++i__) {
273 /* Update A(i:n,i) */
277 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + a_dim1], lda,
278 &w[i__ + w_dim1], ldw, &c_b6, &a[i__ + i__ * a_dim1], &
282 dgemv_("No transpose", &i__2, &i__3, &c_b5, &w[i__ + w_dim1], ldw,
283 &a[i__ + a_dim1], lda, &c_b6, &a[i__ + i__ * a_dim1], &
287 /* Generate elementary reflector H(i) to annihilate */
293 dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *n)+
294 i__ * a_dim1], &c__1, &tau[i__]);
295 e[i__] = a[i__ + 1 + i__ * a_dim1];
296 a[i__ + 1 + i__ * a_dim1] = 1.;
298 /* Compute W(i+1:n,i) */
301 dsymv_("Lower", &i__2, &c_b6, &a[i__ + 1 + (i__ + 1) * a_dim1]
302 , lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &w[
303 i__ + 1 + i__ * w_dim1], &c__1);
306 dgemv_("Transpose", &i__2, &i__3, &c_b6, &w[i__ + 1 + w_dim1],
307 ldw, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &w[
308 i__ * w_dim1 + 1], &c__1);
311 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 +
312 a_dim1], lda, &w[i__ * w_dim1 + 1], &c__1, &c_b6, &w[
313 i__ + 1 + i__ * w_dim1], &c__1);
316 dgemv_("Transpose", &i__2, &i__3, &c_b6, &a[i__ + 1 + a_dim1],
317 lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &w[
318 i__ * w_dim1 + 1], &c__1);
321 dgemv_("No transpose", &i__2, &i__3, &c_b5, &w[i__ + 1 +
322 w_dim1], ldw, &w[i__ * w_dim1 + 1], &c__1, &c_b6, &w[
323 i__ + 1 + i__ * w_dim1], &c__1);
325 dscal_(&i__2, &tau[i__], &w[i__ + 1 + i__ * w_dim1], &c__1);
327 alpha = tau[i__] * -.5 * ddot_(&i__2, &w[i__ + 1 + i__ *
328 w_dim1], &c__1, &a[i__ + 1 + i__ * a_dim1], &c__1);
330 daxpy_(&i__2, &alpha, &a[i__ + 1 + i__ * a_dim1], &c__1, &w[
331 i__ + 1 + i__ * w_dim1], &c__1);