/src/igraph/vendor/lapack/dtrevc.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* -- translated by f2c (version 20191129). |
2 | | You must link the resulting object file with libf2c: |
3 | | on Microsoft Windows system, link with libf2c.lib; |
4 | | on Linux or Unix systems, link with .../path/to/libf2c.a -lm |
5 | | or, if you install libf2c.a in a standard place, with -lf2c -lm |
6 | | -- in that order, at the end of the command line, as in |
7 | | cc *.o -lf2c -lm |
8 | | Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., |
9 | | |
10 | | http://www.netlib.org/f2c/libf2c.zip |
11 | | */ |
12 | | |
13 | | #include "f2c.h" |
14 | | |
15 | | /* Table of constant values */ |
16 | | |
17 | | static logical c_false = FALSE_; |
18 | | static integer c__1 = 1; |
19 | | static doublereal c_b22 = 1.; |
20 | | static doublereal c_b25 = 0.; |
21 | | static integer c__2 = 2; |
22 | | static logical c_true = TRUE_; |
23 | | |
24 | | /* > \brief \b DTREVC |
25 | | |
26 | | =========== DOCUMENTATION =========== |
27 | | |
28 | | Online html documentation available at |
29 | | http://www.netlib.org/lapack/explore-html/ |
30 | | |
31 | | > \htmlonly |
32 | | > Download DTREVC + dependencies |
33 | | > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtrevc. |
34 | | f"> |
35 | | > [TGZ]</a> |
36 | | > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtrevc. |
37 | | f"> |
38 | | > [ZIP]</a> |
39 | | > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtrevc. |
40 | | f"> |
41 | | > [TXT]</a> |
42 | | > \endhtmlonly |
43 | | |
44 | | Definition: |
45 | | =========== |
46 | | |
47 | | SUBROUTINE DTREVC( SIDE, HOWMNY, SELECT, N, T, LDT, VL, LDVL, VR, |
48 | | LDVR, MM, M, WORK, INFO ) |
49 | | |
50 | | CHARACTER HOWMNY, SIDE |
51 | | INTEGER INFO, LDT, LDVL, LDVR, M, MM, N |
52 | | LOGICAL SELECT( * ) |
53 | | DOUBLE PRECISION T( LDT, * ), VL( LDVL, * ), VR( LDVR, * ), |
54 | | $ WORK( * ) |
55 | | |
56 | | |
57 | | > \par Purpose: |
58 | | ============= |
59 | | > |
60 | | > \verbatim |
61 | | > |
62 | | > DTREVC computes some or all of the right and/or left eigenvectors of |
63 | | > a real upper quasi-triangular matrix T. |
64 | | > Matrices of this type are produced by the Schur factorization of |
65 | | > a real general matrix: A = Q*T*Q**T, as computed by DHSEQR. |
66 | | > |
67 | | > The right eigenvector x and the left eigenvector y of T corresponding |
68 | | > to an eigenvalue w are defined by: |
69 | | > |
70 | | > T*x = w*x, (y**T)*T = w*(y**T) |
71 | | > |
72 | | > where y**T denotes the transpose of y. |
73 | | > The eigenvalues are not input to this routine, but are read directly |
74 | | > from the diagonal blocks of T. |
75 | | > |
76 | | > This routine returns the matrices X and/or Y of right and left |
77 | | > eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an |
78 | | > input matrix. If Q is the orthogonal factor that reduces a matrix |
79 | | > A to Schur form T, then Q*X and Q*Y are the matrices of right and |
80 | | > left eigenvectors of A. |
81 | | > \endverbatim |
82 | | |
83 | | Arguments: |
84 | | ========== |
85 | | |
86 | | > \param[in] SIDE |
87 | | > \verbatim |
88 | | > SIDE is CHARACTER*1 |
89 | | > = 'R': compute right eigenvectors only; |
90 | | > = 'L': compute left eigenvectors only; |
91 | | > = 'B': compute both right and left eigenvectors. |
92 | | > \endverbatim |
93 | | > |
94 | | > \param[in] HOWMNY |
95 | | > \verbatim |
96 | | > HOWMNY is CHARACTER*1 |
97 | | > = 'A': compute all right and/or left eigenvectors; |
98 | | > = 'B': compute all right and/or left eigenvectors, |
99 | | > backtransformed by the matrices in VR and/or VL; |
100 | | > = 'S': compute selected right and/or left eigenvectors, |
101 | | > as indicated by the logical array SELECT. |
102 | | > \endverbatim |
103 | | > |
104 | | > \param[in,out] SELECT |
105 | | > \verbatim |
106 | | > SELECT is LOGICAL array, dimension (N) |
107 | | > If HOWMNY = 'S', SELECT specifies the eigenvectors to be |
108 | | > computed. |
109 | | > If w(j) is a real eigenvalue, the corresponding real |
110 | | > eigenvector is computed if SELECT(j) is .TRUE.. |
111 | | > If w(j) and w(j+1) are the real and imaginary parts of a |
112 | | > complex eigenvalue, the corresponding complex eigenvector is |
113 | | > computed if either SELECT(j) or SELECT(j+1) is .TRUE., and |
114 | | > on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is set to |
115 | | > .FALSE.. |
116 | | > Not referenced if HOWMNY = 'A' or 'B'. |
117 | | > \endverbatim |
118 | | > |
119 | | > \param[in] N |
120 | | > \verbatim |
121 | | > N is INTEGER |
122 | | > The order of the matrix T. N >= 0. |
123 | | > \endverbatim |
124 | | > |
125 | | > \param[in] T |
126 | | > \verbatim |
127 | | > T is DOUBLE PRECISION array, dimension (LDT,N) |
128 | | > The upper quasi-triangular matrix T in Schur canonical form. |
129 | | > \endverbatim |
130 | | > |
131 | | > \param[in] LDT |
132 | | > \verbatim |
133 | | > LDT is INTEGER |
134 | | > The leading dimension of the array T. LDT >= max(1,N). |
135 | | > \endverbatim |
136 | | > |
137 | | > \param[in,out] VL |
138 | | > \verbatim |
139 | | > VL is DOUBLE PRECISION array, dimension (LDVL,MM) |
140 | | > On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must |
141 | | > contain an N-by-N matrix Q (usually the orthogonal matrix Q |
142 | | > of Schur vectors returned by DHSEQR). |
143 | | > On exit, if SIDE = 'L' or 'B', VL contains: |
144 | | > if HOWMNY = 'A', the matrix Y of left eigenvectors of T; |
145 | | > if HOWMNY = 'B', the matrix Q*Y; |
146 | | > if HOWMNY = 'S', the left eigenvectors of T specified by |
147 | | > SELECT, stored consecutively in the columns |
148 | | > of VL, in the same order as their |
149 | | > eigenvalues. |
150 | | > A complex eigenvector corresponding to a complex eigenvalue |
151 | | > is stored in two consecutive columns, the first holding the |
152 | | > real part, and the second the imaginary part. |
153 | | > Not referenced if SIDE = 'R'. |
154 | | > \endverbatim |
155 | | > |
156 | | > \param[in] LDVL |
157 | | > \verbatim |
158 | | > LDVL is INTEGER |
159 | | > The leading dimension of the array VL. LDVL >= 1, and if |
160 | | > SIDE = 'L' or 'B', LDVL >= N. |
161 | | > \endverbatim |
162 | | > |
163 | | > \param[in,out] VR |
164 | | > \verbatim |
165 | | > VR is DOUBLE PRECISION array, dimension (LDVR,MM) |
166 | | > On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must |
167 | | > contain an N-by-N matrix Q (usually the orthogonal matrix Q |
168 | | > of Schur vectors returned by DHSEQR). |
169 | | > On exit, if SIDE = 'R' or 'B', VR contains: |
170 | | > if HOWMNY = 'A', the matrix X of right eigenvectors of T; |
171 | | > if HOWMNY = 'B', the matrix Q*X; |
172 | | > if HOWMNY = 'S', the right eigenvectors of T specified by |
173 | | > SELECT, stored consecutively in the columns |
174 | | > of VR, in the same order as their |
175 | | > eigenvalues. |
176 | | > A complex eigenvector corresponding to a complex eigenvalue |
177 | | > is stored in two consecutive columns, the first holding the |
178 | | > real part and the second the imaginary part. |
179 | | > Not referenced if SIDE = 'L'. |
180 | | > \endverbatim |
181 | | > |
182 | | > \param[in] LDVR |
183 | | > \verbatim |
184 | | > LDVR is INTEGER |
185 | | > The leading dimension of the array VR. LDVR >= 1, and if |
186 | | > SIDE = 'R' or 'B', LDVR >= N. |
187 | | > \endverbatim |
188 | | > |
189 | | > \param[in] MM |
190 | | > \verbatim |
191 | | > MM is INTEGER |
192 | | > The number of columns in the arrays VL and/or VR. MM >= M. |
193 | | > \endverbatim |
194 | | > |
195 | | > \param[out] M |
196 | | > \verbatim |
197 | | > M is INTEGER |
198 | | > The number of columns in the arrays VL and/or VR actually |
199 | | > used to store the eigenvectors. |
200 | | > If HOWMNY = 'A' or 'B', M is set to N. |
201 | | > Each selected real eigenvector occupies one column and each |
202 | | > selected complex eigenvector occupies two columns. |
203 | | > \endverbatim |
204 | | > |
205 | | > \param[out] WORK |
206 | | > \verbatim |
207 | | > WORK is DOUBLE PRECISION array, dimension (3*N) |
208 | | > \endverbatim |
209 | | > |
210 | | > \param[out] INFO |
211 | | > \verbatim |
212 | | > INFO is INTEGER |
213 | | > = 0: successful exit |
214 | | > < 0: if INFO = -i, the i-th argument had an illegal value |
215 | | > \endverbatim |
216 | | |
217 | | Authors: |
218 | | ======== |
219 | | |
220 | | > \author Univ. of Tennessee |
221 | | > \author Univ. of California Berkeley |
222 | | > \author Univ. of Colorado Denver |
223 | | > \author NAG Ltd. |
224 | | |
225 | | > \date November 2011 |
226 | | |
227 | | > \ingroup doubleOTHERcomputational |
228 | | |
229 | | > \par Further Details: |
230 | | ===================== |
231 | | > |
232 | | > \verbatim |
233 | | > |
234 | | > The algorithm used in this program is basically backward (forward) |
235 | | > substitution, with scaling to make the the code robust against |
236 | | > possible overflow. |
237 | | > |
238 | | > Each eigenvector is normalized so that the element of largest |
239 | | > magnitude has magnitude 1; here the magnitude of a complex number |
240 | | > (x,y) is taken to be |x| + |y|. |
241 | | > \endverbatim |
242 | | > |
243 | | ===================================================================== |
244 | | Subroutine */ int igraphdtrevc_(char *side, char *howmny, logical *select, |
245 | | integer *n, doublereal *t, integer *ldt, doublereal *vl, integer * |
246 | | ldvl, doublereal *vr, integer *ldvr, integer *mm, integer *m, |
247 | | doublereal *work, integer *info) |
248 | 0 | { |
249 | | /* System generated locals */ |
250 | 0 | integer t_dim1, t_offset, vl_dim1, vl_offset, vr_dim1, vr_offset, i__1, |
251 | 0 | i__2, i__3; |
252 | 0 | doublereal d__1, d__2, d__3, d__4; |
253 | | |
254 | | /* Builtin functions */ |
255 | 0 | double sqrt(doublereal); |
256 | | |
257 | | /* Local variables */ |
258 | 0 | integer i__, j, k; |
259 | 0 | doublereal x[4] /* was [2][2] */; |
260 | 0 | integer j1, j2, n2, ii, ki, ip, is; |
261 | 0 | doublereal wi, wr, rec, ulp, beta, emax; |
262 | 0 | logical pair; |
263 | 0 | extern doublereal igraphddot_(integer *, doublereal *, integer *, doublereal *, |
264 | 0 | integer *); |
265 | 0 | logical allv; |
266 | 0 | integer ierr; |
267 | 0 | doublereal unfl, ovfl, smin; |
268 | 0 | logical over; |
269 | 0 | doublereal vmax; |
270 | 0 | integer jnxt; |
271 | 0 | extern /* Subroutine */ int igraphdscal_(integer *, doublereal *, doublereal *, |
272 | 0 | integer *); |
273 | 0 | doublereal scale; |
274 | 0 | extern logical igraphlsame_(char *, char *); |
275 | 0 | extern /* Subroutine */ int igraphdgemv_(char *, integer *, integer *, |
276 | 0 | doublereal *, doublereal *, integer *, doublereal *, integer *, |
277 | 0 | doublereal *, doublereal *, integer *); |
278 | 0 | doublereal remax; |
279 | 0 | extern /* Subroutine */ int igraphdcopy_(integer *, doublereal *, integer *, |
280 | 0 | doublereal *, integer *); |
281 | 0 | logical leftv, bothv; |
282 | 0 | extern /* Subroutine */ int igraphdaxpy_(integer *, doublereal *, doublereal *, |
283 | 0 | integer *, doublereal *, integer *); |
284 | 0 | doublereal vcrit; |
285 | 0 | logical somev; |
286 | 0 | doublereal xnorm; |
287 | 0 | extern /* Subroutine */ int igraphdlaln2_(logical *, integer *, integer *, |
288 | 0 | doublereal *, doublereal *, doublereal *, integer *, doublereal *, |
289 | 0 | doublereal *, doublereal *, integer *, doublereal *, doublereal * |
290 | 0 | , doublereal *, integer *, doublereal *, doublereal *, integer *), |
291 | 0 | igraphdlabad_(doublereal *, doublereal *); |
292 | 0 | extern doublereal igraphdlamch_(char *); |
293 | 0 | extern integer igraphidamax_(integer *, doublereal *, integer *); |
294 | 0 | extern /* Subroutine */ int igraphxerbla_(char *, integer *, ftnlen); |
295 | 0 | doublereal bignum; |
296 | 0 | logical rightv; |
297 | 0 | doublereal smlnum; |
298 | | |
299 | | |
300 | | /* -- LAPACK computational routine (version 3.4.0) -- |
301 | | -- LAPACK is a software package provided by Univ. of Tennessee, -- |
302 | | -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
303 | | November 2011 |
304 | | |
305 | | |
306 | | ===================================================================== |
307 | | |
308 | | |
309 | | Decode and test the input parameters |
310 | | |
311 | | Parameter adjustments */ |
312 | 0 | --select; |
313 | 0 | t_dim1 = *ldt; |
314 | 0 | t_offset = 1 + t_dim1; |
315 | 0 | t -= t_offset; |
316 | 0 | vl_dim1 = *ldvl; |
317 | 0 | vl_offset = 1 + vl_dim1; |
318 | 0 | vl -= vl_offset; |
319 | 0 | vr_dim1 = *ldvr; |
320 | 0 | vr_offset = 1 + vr_dim1; |
321 | 0 | vr -= vr_offset; |
322 | 0 | --work; |
323 | | |
324 | | /* Function Body */ |
325 | 0 | bothv = igraphlsame_(side, "B"); |
326 | 0 | rightv = igraphlsame_(side, "R") || bothv; |
327 | 0 | leftv = igraphlsame_(side, "L") || bothv; |
328 | |
|
329 | 0 | allv = igraphlsame_(howmny, "A"); |
330 | 0 | over = igraphlsame_(howmny, "B"); |
331 | 0 | somev = igraphlsame_(howmny, "S"); |
332 | |
|
333 | 0 | *info = 0; |
334 | 0 | if (! rightv && ! leftv) { |
335 | 0 | *info = -1; |
336 | 0 | } else if (! allv && ! over && ! somev) { |
337 | 0 | *info = -2; |
338 | 0 | } else if (*n < 0) { |
339 | 0 | *info = -4; |
340 | 0 | } else if (*ldt < max(1,*n)) { |
341 | 0 | *info = -6; |
342 | 0 | } else if (*ldvl < 1 || leftv && *ldvl < *n) { |
343 | 0 | *info = -8; |
344 | 0 | } else if (*ldvr < 1 || rightv && *ldvr < *n) { |
345 | 0 | *info = -10; |
346 | 0 | } else { |
347 | | |
348 | | /* Set M to the number of columns required to store the selected |
349 | | eigenvectors, standardize the array SELECT if necessary, and |
350 | | test MM. */ |
351 | |
|
352 | 0 | if (somev) { |
353 | 0 | *m = 0; |
354 | 0 | pair = FALSE_; |
355 | 0 | i__1 = *n; |
356 | 0 | for (j = 1; j <= i__1; ++j) { |
357 | 0 | if (pair) { |
358 | 0 | pair = FALSE_; |
359 | 0 | select[j] = FALSE_; |
360 | 0 | } else { |
361 | 0 | if (j < *n) { |
362 | 0 | if (t[j + 1 + j * t_dim1] == 0.) { |
363 | 0 | if (select[j]) { |
364 | 0 | ++(*m); |
365 | 0 | } |
366 | 0 | } else { |
367 | 0 | pair = TRUE_; |
368 | 0 | if (select[j] || select[j + 1]) { |
369 | 0 | select[j] = TRUE_; |
370 | 0 | *m += 2; |
371 | 0 | } |
372 | 0 | } |
373 | 0 | } else { |
374 | 0 | if (select[*n]) { |
375 | 0 | ++(*m); |
376 | 0 | } |
377 | 0 | } |
378 | 0 | } |
379 | | /* L10: */ |
380 | 0 | } |
381 | 0 | } else { |
382 | 0 | *m = *n; |
383 | 0 | } |
384 | |
|
385 | 0 | if (*mm < *m) { |
386 | 0 | *info = -11; |
387 | 0 | } |
388 | 0 | } |
389 | 0 | if (*info != 0) { |
390 | 0 | i__1 = -(*info); |
391 | 0 | igraphxerbla_("DTREVC", &i__1, (ftnlen)6); |
392 | 0 | return 0; |
393 | 0 | } |
394 | | |
395 | | /* Quick return if possible. */ |
396 | | |
397 | 0 | if (*n == 0) { |
398 | 0 | return 0; |
399 | 0 | } |
400 | | |
401 | | /* Set the constants to control overflow. */ |
402 | | |
403 | 0 | unfl = igraphdlamch_("Safe minimum"); |
404 | 0 | ovfl = 1. / unfl; |
405 | 0 | igraphdlabad_(&unfl, &ovfl); |
406 | 0 | ulp = igraphdlamch_("Precision"); |
407 | 0 | smlnum = unfl * (*n / ulp); |
408 | 0 | bignum = (1. - ulp) / smlnum; |
409 | | |
410 | | /* Compute 1-norm of each column of strictly upper triangular |
411 | | part of T to control overflow in triangular solver. */ |
412 | |
|
413 | 0 | work[1] = 0.; |
414 | 0 | i__1 = *n; |
415 | 0 | for (j = 2; j <= i__1; ++j) { |
416 | 0 | work[j] = 0.; |
417 | 0 | i__2 = j - 1; |
418 | 0 | for (i__ = 1; i__ <= i__2; ++i__) { |
419 | 0 | work[j] += (d__1 = t[i__ + j * t_dim1], abs(d__1)); |
420 | | /* L20: */ |
421 | 0 | } |
422 | | /* L30: */ |
423 | 0 | } |
424 | | |
425 | | /* Index IP is used to specify the real or complex eigenvalue: |
426 | | IP = 0, real eigenvalue, |
427 | | 1, first of conjugate complex pair: (wr,wi) |
428 | | -1, second of conjugate complex pair: (wr,wi) */ |
429 | |
|
430 | 0 | n2 = *n << 1; |
431 | |
|
432 | 0 | if (rightv) { |
433 | | |
434 | | /* Compute right eigenvectors. */ |
435 | |
|
436 | 0 | ip = 0; |
437 | 0 | is = *m; |
438 | 0 | for (ki = *n; ki >= 1; --ki) { |
439 | |
|
440 | 0 | if (ip == 1) { |
441 | 0 | goto L130; |
442 | 0 | } |
443 | 0 | if (ki == 1) { |
444 | 0 | goto L40; |
445 | 0 | } |
446 | 0 | if (t[ki + (ki - 1) * t_dim1] == 0.) { |
447 | 0 | goto L40; |
448 | 0 | } |
449 | 0 | ip = -1; |
450 | |
|
451 | 0 | L40: |
452 | 0 | if (somev) { |
453 | 0 | if (ip == 0) { |
454 | 0 | if (! select[ki]) { |
455 | 0 | goto L130; |
456 | 0 | } |
457 | 0 | } else { |
458 | 0 | if (! select[ki - 1]) { |
459 | 0 | goto L130; |
460 | 0 | } |
461 | 0 | } |
462 | 0 | } |
463 | | |
464 | | /* Compute the KI-th eigenvalue (WR,WI). */ |
465 | | |
466 | 0 | wr = t[ki + ki * t_dim1]; |
467 | 0 | wi = 0.; |
468 | 0 | if (ip != 0) { |
469 | 0 | wi = sqrt((d__1 = t[ki + (ki - 1) * t_dim1], abs(d__1))) * |
470 | 0 | sqrt((d__2 = t[ki - 1 + ki * t_dim1], abs(d__2))); |
471 | 0 | } |
472 | | /* Computing MAX */ |
473 | 0 | d__1 = ulp * (abs(wr) + abs(wi)); |
474 | 0 | smin = max(d__1,smlnum); |
475 | |
|
476 | 0 | if (ip == 0) { |
477 | | |
478 | | /* Real right eigenvector */ |
479 | |
|
480 | 0 | work[ki + *n] = 1.; |
481 | | |
482 | | /* Form right-hand side */ |
483 | |
|
484 | 0 | i__1 = ki - 1; |
485 | 0 | for (k = 1; k <= i__1; ++k) { |
486 | 0 | work[k + *n] = -t[k + ki * t_dim1]; |
487 | | /* L50: */ |
488 | 0 | } |
489 | | |
490 | | /* Solve the upper quasi-triangular system: |
491 | | (T(1:KI-1,1:KI-1) - WR)*X = SCALE*WORK. */ |
492 | |
|
493 | 0 | jnxt = ki - 1; |
494 | 0 | for (j = ki - 1; j >= 1; --j) { |
495 | 0 | if (j > jnxt) { |
496 | 0 | goto L60; |
497 | 0 | } |
498 | 0 | j1 = j; |
499 | 0 | j2 = j; |
500 | 0 | jnxt = j - 1; |
501 | 0 | if (j > 1) { |
502 | 0 | if (t[j + (j - 1) * t_dim1] != 0.) { |
503 | 0 | j1 = j - 1; |
504 | 0 | jnxt = j - 2; |
505 | 0 | } |
506 | 0 | } |
507 | |
|
508 | 0 | if (j1 == j2) { |
509 | | |
510 | | /* 1-by-1 diagonal block */ |
511 | |
|
512 | 0 | igraphdlaln2_(&c_false, &c__1, &c__1, &smin, &c_b22, &t[j + |
513 | 0 | j * t_dim1], ldt, &c_b22, &c_b22, &work[j + * |
514 | 0 | n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm, |
515 | 0 | &ierr); |
516 | | |
517 | | /* Scale X(1,1) to avoid overflow when updating |
518 | | the right-hand side. */ |
519 | |
|
520 | 0 | if (xnorm > 1.) { |
521 | 0 | if (work[j] > bignum / xnorm) { |
522 | 0 | x[0] /= xnorm; |
523 | 0 | scale /= xnorm; |
524 | 0 | } |
525 | 0 | } |
526 | | |
527 | | /* Scale if necessary */ |
528 | |
|
529 | 0 | if (scale != 1.) { |
530 | 0 | igraphdscal_(&ki, &scale, &work[*n + 1], &c__1); |
531 | 0 | } |
532 | 0 | work[j + *n] = x[0]; |
533 | | |
534 | | /* Update right-hand side */ |
535 | |
|
536 | 0 | i__1 = j - 1; |
537 | 0 | d__1 = -x[0]; |
538 | 0 | igraphdaxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[ |
539 | 0 | *n + 1], &c__1); |
540 | |
|
541 | 0 | } else { |
542 | | |
543 | | /* 2-by-2 diagonal block */ |
544 | |
|
545 | 0 | igraphdlaln2_(&c_false, &c__2, &c__1, &smin, &c_b22, &t[j - |
546 | 0 | 1 + (j - 1) * t_dim1], ldt, &c_b22, &c_b22, & |
547 | 0 | work[j - 1 + *n], n, &wr, &c_b25, x, &c__2, & |
548 | 0 | scale, &xnorm, &ierr); |
549 | | |
550 | | /* Scale X(1,1) and X(2,1) to avoid overflow when |
551 | | updating the right-hand side. */ |
552 | |
|
553 | 0 | if (xnorm > 1.) { |
554 | | /* Computing MAX */ |
555 | 0 | d__1 = work[j - 1], d__2 = work[j]; |
556 | 0 | beta = max(d__1,d__2); |
557 | 0 | if (beta > bignum / xnorm) { |
558 | 0 | x[0] /= xnorm; |
559 | 0 | x[1] /= xnorm; |
560 | 0 | scale /= xnorm; |
561 | 0 | } |
562 | 0 | } |
563 | | |
564 | | /* Scale if necessary */ |
565 | |
|
566 | 0 | if (scale != 1.) { |
567 | 0 | igraphdscal_(&ki, &scale, &work[*n + 1], &c__1); |
568 | 0 | } |
569 | 0 | work[j - 1 + *n] = x[0]; |
570 | 0 | work[j + *n] = x[1]; |
571 | | |
572 | | /* Update right-hand side */ |
573 | |
|
574 | 0 | i__1 = j - 2; |
575 | 0 | d__1 = -x[0]; |
576 | 0 | igraphdaxpy_(&i__1, &d__1, &t[(j - 1) * t_dim1 + 1], &c__1, |
577 | 0 | &work[*n + 1], &c__1); |
578 | 0 | i__1 = j - 2; |
579 | 0 | d__1 = -x[1]; |
580 | 0 | igraphdaxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[ |
581 | 0 | *n + 1], &c__1); |
582 | 0 | } |
583 | 0 | L60: |
584 | 0 | ; |
585 | 0 | } |
586 | | |
587 | | /* Copy the vector x or Q*x to VR and normalize. */ |
588 | | |
589 | 0 | if (! over) { |
590 | 0 | igraphdcopy_(&ki, &work[*n + 1], &c__1, &vr[is * vr_dim1 + 1], & |
591 | 0 | c__1); |
592 | |
|
593 | 0 | ii = igraphidamax_(&ki, &vr[is * vr_dim1 + 1], &c__1); |
594 | 0 | remax = 1. / (d__1 = vr[ii + is * vr_dim1], abs(d__1)); |
595 | 0 | igraphdscal_(&ki, &remax, &vr[is * vr_dim1 + 1], &c__1); |
596 | |
|
597 | 0 | i__1 = *n; |
598 | 0 | for (k = ki + 1; k <= i__1; ++k) { |
599 | 0 | vr[k + is * vr_dim1] = 0.; |
600 | | /* L70: */ |
601 | 0 | } |
602 | 0 | } else { |
603 | 0 | if (ki > 1) { |
604 | 0 | i__1 = ki - 1; |
605 | 0 | igraphdgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, & |
606 | 0 | work[*n + 1], &c__1, &work[ki + *n], &vr[ki * |
607 | 0 | vr_dim1 + 1], &c__1); |
608 | 0 | } |
609 | |
|
610 | 0 | ii = igraphidamax_(n, &vr[ki * vr_dim1 + 1], &c__1); |
611 | 0 | remax = 1. / (d__1 = vr[ii + ki * vr_dim1], abs(d__1)); |
612 | 0 | igraphdscal_(n, &remax, &vr[ki * vr_dim1 + 1], &c__1); |
613 | 0 | } |
614 | |
|
615 | 0 | } else { |
616 | | |
617 | | /* Complex right eigenvector. |
618 | | |
619 | | Initial solve |
620 | | [ (T(KI-1,KI-1) T(KI-1,KI) ) - (WR + I* WI)]*X = 0. |
621 | | [ (T(KI,KI-1) T(KI,KI) ) ] */ |
622 | |
|
623 | 0 | if ((d__1 = t[ki - 1 + ki * t_dim1], abs(d__1)) >= (d__2 = t[ |
624 | 0 | ki + (ki - 1) * t_dim1], abs(d__2))) { |
625 | 0 | work[ki - 1 + *n] = 1.; |
626 | 0 | work[ki + n2] = wi / t[ki - 1 + ki * t_dim1]; |
627 | 0 | } else { |
628 | 0 | work[ki - 1 + *n] = -wi / t[ki + (ki - 1) * t_dim1]; |
629 | 0 | work[ki + n2] = 1.; |
630 | 0 | } |
631 | 0 | work[ki + *n] = 0.; |
632 | 0 | work[ki - 1 + n2] = 0.; |
633 | | |
634 | | /* Form right-hand side */ |
635 | |
|
636 | 0 | i__1 = ki - 2; |
637 | 0 | for (k = 1; k <= i__1; ++k) { |
638 | 0 | work[k + *n] = -work[ki - 1 + *n] * t[k + (ki - 1) * |
639 | 0 | t_dim1]; |
640 | 0 | work[k + n2] = -work[ki + n2] * t[k + ki * t_dim1]; |
641 | | /* L80: */ |
642 | 0 | } |
643 | | |
644 | | /* Solve upper quasi-triangular system: |
645 | | (T(1:KI-2,1:KI-2) - (WR+i*WI))*X = SCALE*(WORK+i*WORK2) */ |
646 | |
|
647 | 0 | jnxt = ki - 2; |
648 | 0 | for (j = ki - 2; j >= 1; --j) { |
649 | 0 | if (j > jnxt) { |
650 | 0 | goto L90; |
651 | 0 | } |
652 | 0 | j1 = j; |
653 | 0 | j2 = j; |
654 | 0 | jnxt = j - 1; |
655 | 0 | if (j > 1) { |
656 | 0 | if (t[j + (j - 1) * t_dim1] != 0.) { |
657 | 0 | j1 = j - 1; |
658 | 0 | jnxt = j - 2; |
659 | 0 | } |
660 | 0 | } |
661 | |
|
662 | 0 | if (j1 == j2) { |
663 | | |
664 | | /* 1-by-1 diagonal block */ |
665 | |
|
666 | 0 | igraphdlaln2_(&c_false, &c__1, &c__2, &smin, &c_b22, &t[j + |
667 | 0 | j * t_dim1], ldt, &c_b22, &c_b22, &work[j + * |
668 | 0 | n], n, &wr, &wi, x, &c__2, &scale, &xnorm, & |
669 | 0 | ierr); |
670 | | |
671 | | /* Scale X(1,1) and X(1,2) to avoid overflow when |
672 | | updating the right-hand side. */ |
673 | |
|
674 | 0 | if (xnorm > 1.) { |
675 | 0 | if (work[j] > bignum / xnorm) { |
676 | 0 | x[0] /= xnorm; |
677 | 0 | x[2] /= xnorm; |
678 | 0 | scale /= xnorm; |
679 | 0 | } |
680 | 0 | } |
681 | | |
682 | | /* Scale if necessary */ |
683 | |
|
684 | 0 | if (scale != 1.) { |
685 | 0 | igraphdscal_(&ki, &scale, &work[*n + 1], &c__1); |
686 | 0 | igraphdscal_(&ki, &scale, &work[n2 + 1], &c__1); |
687 | 0 | } |
688 | 0 | work[j + *n] = x[0]; |
689 | 0 | work[j + n2] = x[2]; |
690 | | |
691 | | /* Update the right-hand side */ |
692 | |
|
693 | 0 | i__1 = j - 1; |
694 | 0 | d__1 = -x[0]; |
695 | 0 | igraphdaxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[ |
696 | 0 | *n + 1], &c__1); |
697 | 0 | i__1 = j - 1; |
698 | 0 | d__1 = -x[2]; |
699 | 0 | igraphdaxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[ |
700 | 0 | n2 + 1], &c__1); |
701 | |
|
702 | 0 | } else { |
703 | | |
704 | | /* 2-by-2 diagonal block */ |
705 | |
|
706 | 0 | igraphdlaln2_(&c_false, &c__2, &c__2, &smin, &c_b22, &t[j - |
707 | 0 | 1 + (j - 1) * t_dim1], ldt, &c_b22, &c_b22, & |
708 | 0 | work[j - 1 + *n], n, &wr, &wi, x, &c__2, & |
709 | 0 | scale, &xnorm, &ierr); |
710 | | |
711 | | /* Scale X to avoid overflow when updating |
712 | | the right-hand side. */ |
713 | |
|
714 | 0 | if (xnorm > 1.) { |
715 | | /* Computing MAX */ |
716 | 0 | d__1 = work[j - 1], d__2 = work[j]; |
717 | 0 | beta = max(d__1,d__2); |
718 | 0 | if (beta > bignum / xnorm) { |
719 | 0 | rec = 1. / xnorm; |
720 | 0 | x[0] *= rec; |
721 | 0 | x[2] *= rec; |
722 | 0 | x[1] *= rec; |
723 | 0 | x[3] *= rec; |
724 | 0 | scale *= rec; |
725 | 0 | } |
726 | 0 | } |
727 | | |
728 | | /* Scale if necessary */ |
729 | |
|
730 | 0 | if (scale != 1.) { |
731 | 0 | igraphdscal_(&ki, &scale, &work[*n + 1], &c__1); |
732 | 0 | igraphdscal_(&ki, &scale, &work[n2 + 1], &c__1); |
733 | 0 | } |
734 | 0 | work[j - 1 + *n] = x[0]; |
735 | 0 | work[j + *n] = x[1]; |
736 | 0 | work[j - 1 + n2] = x[2]; |
737 | 0 | work[j + n2] = x[3]; |
738 | | |
739 | | /* Update the right-hand side */ |
740 | |
|
741 | 0 | i__1 = j - 2; |
742 | 0 | d__1 = -x[0]; |
743 | 0 | igraphdaxpy_(&i__1, &d__1, &t[(j - 1) * t_dim1 + 1], &c__1, |
744 | 0 | &work[*n + 1], &c__1); |
745 | 0 | i__1 = j - 2; |
746 | 0 | d__1 = -x[1]; |
747 | 0 | igraphdaxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[ |
748 | 0 | *n + 1], &c__1); |
749 | 0 | i__1 = j - 2; |
750 | 0 | d__1 = -x[2]; |
751 | 0 | igraphdaxpy_(&i__1, &d__1, &t[(j - 1) * t_dim1 + 1], &c__1, |
752 | 0 | &work[n2 + 1], &c__1); |
753 | 0 | i__1 = j - 2; |
754 | 0 | d__1 = -x[3]; |
755 | 0 | igraphdaxpy_(&i__1, &d__1, &t[j * t_dim1 + 1], &c__1, &work[ |
756 | 0 | n2 + 1], &c__1); |
757 | 0 | } |
758 | 0 | L90: |
759 | 0 | ; |
760 | 0 | } |
761 | | |
762 | | /* Copy the vector x or Q*x to VR and normalize. */ |
763 | | |
764 | 0 | if (! over) { |
765 | 0 | igraphdcopy_(&ki, &work[*n + 1], &c__1, &vr[(is - 1) * vr_dim1 |
766 | 0 | + 1], &c__1); |
767 | 0 | igraphdcopy_(&ki, &work[n2 + 1], &c__1, &vr[is * vr_dim1 + 1], & |
768 | 0 | c__1); |
769 | |
|
770 | 0 | emax = 0.; |
771 | 0 | i__1 = ki; |
772 | 0 | for (k = 1; k <= i__1; ++k) { |
773 | | /* Computing MAX */ |
774 | 0 | d__3 = emax, d__4 = (d__1 = vr[k + (is - 1) * vr_dim1] |
775 | 0 | , abs(d__1)) + (d__2 = vr[k + is * vr_dim1], |
776 | 0 | abs(d__2)); |
777 | 0 | emax = max(d__3,d__4); |
778 | | /* L100: */ |
779 | 0 | } |
780 | |
|
781 | 0 | remax = 1. / emax; |
782 | 0 | igraphdscal_(&ki, &remax, &vr[(is - 1) * vr_dim1 + 1], &c__1); |
783 | 0 | igraphdscal_(&ki, &remax, &vr[is * vr_dim1 + 1], &c__1); |
784 | |
|
785 | 0 | i__1 = *n; |
786 | 0 | for (k = ki + 1; k <= i__1; ++k) { |
787 | 0 | vr[k + (is - 1) * vr_dim1] = 0.; |
788 | 0 | vr[k + is * vr_dim1] = 0.; |
789 | | /* L110: */ |
790 | 0 | } |
791 | |
|
792 | 0 | } else { |
793 | |
|
794 | 0 | if (ki > 2) { |
795 | 0 | i__1 = ki - 2; |
796 | 0 | igraphdgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, & |
797 | 0 | work[*n + 1], &c__1, &work[ki - 1 + *n], &vr[( |
798 | 0 | ki - 1) * vr_dim1 + 1], &c__1); |
799 | 0 | i__1 = ki - 2; |
800 | 0 | igraphdgemv_("N", n, &i__1, &c_b22, &vr[vr_offset], ldvr, & |
801 | 0 | work[n2 + 1], &c__1, &work[ki + n2], &vr[ki * |
802 | 0 | vr_dim1 + 1], &c__1); |
803 | 0 | } else { |
804 | 0 | igraphdscal_(n, &work[ki - 1 + *n], &vr[(ki - 1) * vr_dim1 |
805 | 0 | + 1], &c__1); |
806 | 0 | igraphdscal_(n, &work[ki + n2], &vr[ki * vr_dim1 + 1], & |
807 | 0 | c__1); |
808 | 0 | } |
809 | |
|
810 | 0 | emax = 0.; |
811 | 0 | i__1 = *n; |
812 | 0 | for (k = 1; k <= i__1; ++k) { |
813 | | /* Computing MAX */ |
814 | 0 | d__3 = emax, d__4 = (d__1 = vr[k + (ki - 1) * vr_dim1] |
815 | 0 | , abs(d__1)) + (d__2 = vr[k + ki * vr_dim1], |
816 | 0 | abs(d__2)); |
817 | 0 | emax = max(d__3,d__4); |
818 | | /* L120: */ |
819 | 0 | } |
820 | 0 | remax = 1. / emax; |
821 | 0 | igraphdscal_(n, &remax, &vr[(ki - 1) * vr_dim1 + 1], &c__1); |
822 | 0 | igraphdscal_(n, &remax, &vr[ki * vr_dim1 + 1], &c__1); |
823 | 0 | } |
824 | 0 | } |
825 | | |
826 | 0 | --is; |
827 | 0 | if (ip != 0) { |
828 | 0 | --is; |
829 | 0 | } |
830 | 0 | L130: |
831 | 0 | if (ip == 1) { |
832 | 0 | ip = 0; |
833 | 0 | } |
834 | 0 | if (ip == -1) { |
835 | 0 | ip = 1; |
836 | 0 | } |
837 | | /* L140: */ |
838 | 0 | } |
839 | 0 | } |
840 | | |
841 | 0 | if (leftv) { |
842 | | |
843 | | /* Compute left eigenvectors. */ |
844 | |
|
845 | 0 | ip = 0; |
846 | 0 | is = 1; |
847 | 0 | i__1 = *n; |
848 | 0 | for (ki = 1; ki <= i__1; ++ki) { |
849 | |
|
850 | 0 | if (ip == -1) { |
851 | 0 | goto L250; |
852 | 0 | } |
853 | 0 | if (ki == *n) { |
854 | 0 | goto L150; |
855 | 0 | } |
856 | 0 | if (t[ki + 1 + ki * t_dim1] == 0.) { |
857 | 0 | goto L150; |
858 | 0 | } |
859 | 0 | ip = 1; |
860 | |
|
861 | 0 | L150: |
862 | 0 | if (somev) { |
863 | 0 | if (! select[ki]) { |
864 | 0 | goto L250; |
865 | 0 | } |
866 | 0 | } |
867 | | |
868 | | /* Compute the KI-th eigenvalue (WR,WI). */ |
869 | | |
870 | 0 | wr = t[ki + ki * t_dim1]; |
871 | 0 | wi = 0.; |
872 | 0 | if (ip != 0) { |
873 | 0 | wi = sqrt((d__1 = t[ki + (ki + 1) * t_dim1], abs(d__1))) * |
874 | 0 | sqrt((d__2 = t[ki + 1 + ki * t_dim1], abs(d__2))); |
875 | 0 | } |
876 | | /* Computing MAX */ |
877 | 0 | d__1 = ulp * (abs(wr) + abs(wi)); |
878 | 0 | smin = max(d__1,smlnum); |
879 | |
|
880 | 0 | if (ip == 0) { |
881 | | |
882 | | /* Real left eigenvector. */ |
883 | |
|
884 | 0 | work[ki + *n] = 1.; |
885 | | |
886 | | /* Form right-hand side */ |
887 | |
|
888 | 0 | i__2 = *n; |
889 | 0 | for (k = ki + 1; k <= i__2; ++k) { |
890 | 0 | work[k + *n] = -t[ki + k * t_dim1]; |
891 | | /* L160: */ |
892 | 0 | } |
893 | | |
894 | | /* Solve the quasi-triangular system: |
895 | | (T(KI+1:N,KI+1:N) - WR)**T*X = SCALE*WORK */ |
896 | |
|
897 | 0 | vmax = 1.; |
898 | 0 | vcrit = bignum; |
899 | |
|
900 | 0 | jnxt = ki + 1; |
901 | 0 | i__2 = *n; |
902 | 0 | for (j = ki + 1; j <= i__2; ++j) { |
903 | 0 | if (j < jnxt) { |
904 | 0 | goto L170; |
905 | 0 | } |
906 | 0 | j1 = j; |
907 | 0 | j2 = j; |
908 | 0 | jnxt = j + 1; |
909 | 0 | if (j < *n) { |
910 | 0 | if (t[j + 1 + j * t_dim1] != 0.) { |
911 | 0 | j2 = j + 1; |
912 | 0 | jnxt = j + 2; |
913 | 0 | } |
914 | 0 | } |
915 | |
|
916 | 0 | if (j1 == j2) { |
917 | | |
918 | | /* 1-by-1 diagonal block |
919 | | |
920 | | Scale if necessary to avoid overflow when forming |
921 | | the right-hand side. */ |
922 | |
|
923 | 0 | if (work[j] > vcrit) { |
924 | 0 | rec = 1. / vmax; |
925 | 0 | i__3 = *n - ki + 1; |
926 | 0 | igraphdscal_(&i__3, &rec, &work[ki + *n], &c__1); |
927 | 0 | vmax = 1.; |
928 | 0 | vcrit = bignum; |
929 | 0 | } |
930 | |
|
931 | 0 | i__3 = j - ki - 1; |
932 | 0 | work[j + *n] -= igraphddot_(&i__3, &t[ki + 1 + j * t_dim1], |
933 | 0 | &c__1, &work[ki + 1 + *n], &c__1); |
934 | | |
935 | | /* Solve (T(J,J)-WR)**T*X = WORK */ |
936 | |
|
937 | 0 | igraphdlaln2_(&c_false, &c__1, &c__1, &smin, &c_b22, &t[j + |
938 | 0 | j * t_dim1], ldt, &c_b22, &c_b22, &work[j + * |
939 | 0 | n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm, |
940 | 0 | &ierr); |
941 | | |
942 | | /* Scale if necessary */ |
943 | |
|
944 | 0 | if (scale != 1.) { |
945 | 0 | i__3 = *n - ki + 1; |
946 | 0 | igraphdscal_(&i__3, &scale, &work[ki + *n], &c__1); |
947 | 0 | } |
948 | 0 | work[j + *n] = x[0]; |
949 | | /* Computing MAX */ |
950 | 0 | d__2 = (d__1 = work[j + *n], abs(d__1)); |
951 | 0 | vmax = max(d__2,vmax); |
952 | 0 | vcrit = bignum / vmax; |
953 | |
|
954 | 0 | } else { |
955 | | |
956 | | /* 2-by-2 diagonal block |
957 | | |
958 | | Scale if necessary to avoid overflow when forming |
959 | | the right-hand side. |
960 | | |
961 | | Computing MAX */ |
962 | 0 | d__1 = work[j], d__2 = work[j + 1]; |
963 | 0 | beta = max(d__1,d__2); |
964 | 0 | if (beta > vcrit) { |
965 | 0 | rec = 1. / vmax; |
966 | 0 | i__3 = *n - ki + 1; |
967 | 0 | igraphdscal_(&i__3, &rec, &work[ki + *n], &c__1); |
968 | 0 | vmax = 1.; |
969 | 0 | vcrit = bignum; |
970 | 0 | } |
971 | |
|
972 | 0 | i__3 = j - ki - 1; |
973 | 0 | work[j + *n] -= igraphddot_(&i__3, &t[ki + 1 + j * t_dim1], |
974 | 0 | &c__1, &work[ki + 1 + *n], &c__1); |
975 | |
|
976 | 0 | i__3 = j - ki - 1; |
977 | 0 | work[j + 1 + *n] -= igraphddot_(&i__3, &t[ki + 1 + (j + 1) * |
978 | 0 | t_dim1], &c__1, &work[ki + 1 + *n], &c__1); |
979 | | |
980 | | /* Solve |
981 | | [T(J,J)-WR T(J,J+1) ]**T * X = SCALE*( WORK1 ) |
982 | | [T(J+1,J) T(J+1,J+1)-WR] ( WORK2 ) */ |
983 | |
|
984 | 0 | igraphdlaln2_(&c_true, &c__2, &c__1, &smin, &c_b22, &t[j + |
985 | 0 | j * t_dim1], ldt, &c_b22, &c_b22, &work[j + * |
986 | 0 | n], n, &wr, &c_b25, x, &c__2, &scale, &xnorm, |
987 | 0 | &ierr); |
988 | | |
989 | | /* Scale if necessary */ |
990 | |
|
991 | 0 | if (scale != 1.) { |
992 | 0 | i__3 = *n - ki + 1; |
993 | 0 | igraphdscal_(&i__3, &scale, &work[ki + *n], &c__1); |
994 | 0 | } |
995 | 0 | work[j + *n] = x[0]; |
996 | 0 | work[j + 1 + *n] = x[1]; |
997 | | |
998 | | /* Computing MAX */ |
999 | 0 | d__3 = (d__1 = work[j + *n], abs(d__1)), d__4 = (d__2 |
1000 | 0 | = work[j + 1 + *n], abs(d__2)), d__3 = max( |
1001 | 0 | d__3,d__4); |
1002 | 0 | vmax = max(d__3,vmax); |
1003 | 0 | vcrit = bignum / vmax; |
1004 | |
|
1005 | 0 | } |
1006 | 0 | L170: |
1007 | 0 | ; |
1008 | 0 | } |
1009 | | |
1010 | | /* Copy the vector x or Q*x to VL and normalize. */ |
1011 | | |
1012 | 0 | if (! over) { |
1013 | 0 | i__2 = *n - ki + 1; |
1014 | 0 | igraphdcopy_(&i__2, &work[ki + *n], &c__1, &vl[ki + is * |
1015 | 0 | vl_dim1], &c__1); |
1016 | |
|
1017 | 0 | i__2 = *n - ki + 1; |
1018 | 0 | ii = igraphidamax_(&i__2, &vl[ki + is * vl_dim1], &c__1) + ki - |
1019 | 0 | 1; |
1020 | 0 | remax = 1. / (d__1 = vl[ii + is * vl_dim1], abs(d__1)); |
1021 | 0 | i__2 = *n - ki + 1; |
1022 | 0 | igraphdscal_(&i__2, &remax, &vl[ki + is * vl_dim1], &c__1); |
1023 | |
|
1024 | 0 | i__2 = ki - 1; |
1025 | 0 | for (k = 1; k <= i__2; ++k) { |
1026 | 0 | vl[k + is * vl_dim1] = 0.; |
1027 | | /* L180: */ |
1028 | 0 | } |
1029 | |
|
1030 | 0 | } else { |
1031 | |
|
1032 | 0 | if (ki < *n) { |
1033 | 0 | i__2 = *n - ki; |
1034 | 0 | igraphdgemv_("N", n, &i__2, &c_b22, &vl[(ki + 1) * vl_dim1 |
1035 | 0 | + 1], ldvl, &work[ki + 1 + *n], &c__1, &work[ |
1036 | 0 | ki + *n], &vl[ki * vl_dim1 + 1], &c__1); |
1037 | 0 | } |
1038 | |
|
1039 | 0 | ii = igraphidamax_(n, &vl[ki * vl_dim1 + 1], &c__1); |
1040 | 0 | remax = 1. / (d__1 = vl[ii + ki * vl_dim1], abs(d__1)); |
1041 | 0 | igraphdscal_(n, &remax, &vl[ki * vl_dim1 + 1], &c__1); |
1042 | |
|
1043 | 0 | } |
1044 | |
|
1045 | 0 | } else { |
1046 | | |
1047 | | /* Complex left eigenvector. |
1048 | | |
1049 | | Initial solve: |
1050 | | ((T(KI,KI) T(KI,KI+1) )**T - (WR - I* WI))*X = 0. |
1051 | | ((T(KI+1,KI) T(KI+1,KI+1)) ) */ |
1052 | |
|
1053 | 0 | if ((d__1 = t[ki + (ki + 1) * t_dim1], abs(d__1)) >= (d__2 = |
1054 | 0 | t[ki + 1 + ki * t_dim1], abs(d__2))) { |
1055 | 0 | work[ki + *n] = wi / t[ki + (ki + 1) * t_dim1]; |
1056 | 0 | work[ki + 1 + n2] = 1.; |
1057 | 0 | } else { |
1058 | 0 | work[ki + *n] = 1.; |
1059 | 0 | work[ki + 1 + n2] = -wi / t[ki + 1 + ki * t_dim1]; |
1060 | 0 | } |
1061 | 0 | work[ki + 1 + *n] = 0.; |
1062 | 0 | work[ki + n2] = 0.; |
1063 | | |
1064 | | /* Form right-hand side */ |
1065 | |
|
1066 | 0 | i__2 = *n; |
1067 | 0 | for (k = ki + 2; k <= i__2; ++k) { |
1068 | 0 | work[k + *n] = -work[ki + *n] * t[ki + k * t_dim1]; |
1069 | 0 | work[k + n2] = -work[ki + 1 + n2] * t[ki + 1 + k * t_dim1] |
1070 | 0 | ; |
1071 | | /* L190: */ |
1072 | 0 | } |
1073 | | |
1074 | | /* Solve complex quasi-triangular system: |
1075 | | ( T(KI+2,N:KI+2,N) - (WR-i*WI) )*X = WORK1+i*WORK2 */ |
1076 | |
|
1077 | 0 | vmax = 1.; |
1078 | 0 | vcrit = bignum; |
1079 | |
|
1080 | 0 | jnxt = ki + 2; |
1081 | 0 | i__2 = *n; |
1082 | 0 | for (j = ki + 2; j <= i__2; ++j) { |
1083 | 0 | if (j < jnxt) { |
1084 | 0 | goto L200; |
1085 | 0 | } |
1086 | 0 | j1 = j; |
1087 | 0 | j2 = j; |
1088 | 0 | jnxt = j + 1; |
1089 | 0 | if (j < *n) { |
1090 | 0 | if (t[j + 1 + j * t_dim1] != 0.) { |
1091 | 0 | j2 = j + 1; |
1092 | 0 | jnxt = j + 2; |
1093 | 0 | } |
1094 | 0 | } |
1095 | |
|
1096 | 0 | if (j1 == j2) { |
1097 | | |
1098 | | /* 1-by-1 diagonal block |
1099 | | |
1100 | | Scale if necessary to avoid overflow when |
1101 | | forming the right-hand side elements. */ |
1102 | |
|
1103 | 0 | if (work[j] > vcrit) { |
1104 | 0 | rec = 1. / vmax; |
1105 | 0 | i__3 = *n - ki + 1; |
1106 | 0 | igraphdscal_(&i__3, &rec, &work[ki + *n], &c__1); |
1107 | 0 | i__3 = *n - ki + 1; |
1108 | 0 | igraphdscal_(&i__3, &rec, &work[ki + n2], &c__1); |
1109 | 0 | vmax = 1.; |
1110 | 0 | vcrit = bignum; |
1111 | 0 | } |
1112 | |
|
1113 | 0 | i__3 = j - ki - 2; |
1114 | 0 | work[j + *n] -= igraphddot_(&i__3, &t[ki + 2 + j * t_dim1], |
1115 | 0 | &c__1, &work[ki + 2 + *n], &c__1); |
1116 | 0 | i__3 = j - ki - 2; |
1117 | 0 | work[j + n2] -= igraphddot_(&i__3, &t[ki + 2 + j * t_dim1], |
1118 | 0 | &c__1, &work[ki + 2 + n2], &c__1); |
1119 | | |
1120 | | /* Solve (T(J,J)-(WR-i*WI))*(X11+i*X12)= WK+I*WK2 */ |
1121 | |
|
1122 | 0 | d__1 = -wi; |
1123 | 0 | igraphdlaln2_(&c_false, &c__1, &c__2, &smin, &c_b22, &t[j + |
1124 | 0 | j * t_dim1], ldt, &c_b22, &c_b22, &work[j + * |
1125 | 0 | n], n, &wr, &d__1, x, &c__2, &scale, &xnorm, & |
1126 | 0 | ierr); |
1127 | | |
1128 | | /* Scale if necessary */ |
1129 | |
|
1130 | 0 | if (scale != 1.) { |
1131 | 0 | i__3 = *n - ki + 1; |
1132 | 0 | igraphdscal_(&i__3, &scale, &work[ki + *n], &c__1); |
1133 | 0 | i__3 = *n - ki + 1; |
1134 | 0 | igraphdscal_(&i__3, &scale, &work[ki + n2], &c__1); |
1135 | 0 | } |
1136 | 0 | work[j + *n] = x[0]; |
1137 | 0 | work[j + n2] = x[2]; |
1138 | | /* Computing MAX */ |
1139 | 0 | d__3 = (d__1 = work[j + *n], abs(d__1)), d__4 = (d__2 |
1140 | 0 | = work[j + n2], abs(d__2)), d__3 = max(d__3, |
1141 | 0 | d__4); |
1142 | 0 | vmax = max(d__3,vmax); |
1143 | 0 | vcrit = bignum / vmax; |
1144 | |
|
1145 | 0 | } else { |
1146 | | |
1147 | | /* 2-by-2 diagonal block |
1148 | | |
1149 | | Scale if necessary to avoid overflow when forming |
1150 | | the right-hand side elements. |
1151 | | |
1152 | | Computing MAX */ |
1153 | 0 | d__1 = work[j], d__2 = work[j + 1]; |
1154 | 0 | beta = max(d__1,d__2); |
1155 | 0 | if (beta > vcrit) { |
1156 | 0 | rec = 1. / vmax; |
1157 | 0 | i__3 = *n - ki + 1; |
1158 | 0 | igraphdscal_(&i__3, &rec, &work[ki + *n], &c__1); |
1159 | 0 | i__3 = *n - ki + 1; |
1160 | 0 | igraphdscal_(&i__3, &rec, &work[ki + n2], &c__1); |
1161 | 0 | vmax = 1.; |
1162 | 0 | vcrit = bignum; |
1163 | 0 | } |
1164 | |
|
1165 | 0 | i__3 = j - ki - 2; |
1166 | 0 | work[j + *n] -= igraphddot_(&i__3, &t[ki + 2 + j * t_dim1], |
1167 | 0 | &c__1, &work[ki + 2 + *n], &c__1); |
1168 | |
|
1169 | 0 | i__3 = j - ki - 2; |
1170 | 0 | work[j + n2] -= igraphddot_(&i__3, &t[ki + 2 + j * t_dim1], |
1171 | 0 | &c__1, &work[ki + 2 + n2], &c__1); |
1172 | |
|
1173 | 0 | i__3 = j - ki - 2; |
1174 | 0 | work[j + 1 + *n] -= igraphddot_(&i__3, &t[ki + 2 + (j + 1) * |
1175 | 0 | t_dim1], &c__1, &work[ki + 2 + *n], &c__1); |
1176 | |
|
1177 | 0 | i__3 = j - ki - 2; |
1178 | 0 | work[j + 1 + n2] -= igraphddot_(&i__3, &t[ki + 2 + (j + 1) * |
1179 | 0 | t_dim1], &c__1, &work[ki + 2 + n2], &c__1); |
1180 | | |
1181 | | /* Solve 2-by-2 complex linear equation |
1182 | | ([T(j,j) T(j,j+1) ]**T-(wr-i*wi)*I)*X = SCALE*B |
1183 | | ([T(j+1,j) T(j+1,j+1)] ) */ |
1184 | |
|
1185 | 0 | d__1 = -wi; |
1186 | 0 | igraphdlaln2_(&c_true, &c__2, &c__2, &smin, &c_b22, &t[j + |
1187 | 0 | j * t_dim1], ldt, &c_b22, &c_b22, &work[j + * |
1188 | 0 | n], n, &wr, &d__1, x, &c__2, &scale, &xnorm, & |
1189 | 0 | ierr); |
1190 | | |
1191 | | /* Scale if necessary */ |
1192 | |
|
1193 | 0 | if (scale != 1.) { |
1194 | 0 | i__3 = *n - ki + 1; |
1195 | 0 | igraphdscal_(&i__3, &scale, &work[ki + *n], &c__1); |
1196 | 0 | i__3 = *n - ki + 1; |
1197 | 0 | igraphdscal_(&i__3, &scale, &work[ki + n2], &c__1); |
1198 | 0 | } |
1199 | 0 | work[j + *n] = x[0]; |
1200 | 0 | work[j + n2] = x[2]; |
1201 | 0 | work[j + 1 + *n] = x[1]; |
1202 | 0 | work[j + 1 + n2] = x[3]; |
1203 | | /* Computing MAX */ |
1204 | 0 | d__1 = abs(x[0]), d__2 = abs(x[2]), d__1 = max(d__1, |
1205 | 0 | d__2), d__2 = abs(x[1]), d__1 = max(d__1,d__2) |
1206 | 0 | , d__2 = abs(x[3]), d__1 = max(d__1,d__2); |
1207 | 0 | vmax = max(d__1,vmax); |
1208 | 0 | vcrit = bignum / vmax; |
1209 | |
|
1210 | 0 | } |
1211 | 0 | L200: |
1212 | 0 | ; |
1213 | 0 | } |
1214 | | |
1215 | | /* Copy the vector x or Q*x to VL and normalize. */ |
1216 | | |
1217 | 0 | if (! over) { |
1218 | 0 | i__2 = *n - ki + 1; |
1219 | 0 | igraphdcopy_(&i__2, &work[ki + *n], &c__1, &vl[ki + is * |
1220 | 0 | vl_dim1], &c__1); |
1221 | 0 | i__2 = *n - ki + 1; |
1222 | 0 | igraphdcopy_(&i__2, &work[ki + n2], &c__1, &vl[ki + (is + 1) * |
1223 | 0 | vl_dim1], &c__1); |
1224 | |
|
1225 | 0 | emax = 0.; |
1226 | 0 | i__2 = *n; |
1227 | 0 | for (k = ki; k <= i__2; ++k) { |
1228 | | /* Computing MAX */ |
1229 | 0 | d__3 = emax, d__4 = (d__1 = vl[k + is * vl_dim1], abs( |
1230 | 0 | d__1)) + (d__2 = vl[k + (is + 1) * vl_dim1], |
1231 | 0 | abs(d__2)); |
1232 | 0 | emax = max(d__3,d__4); |
1233 | | /* L220: */ |
1234 | 0 | } |
1235 | 0 | remax = 1. / emax; |
1236 | 0 | i__2 = *n - ki + 1; |
1237 | 0 | igraphdscal_(&i__2, &remax, &vl[ki + is * vl_dim1], &c__1); |
1238 | 0 | i__2 = *n - ki + 1; |
1239 | 0 | igraphdscal_(&i__2, &remax, &vl[ki + (is + 1) * vl_dim1], &c__1) |
1240 | 0 | ; |
1241 | |
|
1242 | 0 | i__2 = ki - 1; |
1243 | 0 | for (k = 1; k <= i__2; ++k) { |
1244 | 0 | vl[k + is * vl_dim1] = 0.; |
1245 | 0 | vl[k + (is + 1) * vl_dim1] = 0.; |
1246 | | /* L230: */ |
1247 | 0 | } |
1248 | 0 | } else { |
1249 | 0 | if (ki < *n - 1) { |
1250 | 0 | i__2 = *n - ki - 1; |
1251 | 0 | igraphdgemv_("N", n, &i__2, &c_b22, &vl[(ki + 2) * vl_dim1 |
1252 | 0 | + 1], ldvl, &work[ki + 2 + *n], &c__1, &work[ |
1253 | 0 | ki + *n], &vl[ki * vl_dim1 + 1], &c__1); |
1254 | 0 | i__2 = *n - ki - 1; |
1255 | 0 | igraphdgemv_("N", n, &i__2, &c_b22, &vl[(ki + 2) * vl_dim1 |
1256 | 0 | + 1], ldvl, &work[ki + 2 + n2], &c__1, &work[ |
1257 | 0 | ki + 1 + n2], &vl[(ki + 1) * vl_dim1 + 1], & |
1258 | 0 | c__1); |
1259 | 0 | } else { |
1260 | 0 | igraphdscal_(n, &work[ki + *n], &vl[ki * vl_dim1 + 1], & |
1261 | 0 | c__1); |
1262 | 0 | igraphdscal_(n, &work[ki + 1 + n2], &vl[(ki + 1) * vl_dim1 |
1263 | 0 | + 1], &c__1); |
1264 | 0 | } |
1265 | |
|
1266 | 0 | emax = 0.; |
1267 | 0 | i__2 = *n; |
1268 | 0 | for (k = 1; k <= i__2; ++k) { |
1269 | | /* Computing MAX */ |
1270 | 0 | d__3 = emax, d__4 = (d__1 = vl[k + ki * vl_dim1], abs( |
1271 | 0 | d__1)) + (d__2 = vl[k + (ki + 1) * vl_dim1], |
1272 | 0 | abs(d__2)); |
1273 | 0 | emax = max(d__3,d__4); |
1274 | | /* L240: */ |
1275 | 0 | } |
1276 | 0 | remax = 1. / emax; |
1277 | 0 | igraphdscal_(n, &remax, &vl[ki * vl_dim1 + 1], &c__1); |
1278 | 0 | igraphdscal_(n, &remax, &vl[(ki + 1) * vl_dim1 + 1], &c__1); |
1279 | |
|
1280 | 0 | } |
1281 | |
|
1282 | 0 | } |
1283 | | |
1284 | 0 | ++is; |
1285 | 0 | if (ip != 0) { |
1286 | 0 | ++is; |
1287 | 0 | } |
1288 | 0 | L250: |
1289 | 0 | if (ip == -1) { |
1290 | 0 | ip = 0; |
1291 | 0 | } |
1292 | 0 | if (ip == 1) { |
1293 | 0 | ip = -1; |
1294 | 0 | } |
1295 | | |
1296 | | /* L260: */ |
1297 | 0 | } |
1298 | |
|
1299 | 0 | } |
1300 | | |
1301 | 0 | return 0; |
1302 | | |
1303 | | /* End of DTREVC */ |
1304 | |
|
1305 | 0 | } /* igraphdtrevc_ */ |
1306 | | |