1 /* ./src_f77/dgehrd.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 /* Table of constant values */
9
10 static integer c__1 = 1;
11 static integer c_n1 = -1;
12 static integer c__3 = 3;
13 static integer c__2 = 2;
14 static integer c__65 = 65;
15 static doublereal c_b25 = -1.;
16 static doublereal c_b26 = 1.;
17
dgehrd_(integer * n,integer * ilo,integer * ihi,doublereal * a,integer * lda,doublereal * tau,doublereal * work,integer * lwork,integer * info)18 /* Subroutine */ int dgehrd_(integer *n, integer *ilo, integer *ihi,
19 doublereal *a, integer *lda, doublereal *tau, doublereal *work,
20 integer *lwork, integer *info)
21 {
22 /* System generated locals */
23 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
24
25 /* Local variables */
26 static integer i__;
27 static doublereal t[4160] /* was [65][64] */;
28 static integer ib;
29 static doublereal ei;
30 static integer nb, nh, nx, iws;
31 extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *,
32 integer *, doublereal *, doublereal *, integer *, doublereal *,
33 integer *, doublereal *, doublereal *, integer *, ftnlen, ftnlen);
34 static integer nbmin, iinfo;
35 extern /* Subroutine */ int dgehd2_(integer *, integer *, integer *,
36 doublereal *, integer *, doublereal *, doublereal *, integer *),
37 dlarfb_(char *, char *, char *, char *, integer *, integer *,
38 integer *, doublereal *, integer *, doublereal *, integer *,
39 doublereal *, integer *, doublereal *, integer *, ftnlen, ftnlen,
40 ftnlen, ftnlen), dlahrd_(integer *, integer *, integer *,
41 doublereal *, integer *, doublereal *, doublereal *, integer *,
42 doublereal *, integer *), xerbla_(char *, integer *, ftnlen);
43 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
44 integer *, integer *, ftnlen, ftnlen);
45 static integer ldwork, lwkopt;
46 static logical lquery;
47
48
49 /* -- LAPACK routine (version 3.0) -- */
50 /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
51 /* Courant Institute, Argonne National Lab, and Rice University */
52 /* June 30, 1999 */
53
54 /* .. Scalar Arguments .. */
55 /* .. */
56 /* .. Array Arguments .. */
57 /* .. */
58
59 /* Purpose */
60 /* ======= */
61
62 /* DGEHRD reduces a real general matrix A to upper Hessenberg form H by */
63 /* an orthogonal similarity transformation: Q' * A * Q = H . */
64
65 /* Arguments */
66 /* ========= */
67
68 /* N (input) INTEGER */
69 /* The order of the matrix A. N >= 0. */
70
71 /* ILO (input) INTEGER */
72 /* IHI (input) INTEGER */
73 /* It is assumed that A is already upper triangular in rows */
74 /* and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */
75 /* set by a previous call to DGEBAL; otherwise they should be */
76 /* set to 1 and N respectively. See Further Details. */
77 /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
78
79 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
80 /* On entry, the N-by-N general matrix to be reduced. */
81 /* On exit, the upper triangle and the first subdiagonal of A */
82 /* are overwritten with the upper Hessenberg matrix H, and the */
83 /* elements below the first subdiagonal, with the array TAU, */
84 /* represent the orthogonal matrix Q as a product of elementary */
85 /* reflectors. See Further Details. */
86
87 /* LDA (input) INTEGER */
88 /* The leading dimension of the array A. LDA >= max(1,N). */
89
90 /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */
91 /* The scalar factors of the elementary reflectors (see Further */
92 /* Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to */
93 /* zero. */
94
95 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK) */
96 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
97
98 /* LWORK (input) INTEGER */
99 /* The length of the array WORK. LWORK >= max(1,N). */
100 /* For optimum performance LWORK >= N*NB, where NB is the */
101 /* optimal blocksize. */
102
103 /* If LWORK = -1, then a workspace query is assumed; the routine */
104 /* only calculates the optimal size of the WORK array, returns */
105 /* this value as the first entry of the WORK array, and no error */
106 /* message related to LWORK is issued by XERBLA. */
107
108 /* INFO (output) INTEGER */
109 /* = 0: successful exit */
110 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
111
112 /* Further Details */
113 /* =============== */
114
115 /* The matrix Q is represented as a product of (ihi-ilo) elementary */
116 /* reflectors */
117
118 /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */
119
120 /* Each H(i) has the form */
121
122 /* H(i) = I - tau * v * v' */
123
124 /* where tau is a real scalar, and v is a real vector with */
125 /* v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */
126 /* exit in A(i+2:ihi,i), and tau in TAU(i). */
127
128 /* The contents of A are illustrated by the following example, with */
129 /* n = 7, ilo = 2 and ihi = 6: */
130
131 /* on entry, on exit, */
132
133 /* ( a a a a a a a ) ( a a h h h h a ) */
134 /* ( a a a a a a ) ( a h h h h a ) */
135 /* ( a a a a a a ) ( h h h h h h ) */
136 /* ( a a a a a a ) ( v2 h h h h h ) */
137 /* ( a a a a a a ) ( v2 v3 h h h h ) */
138 /* ( a a a a a a ) ( v2 v3 v4 h h h ) */
139 /* ( a ) ( a ) */
140
141 /* where a denotes an element of the original matrix A, h denotes a */
142 /* modified element of the upper Hessenberg matrix H, and vi denotes an */
143 /* element of the vector defining H(i). */
144
145 /* ===================================================================== */
146
147 /* .. Parameters .. */
148 /* .. */
149 /* .. Local Scalars .. */
150 /* .. */
151 /* .. Local Arrays .. */
152 /* .. */
153 /* .. External Subroutines .. */
154 /* .. */
155 /* .. Intrinsic Functions .. */
156 /* .. */
157 /* .. External Functions .. */
158 /* .. */
159 /* .. Executable Statements .. */
160
161 /* Test the input parameters */
162
163 /* Parameter adjustments */
164 a_dim1 = *lda;
165 a_offset = 1 + a_dim1;
166 a -= a_offset;
167 --tau;
168 --work;
169
170 /* Function Body */
171 *info = 0;
172 /* Computing MIN */
173 i__1 = 64, i__2 = ilaenv_(&c__1, "DGEHRD", " ", n, ilo, ihi, &c_n1, (
174 ftnlen)6, (ftnlen)1);
175 nb = min(i__1,i__2);
176 lwkopt = *n * nb;
177 work[1] = (doublereal) lwkopt;
178 lquery = *lwork == -1;
179 if (*n < 0) {
180 *info = -1;
181 } else if (*ilo < 1 || *ilo > max(1,*n)) {
182 *info = -2;
183 } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
184 *info = -3;
185 } else if (*lda < max(1,*n)) {
186 *info = -5;
187 } else if (*lwork < max(1,*n) && ! lquery) {
188 *info = -8;
189 }
190 if (*info != 0) {
191 i__1 = -(*info);
192 xerbla_("DGEHRD", &i__1, (ftnlen)6);
193 return 0;
194 } else if (lquery) {
195 return 0;
196 }
197
198 /* Set elements 1:ILO-1 and IHI:N-1 of TAU to zero */
199
200 i__1 = *ilo - 1;
201 for (i__ = 1; i__ <= i__1; ++i__) {
202 tau[i__] = 0.;
203 /* L10: */
204 }
205 i__1 = *n - 1;
206 for (i__ = max(1,*ihi); i__ <= i__1; ++i__) {
207 tau[i__] = 0.;
208 /* L20: */
209 }
210
211 /* Quick return if possible */
212
213 nh = *ihi - *ilo + 1;
214 if (nh <= 1) {
215 work[1] = 1.;
216 return 0;
217 }
218
219 /* Determine the block size. */
220
221 /* Computing MIN */
222 i__1 = 64, i__2 = ilaenv_(&c__1, "DGEHRD", " ", n, ilo, ihi, &c_n1, (
223 ftnlen)6, (ftnlen)1);
224 nb = min(i__1,i__2);
225 nbmin = 2;
226 iws = 1;
227 if (nb > 1 && nb < nh) {
228
229 /* Determine when to cross over from blocked to unblocked code */
230 /* (last block is always handled by unblocked code). */
231
232 /* Computing MAX */
233 i__1 = nb, i__2 = ilaenv_(&c__3, "DGEHRD", " ", n, ilo, ihi, &c_n1, (
234 ftnlen)6, (ftnlen)1);
235 nx = max(i__1,i__2);
236 if (nx < nh) {
237
238 /* Determine if workspace is large enough for blocked code. */
239
240 iws = *n * nb;
241 if (*lwork < iws) {
242
243 /* Not enough workspace to use optimal NB: determine the */
244 /* minimum value of NB, and reduce NB or force use of */
245 /* unblocked code. */
246
247 /* Computing MAX */
248 i__1 = 2, i__2 = ilaenv_(&c__2, "DGEHRD", " ", n, ilo, ihi, &
249 c_n1, (ftnlen)6, (ftnlen)1);
250 nbmin = max(i__1,i__2);
251 if (*lwork >= *n * nbmin) {
252 nb = *lwork / *n;
253 } else {
254 nb = 1;
255 }
256 }
257 }
258 }
259 ldwork = *n;
260
261 if (nb < nbmin || nb >= nh) {
262
263 /* Use unblocked code below */
264
265 i__ = *ilo;
266
267 } else {
268
269 /* Use blocked code */
270
271 i__1 = *ihi - 1 - nx;
272 i__2 = nb;
273 for (i__ = *ilo; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
274 /* Computing MIN */
275 i__3 = nb, i__4 = *ihi - i__;
276 ib = min(i__3,i__4);
277
278 /* Reduce columns i:i+ib-1 to Hessenberg form, returning the */
279 /* matrices V and T of the block reflector H = I - V*T*V' */
280 /* which performs the reduction, and also the matrix Y = A*V*T */
281
282 dlahrd_(ihi, &i__, &ib, &a[i__ * a_dim1 + 1], lda, &tau[i__], t, &
283 c__65, &work[1], &ldwork);
284
285 /* Apply the block reflector H to A(1:ihi,i+ib:ihi) from the */
286 /* right, computing A := A - Y * V'. V(i+ib,ib-1) must be set */
287 /* to 1. */
288
289 ei = a[i__ + ib + (i__ + ib - 1) * a_dim1];
290 a[i__ + ib + (i__ + ib - 1) * a_dim1] = 1.;
291 i__3 = *ihi - i__ - ib + 1;
292 dgemm_("No transpose", "Transpose", ihi, &i__3, &ib, &c_b25, &
293 work[1], &ldwork, &a[i__ + ib + i__ * a_dim1], lda, &
294 c_b26, &a[(i__ + ib) * a_dim1 + 1], lda, (ftnlen)12, (
295 ftnlen)9);
296 a[i__ + ib + (i__ + ib - 1) * a_dim1] = ei;
297
298 /* Apply the block reflector H to A(i+1:ihi,i+ib:n) from the */
299 /* left */
300
301 i__3 = *ihi - i__;
302 i__4 = *n - i__ - ib + 1;
303 dlarfb_("Left", "Transpose", "Forward", "Columnwise", &i__3, &
304 i__4, &ib, &a[i__ + 1 + i__ * a_dim1], lda, t, &c__65, &a[
305 i__ + 1 + (i__ + ib) * a_dim1], lda, &work[1], &ldwork, (
306 ftnlen)4, (ftnlen)9, (ftnlen)7, (ftnlen)10);
307 /* L30: */
308 }
309 }
310
311 /* Use unblocked code to reduce the rest of the matrix */
312
313 dgehd2_(n, &i__, ihi, &a[a_offset], lda, &tau[1], &work[1], &iinfo);
314 work[1] = (doublereal) iws;
315
316 return 0;
317
318 /* End of DGEHRD */
319
320 } /* dgehrd_ */
321
322