14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
22 typedef BLASLONG blasint;
24 #define blasabs(x) llabs(x)
26 #define blasabs(x) labs(x)
30 #define blasabs(x) abs(x)
33 typedef blasint integer;
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
63 /* Extern is for use with -E */
74 /*external read, write*/
83 /*internal read, write*/
113 /*rewind, backspace, endfile*/
125 ftnint *inex; /*parameters in standard's order*/
151 union Multitype { /* for multiple entry points */
162 typedef union Multitype Multitype;
164 struct Vardesc { /* for Namelist */
170 typedef struct Vardesc Vardesc;
177 typedef struct Namelist Namelist;
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b) ((a) >> (b) & 1)
186 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);}
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle_() continue;
256 #define myceiling_(w) {ceil(w)}
257 #define myhuge_(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc_(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
261 /* procedure parameter types for -A and -C++ */
263 #define F2C_proc_par_types 1
265 typedef logical (*L_fp)(...);
267 typedef logical (*L_fp)();
270 static float spow_ui(float x, integer n) {
271 float pow=1.0; unsigned long int u;
273 if(n < 0) n = -n, x = 1/x;
282 static double dpow_ui(double x, integer n) {
283 double pow=1.0; unsigned long int u;
285 if(n < 0) n = -n, x = 1/x;
295 static _Fcomplex cpow_ui(complex x, integer n) {
296 complex pow={1.0,0.0}; unsigned long int u;
298 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
300 if(u & 01) pow.r *= x.r, pow.i *= x.i;
301 if(u >>= 1) x.r *= x.r, x.i *= x.i;
305 _Fcomplex p={pow.r, pow.i};
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310 _Complex float pow=1.0; unsigned long int u;
312 if(n < 0) n = -n, x = 1/x;
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324 _Dcomplex pow={1.0,0.0}; unsigned long int u;
326 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
328 if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329 if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
333 _Dcomplex p = {pow._Val[0], pow._Val[1]};
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338 _Complex double pow=1.0; unsigned long int u;
340 if(n < 0) n = -n, x = 1/x;
350 static integer pow_ii(integer x, integer n) {
351 integer pow; unsigned long int u;
353 if (n == 0 || x == 1) pow = 1;
354 else if (x != -1) pow = x == 0 ? 1/x : 0;
357 if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
369 double m; integer i, mi;
370 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371 if (w[i-1]>m) mi=i ,m=w[i-1];
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
376 float m; integer i, mi;
377 for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378 if (w[i-1]>m) mi=i ,m=w[i-1];
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382 integer n = *n_, incx = *incx_, incy = *incy_, i;
384 _Fcomplex zdotc = {0.0, 0.0};
385 if (incx == 1 && incy == 1) {
386 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387 zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388 zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
391 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392 zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393 zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
399 _Complex float zdotc = 0.0;
400 if (incx == 1 && incy == 1) {
401 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402 zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
405 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406 zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413 integer n = *n_, incx = *incx_, incy = *incy_, i;
415 _Dcomplex zdotc = {0.0, 0.0};
416 if (incx == 1 && incy == 1) {
417 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418 zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419 zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
422 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423 zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424 zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
430 _Complex double zdotc = 0.0;
431 if (incx == 1 && incy == 1) {
432 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433 zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
436 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437 zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444 integer n = *n_, incx = *incx_, incy = *incy_, i;
446 _Fcomplex zdotc = {0.0, 0.0};
447 if (incx == 1 && incy == 1) {
448 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449 zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450 zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
453 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454 zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455 zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
461 _Complex float zdotc = 0.0;
462 if (incx == 1 && incy == 1) {
463 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464 zdotc += Cf(&x[i]) * Cf(&y[i]);
467 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468 zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475 integer n = *n_, incx = *incx_, incy = *incy_, i;
477 _Dcomplex zdotc = {0.0, 0.0};
478 if (incx == 1 && incy == 1) {
479 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480 zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481 zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
484 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485 zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486 zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
492 _Complex double zdotc = 0.0;
493 if (incx == 1 && incy == 1) {
494 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495 zdotc += Cd(&x[i]) * Cd(&y[i]);
498 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499 zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
505 /* -- translated by f2c (version 20000121).
506 You must link the resulting object file with the libraries:
507 -lf2c -lm (in that order)
514 /* Table of constant values */
516 static doublereal c_b7 = 0.;
517 static doublereal c_b8 = 1.;
518 static integer c__2 = 2;
519 static integer c__1 = 1;
520 static integer c__3 = 3;
522 /* > \brief \b DLAQR5 performs a single small-bulge multi-shift QR sweep. */
524 /* =========== DOCUMENTATION =========== */
526 /* Online html documentation available at */
527 /* http://www.netlib.org/lapack/explore-html/ */
530 /* > Download DLAQR5 + dependencies */
531 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaqr5.
534 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaqr5.
537 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaqr5.
545 /* SUBROUTINE DLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS, */
546 /* SR, SI, H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U, */
547 /* LDU, NV, WV, LDWV, NH, WH, LDWH ) */
549 /* INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV, */
550 /* $ LDWH, LDWV, LDZ, N, NH, NSHFTS, NV */
551 /* LOGICAL WANTT, WANTZ */
552 /* DOUBLE PRECISION H( LDH, * ), SI( * ), SR( * ), U( LDU, * ), */
553 /* $ V( LDV, * ), WH( LDWH, * ), WV( LDWV, * ), */
557 /* > \par Purpose: */
562 /* > DLAQR5, called by DLAQR0, performs a */
563 /* > single small-bulge multi-shift QR sweep. */
569 /* > \param[in] WANTT */
571 /* > WANTT is LOGICAL */
572 /* > WANTT = .true. if the quasi-triangular Schur factor */
573 /* > is being computed. WANTT is set to .false. otherwise. */
576 /* > \param[in] WANTZ */
578 /* > WANTZ is LOGICAL */
579 /* > WANTZ = .true. if the orthogonal Schur factor is being */
580 /* > computed. WANTZ is set to .false. otherwise. */
583 /* > \param[in] KACC22 */
585 /* > KACC22 is INTEGER with value 0, 1, or 2. */
586 /* > Specifies the computation mode of far-from-diagonal */
587 /* > orthogonal updates. */
588 /* > = 0: DLAQR5 does not accumulate reflections and does not */
589 /* > use matrix-matrix multiply to update far-from-diagonal */
590 /* > matrix entries. */
591 /* > = 1: DLAQR5 accumulates reflections and uses matrix-matrix */
592 /* > multiply to update the far-from-diagonal matrix entries. */
593 /* > = 2: Same as KACC22 = 1. This option used to enable exploiting */
594 /* > the 2-by-2 structure during matrix multiplications, but */
595 /* > this is no longer supported. */
601 /* > N is the order of the Hessenberg matrix H upon which this */
602 /* > subroutine operates. */
605 /* > \param[in] KTOP */
607 /* > KTOP is INTEGER */
610 /* > \param[in] KBOT */
612 /* > KBOT is INTEGER */
613 /* > These are the first and last rows and columns of an */
614 /* > isolated diagonal block upon which the QR sweep is to be */
615 /* > applied. It is assumed without a check that */
616 /* > either KTOP = 1 or H(KTOP,KTOP-1) = 0 */
618 /* > either KBOT = N or H(KBOT+1,KBOT) = 0. */
621 /* > \param[in] NSHFTS */
623 /* > NSHFTS is INTEGER */
624 /* > NSHFTS gives the number of simultaneous shifts. NSHFTS */
625 /* > must be positive and even. */
628 /* > \param[in,out] SR */
630 /* > SR is DOUBLE PRECISION array, dimension (NSHFTS) */
633 /* > \param[in,out] SI */
635 /* > SI is DOUBLE PRECISION array, dimension (NSHFTS) */
636 /* > SR contains the real parts and SI contains the imaginary */
637 /* > parts of the NSHFTS shifts of origin that define the */
638 /* > multi-shift QR sweep. On output SR and SI may be */
642 /* > \param[in,out] H */
644 /* > H is DOUBLE PRECISION array, dimension (LDH,N) */
645 /* > On input H contains a Hessenberg matrix. On output a */
646 /* > multi-shift QR sweep with shifts SR(J)+i*SI(J) is applied */
647 /* > to the isolated diagonal block in rows and columns KTOP */
648 /* > through KBOT. */
651 /* > \param[in] LDH */
653 /* > LDH is INTEGER */
654 /* > LDH is the leading dimension of H just as declared in the */
655 /* > calling procedure. LDH >= MAX(1,N). */
658 /* > \param[in] ILOZ */
660 /* > ILOZ is INTEGER */
663 /* > \param[in] IHIZ */
665 /* > IHIZ is INTEGER */
666 /* > Specify the rows of Z to which transformations must be */
667 /* > applied if WANTZ is .TRUE.. 1 <= ILOZ <= IHIZ <= N */
670 /* > \param[in,out] Z */
672 /* > Z is DOUBLE PRECISION array, dimension (LDZ,IHIZ) */
673 /* > If WANTZ = .TRUE., then the QR Sweep orthogonal */
674 /* > similarity transformation is accumulated into */
675 /* > Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right. */
676 /* > If WANTZ = .FALSE., then Z is unreferenced. */
679 /* > \param[in] LDZ */
681 /* > LDZ is INTEGER */
682 /* > LDA is the leading dimension of Z just as declared in */
683 /* > the calling procedure. LDZ >= N. */
686 /* > \param[out] V */
688 /* > V is DOUBLE PRECISION array, dimension (LDV,NSHFTS/2) */
691 /* > \param[in] LDV */
693 /* > LDV is INTEGER */
694 /* > LDV is the leading dimension of V as declared in the */
695 /* > calling procedure. LDV >= 3. */
698 /* > \param[out] U */
700 /* > U is DOUBLE PRECISION array, dimension (LDU,2*NSHFTS) */
703 /* > \param[in] LDU */
705 /* > LDU is INTEGER */
706 /* > LDU is the leading dimension of U just as declared in the */
707 /* > in the calling subroutine. LDU >= 2*NSHFTS. */
710 /* > \param[in] NV */
712 /* > NV is INTEGER */
713 /* > NV is the number of rows in WV agailable for workspace. */
717 /* > \param[out] WV */
719 /* > WV is DOUBLE PRECISION array, dimension (LDWV,2*NSHFTS) */
722 /* > \param[in] LDWV */
724 /* > LDWV is INTEGER */
725 /* > LDWV is the leading dimension of WV as declared in the */
726 /* > in the calling subroutine. LDWV >= NV. */
729 /* > \param[in] NH */
731 /* > NH is INTEGER */
732 /* > NH is the number of columns in array WH available for */
733 /* > workspace. NH >= 1. */
736 /* > \param[out] WH */
738 /* > WH is DOUBLE PRECISION array, dimension (LDWH,NH) */
741 /* > \param[in] LDWH */
743 /* > LDWH is INTEGER */
744 /* > Leading dimension of WH just as declared in the */
745 /* > calling procedure. LDWH >= 2*NSHFTS. */
751 /* > \author Univ. of Tennessee */
752 /* > \author Univ. of California Berkeley */
753 /* > \author Univ. of Colorado Denver */
754 /* > \author NAG Ltd. */
756 /* > \date January 2021 */
758 /* > \ingroup doubleOTHERauxiliary */
760 /* > \par Contributors: */
761 /* ================== */
763 /* > Karen Braman and Ralph Byers, Department of Mathematics, */
764 /* > University of Kansas, USA */
766 /* > Lars Karlsson, Daniel Kressner, and Bruno Lang */
768 /* > Thijs Steel, Department of Computer science, */
769 /* > KU Leuven, Belgium */
771 /* > \par References: */
772 /* ================ */
774 /* > K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */
775 /* > Algorithm Part I: Maintaining Well Focused Shifts, and Level 3 */
776 /* > Performance, SIAM Journal of Matrix Analysis, volume 23, pages */
777 /* > 929--947, 2002. */
779 /* > Lars Karlsson, Daniel Kressner, and Bruno Lang, Optimally packed */
780 /* > chains of bulges in multishift QR algorithms. */
781 /* > ACM Trans. Math. Softw. 40, 2, Article 12 (February 2014). */
783 /* ===================================================================== */
784 /* Subroutine */ int dlaqr5_(logical *wantt, logical *wantz, integer *kacc22,
785 integer *n, integer *ktop, integer *kbot, integer *nshfts, doublereal
786 *sr, doublereal *si, doublereal *h__, integer *ldh, integer *iloz,
787 integer *ihiz, doublereal *z__, integer *ldz, doublereal *v, integer *
788 ldv, doublereal *u, integer *ldu, integer *nv, doublereal *wv,
789 integer *ldwv, integer *nh, doublereal *wh, integer *ldwh)
791 /* System generated locals */
792 integer h_dim1, h_offset, u_dim1, u_offset, v_dim1, v_offset, wh_dim1,
793 wh_offset, wv_dim1, wv_offset, z_dim1, z_offset, i__1, i__2, i__3,
794 i__4, i__5, i__6, i__7;
795 doublereal d__1, d__2, d__3, d__4, d__5;
797 /* Local variables */
800 integer jcol, jlen, jbot, mbot;
802 integer jtop, jrow, mtop, i__, j, k, m;
805 extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *,
806 integer *, doublereal *, doublereal *, integer *, doublereal *,
807 integer *, doublereal *, doublereal *, integer *);
808 integer ndcol, incol, krcol, nbmps, i2, k1, i4;
809 extern /* Subroutine */ int dlaqr1_(integer *, doublereal *, integer *,
810 doublereal *, doublereal *, doublereal *, doublereal *,
811 doublereal *), dlabad_(doublereal *, doublereal *);
812 doublereal h11, h12, h21, h22;
814 extern doublereal dlamch_(char *);
815 extern /* Subroutine */ int dlarfg_(integer *, doublereal *, doublereal *,
816 integer *, doublereal *);
819 extern /* Subroutine */ int dlacpy_(char *, integer *, integer *,
820 doublereal *, integer *, doublereal *, integer *);
821 doublereal safmin, safmax;
822 extern /* Subroutine */ int dlaset_(char *, integer *, integer *,
823 doublereal *, doublereal *, doublereal *, integer *);
824 doublereal refsum, smlnum, scl;
827 doublereal tst1, tst2;
830 /* -- LAPACK auxiliary routine (version 3.7.1) -- */
831 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
832 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
836 /* ================================================================ */
839 /* ==== If there are no shifts, then there is nothing to do. ==== */
841 /* Parameter adjustments */
845 h_offset = 1 + h_dim1 * 1;
848 z_offset = 1 + z_dim1 * 1;
851 v_offset = 1 + v_dim1 * 1;
854 u_offset = 1 + u_dim1 * 1;
857 wv_offset = 1 + wv_dim1 * 1;
860 wh_offset = 1 + wh_dim1 * 1;
868 /* ==== If the active block is empty or 1-by-1, then there */
869 /* . is nothing to do. ==== */
871 if (*ktop >= *kbot) {
875 /* ==== Shuffle shifts into pairs of real shifts and pairs */
876 /* . of complex conjugate shifts assuming complex */
877 /* . conjugate shifts are already adjacent to one */
878 /* . another. ==== */
881 for (i__ = 1; i__ <= i__1; i__ += 2) {
882 if (si[i__] != -si[i__ + 1]) {
885 sr[i__] = sr[i__ + 1];
886 sr[i__ + 1] = sr[i__ + 2];
890 si[i__] = si[i__ + 1];
891 si[i__ + 1] = si[i__ + 2];
897 /* ==== NSHFTS is supposed to be even, but if it is odd, */
898 /* . then simply reduce it by one. The shuffle above */
899 /* . ensures that the dropped shift is real and that */
900 /* . the remaining shifts are paired. ==== */
902 ns = *nshfts - *nshfts % 2;
904 /* ==== Machine constants for deflation ==== */
906 safmin = dlamch_("SAFE MINIMUM");
907 safmax = 1. / safmin;
908 dlabad_(&safmin, &safmax);
909 ulp = dlamch_("PRECISION");
910 smlnum = safmin * ((doublereal) (*n) / ulp);
912 /* ==== Use accumulated reflections to update far-from-diagonal */
913 /* . entries ? ==== */
915 accum = *kacc22 == 1 || *kacc22 == 2;
917 /* ==== clear trash ==== */
919 if (*ktop + 2 <= *kbot) {
920 h__[*ktop + 2 + *ktop * h_dim1] = 0.;
923 /* ==== NBMPS = number of 2-shift bulges in the chain ==== */
927 /* ==== KDU = width of slab ==== */
931 /* ==== Create and chase chains of NBMPS bulges ==== */
935 for (incol = *ktop - (nbmps << 1) + 1; i__2 < 0 ? incol >= i__1 : incol <=
936 i__1; incol += i__2) {
938 /* JTOP = Index from which updates from the right start. */
941 jtop = f2cmax(*ktop,incol);
950 dlaset_("ALL", &kdu, &kdu, &c_b7, &c_b8, &u[u_offset], ldu);
953 /* ==== Near-the-diagonal bulge chase. The following loop */
954 /* . performs the near-the-diagonal part of a small bulge */
955 /* . multi-shift QR sweep. Each 4*NBMPS column diagonal */
956 /* . chunk extends from column INCOL to column NDCOL */
957 /* . (including both column INCOL and column NDCOL). The */
958 /* . following loop chases a 2*NBMPS+1 column long chain of */
959 /* . NBMPS bulges 2*NBMPS columns to the right. (INCOL */
960 /* . may be less than KTOP and and NDCOL may be greater than */
961 /* . KBOT indicating phantom columns from which to chase */
962 /* . bulges before they are actually introduced or to which */
963 /* . to chase bulges beyond column KBOT.) ==== */
966 i__4 = incol + (nbmps << 1) - 1, i__5 = *kbot - 2;
967 i__3 = f2cmin(i__4,i__5);
968 for (krcol = incol; krcol <= i__3; ++krcol) {
970 /* ==== Bulges number MTOP to MBOT are active double implicit */
971 /* . shift bulges. There may or may not also be small */
972 /* . 2-by-2 bulge, if there is room. The inactive bulges */
973 /* . (if any) must wait until the active bulges have moved */
974 /* . down the diagonal to make room. The phantom matrix */
975 /* . paradigm described above helps keep track. ==== */
978 i__4 = 1, i__5 = (*ktop - krcol) / 2 + 1;
979 mtop = f2cmax(i__4,i__5);
981 i__4 = nbmps, i__5 = (*kbot - krcol - 1) / 2;
982 mbot = f2cmin(i__4,i__5);
984 bmp22 = mbot < nbmps && krcol + (m22 - 1 << 1) == *kbot - 2;
986 /* ==== Generate reflections to chase the chain right */
987 /* . one column. (The minimum value of K is KTOP-1.) ==== */
991 /* ==== Special case: 2-by-2 reflection at bottom treated */
992 /* . separately ==== */
994 k = krcol + (m22 - 1 << 1);
995 if (k == *ktop - 1) {
996 dlaqr1_(&c__2, &h__[k + 1 + (k + 1) * h_dim1], ldh, &sr[(
997 m22 << 1) - 1], &si[(m22 << 1) - 1], &sr[m22 * 2],
998 &si[m22 * 2], &v[m22 * v_dim1 + 1]);
999 beta = v[m22 * v_dim1 + 1];
1000 dlarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22
1003 beta = h__[k + 1 + k * h_dim1];
1004 v[m22 * v_dim1 + 2] = h__[k + 2 + k * h_dim1];
1005 dlarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22
1007 h__[k + 1 + k * h_dim1] = beta;
1008 h__[k + 2 + k * h_dim1] = 0.;
1011 /* ==== Perform update from right within */
1012 /* . computational window. ==== */
1015 i__5 = *kbot, i__6 = k + 3;
1016 i__4 = f2cmin(i__5,i__6);
1017 for (j = jtop; j <= i__4; ++j) {
1018 refsum = v[m22 * v_dim1 + 1] * (h__[j + (k + 1) * h_dim1]
1019 + v[m22 * v_dim1 + 2] * h__[j + (k + 2) * h_dim1])
1021 h__[j + (k + 1) * h_dim1] -= refsum;
1022 h__[j + (k + 2) * h_dim1] -= refsum * v[m22 * v_dim1 + 2];
1026 /* ==== Perform update from left within */
1027 /* . computational window. ==== */
1030 jbot = f2cmin(ndcol,*kbot);
1031 } else if (*wantt) {
1037 for (j = k + 1; j <= i__4; ++j) {
1038 refsum = v[m22 * v_dim1 + 1] * (h__[k + 1 + j * h_dim1] +
1039 v[m22 * v_dim1 + 2] * h__[k + 2 + j * h_dim1]);
1040 h__[k + 1 + j * h_dim1] -= refsum;
1041 h__[k + 2 + j * h_dim1] -= refsum * v[m22 * v_dim1 + 2];
1045 /* ==== The following convergence test requires that */
1046 /* . the tradition small-compared-to-nearby-diagonals */
1047 /* . criterion and the Ahues & Tisseur (LAWN 122, 1997) */
1048 /* . criteria both be satisfied. The latter improves */
1049 /* . accuracy in some examples. Falling back on an */
1050 /* . alternate convergence criterion when TST1 or TST2 */
1051 /* . is zero (as done here) is traditional but probably */
1052 /* . unnecessary. ==== */
1055 if (h__[k + 1 + k * h_dim1] != 0.) {
1056 tst1 = (d__1 = h__[k + k * h_dim1], abs(d__1)) + (
1057 d__2 = h__[k + 1 + (k + 1) * h_dim1], abs(
1060 if (k >= *ktop + 1) {
1061 tst1 += (d__1 = h__[k + (k - 1) * h_dim1],
1064 if (k >= *ktop + 2) {
1065 tst1 += (d__1 = h__[k + (k - 2) * h_dim1],
1068 if (k >= *ktop + 3) {
1069 tst1 += (d__1 = h__[k + (k - 3) * h_dim1],
1072 if (k <= *kbot - 2) {
1073 tst1 += (d__1 = h__[k + 2 + (k + 1) * h_dim1],
1076 if (k <= *kbot - 3) {
1077 tst1 += (d__1 = h__[k + 3 + (k + 1) * h_dim1],
1080 if (k <= *kbot - 4) {
1081 tst1 += (d__1 = h__[k + 4 + (k + 1) * h_dim1],
1086 d__2 = smlnum, d__3 = ulp * tst1;
1087 if ((d__1 = h__[k + 1 + k * h_dim1], abs(d__1)) <=
1088 f2cmax(d__2,d__3)) {
1090 d__3 = (d__1 = h__[k + 1 + k * h_dim1], abs(d__1))
1091 , d__4 = (d__2 = h__[k + (k + 1) * h_dim1]
1093 h12 = f2cmax(d__3,d__4);
1095 d__3 = (d__1 = h__[k + 1 + k * h_dim1], abs(d__1))
1096 , d__4 = (d__2 = h__[k + (k + 1) * h_dim1]
1098 h21 = f2cmin(d__3,d__4);
1100 d__3 = (d__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1101 d__1)), d__4 = (d__2 = h__[k + k * h_dim1]
1102 - h__[k + 1 + (k + 1) * h_dim1], abs(
1104 h11 = f2cmax(d__3,d__4);
1106 d__3 = (d__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1107 d__1)), d__4 = (d__2 = h__[k + k * h_dim1]
1108 - h__[k + 1 + (k + 1) * h_dim1], abs(
1110 h22 = f2cmin(d__3,d__4);
1112 tst2 = h22 * (h11 / scl);
1115 d__1 = smlnum, d__2 = ulp * tst2;
1116 if (tst2 == 0. || h21 * (h12 / scl) <= f2cmax(d__1,
1118 h__[k + 1 + k * h_dim1] = 0.;
1124 /* ==== Accumulate orthogonal transformations. ==== */
1129 i__4 = 1, i__5 = *ktop - incol;
1131 for (j = f2cmax(i__4,i__5); j <= i__6; ++j) {
1132 refsum = v[m22 * v_dim1 + 1] * (u[j + (kms + 1) *
1133 u_dim1] + v[m22 * v_dim1 + 2] * u[j + (kms +
1135 u[j + (kms + 1) * u_dim1] -= refsum;
1136 u[j + (kms + 2) * u_dim1] -= refsum * v[m22 * v_dim1
1140 } else if (*wantz) {
1142 for (j = *iloz; j <= i__6; ++j) {
1143 refsum = v[m22 * v_dim1 + 1] * (z__[j + (k + 1) *
1144 z_dim1] + v[m22 * v_dim1 + 2] * z__[j + (k +
1146 z__[j + (k + 1) * z_dim1] -= refsum;
1147 z__[j + (k + 2) * z_dim1] -= refsum * v[m22 * v_dim1
1154 /* ==== Normal case: Chain of 3-by-3 reflections ==== */
1157 for (m = mbot; m >= i__6; --m) {
1158 k = krcol + (m - 1 << 1);
1159 if (k == *ktop - 1) {
1160 dlaqr1_(&c__3, &h__[*ktop + *ktop * h_dim1], ldh, &sr[(m
1161 << 1) - 1], &si[(m << 1) - 1], &sr[m * 2], &si[m *
1162 2], &v[m * v_dim1 + 1]);
1163 alpha = v[m * v_dim1 + 1];
1164 dlarfg_(&c__3, &alpha, &v[m * v_dim1 + 2], &c__1, &v[m *
1168 /* ==== Perform delayed transformation of row below */
1169 /* . Mth bulge. Exploit fact that first two elements */
1170 /* . of row are actually zero. ==== */
1172 refsum = v[m * v_dim1 + 1] * v[m * v_dim1 + 3] * h__[k +
1173 3 + (k + 2) * h_dim1];
1174 h__[k + 3 + k * h_dim1] = -refsum;
1175 h__[k + 3 + (k + 1) * h_dim1] = -refsum * v[m * v_dim1 +
1177 h__[k + 3 + (k + 2) * h_dim1] -= refsum * v[m * v_dim1 +
1180 /* ==== Calculate reflection to move */
1181 /* . Mth bulge one step. ==== */
1183 beta = h__[k + 1 + k * h_dim1];
1184 v[m * v_dim1 + 2] = h__[k + 2 + k * h_dim1];
1185 v[m * v_dim1 + 3] = h__[k + 3 + k * h_dim1];
1186 dlarfg_(&c__3, &beta, &v[m * v_dim1 + 2], &c__1, &v[m *
1189 /* ==== A Bulge may collapse because of vigilant */
1190 /* . deflation or destructive underflow. In the */
1191 /* . underflow case, try the two-small-subdiagonals */
1192 /* . trick to try to reinflate the bulge. ==== */
1194 if (h__[k + 3 + k * h_dim1] != 0. || h__[k + 3 + (k + 1) *
1195 h_dim1] != 0. || h__[k + 3 + (k + 2) * h_dim1] ==
1198 /* ==== Typical case: not collapsed (yet). ==== */
1200 h__[k + 1 + k * h_dim1] = beta;
1201 h__[k + 2 + k * h_dim1] = 0.;
1202 h__[k + 3 + k * h_dim1] = 0.;
1205 /* ==== Atypical case: collapsed. Attempt to */
1206 /* . reintroduce ignoring H(K+1,K) and H(K+2,K). */
1207 /* . If the fill resulting from the new */
1208 /* . reflector is too large, then abandon it. */
1209 /* . Otherwise, use the new one. ==== */
1211 dlaqr1_(&c__3, &h__[k + 1 + (k + 1) * h_dim1], ldh, &
1212 sr[(m << 1) - 1], &si[(m << 1) - 1], &sr[m *
1213 2], &si[m * 2], vt);
1215 dlarfg_(&c__3, &alpha, &vt[1], &c__1, vt);
1216 refsum = vt[0] * (h__[k + 1 + k * h_dim1] + vt[1] *
1217 h__[k + 2 + k * h_dim1]);
1219 if ((d__1 = h__[k + 2 + k * h_dim1] - refsum * vt[1],
1220 abs(d__1)) + (d__2 = refsum * vt[2], abs(d__2)
1221 ) > ulp * ((d__3 = h__[k + k * h_dim1], abs(
1222 d__3)) + (d__4 = h__[k + 1 + (k + 1) * h_dim1]
1223 , abs(d__4)) + (d__5 = h__[k + 2 + (k + 2) *
1224 h_dim1], abs(d__5)))) {
1226 /* ==== Starting a new bulge here would */
1227 /* . create non-negligible fill. Use */
1228 /* . the old one with trepidation. ==== */
1230 h__[k + 1 + k * h_dim1] = beta;
1231 h__[k + 2 + k * h_dim1] = 0.;
1232 h__[k + 3 + k * h_dim1] = 0.;
1235 /* ==== Starting a new bulge here would */
1236 /* . create only negligible fill. */
1237 /* . Replace the old reflector with */
1238 /* . the new one. ==== */
1240 h__[k + 1 + k * h_dim1] -= refsum;
1241 h__[k + 2 + k * h_dim1] = 0.;
1242 h__[k + 3 + k * h_dim1] = 0.;
1243 v[m * v_dim1 + 1] = vt[0];
1244 v[m * v_dim1 + 2] = vt[1];
1245 v[m * v_dim1 + 3] = vt[2];
1250 /* ==== Apply reflection from the right and */
1251 /* . the first column of update from the left. */
1252 /* . These updates are required for the vigilant */
1253 /* . deflation check. We still delay most of the */
1254 /* . updates from the left for efficiency. ==== */
1257 i__5 = *kbot, i__7 = k + 3;
1258 i__4 = f2cmin(i__5,i__7);
1259 for (j = jtop; j <= i__4; ++j) {
1260 refsum = v[m * v_dim1 + 1] * (h__[j + (k + 1) * h_dim1] +
1261 v[m * v_dim1 + 2] * h__[j + (k + 2) * h_dim1] + v[
1262 m * v_dim1 + 3] * h__[j + (k + 3) * h_dim1]);
1263 h__[j + (k + 1) * h_dim1] -= refsum;
1264 h__[j + (k + 2) * h_dim1] -= refsum * v[m * v_dim1 + 2];
1265 h__[j + (k + 3) * h_dim1] -= refsum * v[m * v_dim1 + 3];
1269 /* ==== Perform update from left for subsequent */
1270 /* . column. ==== */
1272 refsum = v[m * v_dim1 + 1] * (h__[k + 1 + (k + 1) * h_dim1] +
1273 v[m * v_dim1 + 2] * h__[k + 2 + (k + 1) * h_dim1] + v[
1274 m * v_dim1 + 3] * h__[k + 3 + (k + 1) * h_dim1]);
1275 h__[k + 1 + (k + 1) * h_dim1] -= refsum;
1276 h__[k + 2 + (k + 1) * h_dim1] -= refsum * v[m * v_dim1 + 2];
1277 h__[k + 3 + (k + 1) * h_dim1] -= refsum * v[m * v_dim1 + 3];
1279 /* ==== The following convergence test requires that */
1280 /* . the tradition small-compared-to-nearby-diagonals */
1281 /* . criterion and the Ahues & Tisseur (LAWN 122, 1997) */
1282 /* . criteria both be satisfied. The latter improves */
1283 /* . accuracy in some examples. Falling back on an */
1284 /* . alternate convergence criterion when TST1 or TST2 */
1285 /* . is zero (as done here) is traditional but probably */
1286 /* . unnecessary. ==== */
1291 if (h__[k + 1 + k * h_dim1] != 0.) {
1292 tst1 = (d__1 = h__[k + k * h_dim1], abs(d__1)) + (d__2 =
1293 h__[k + 1 + (k + 1) * h_dim1], abs(d__2));
1295 if (k >= *ktop + 1) {
1296 tst1 += (d__1 = h__[k + (k - 1) * h_dim1], abs(
1299 if (k >= *ktop + 2) {
1300 tst1 += (d__1 = h__[k + (k - 2) * h_dim1], abs(
1303 if (k >= *ktop + 3) {
1304 tst1 += (d__1 = h__[k + (k - 3) * h_dim1], abs(
1307 if (k <= *kbot - 2) {
1308 tst1 += (d__1 = h__[k + 2 + (k + 1) * h_dim1],
1311 if (k <= *kbot - 3) {
1312 tst1 += (d__1 = h__[k + 3 + (k + 1) * h_dim1],
1315 if (k <= *kbot - 4) {
1316 tst1 += (d__1 = h__[k + 4 + (k + 1) * h_dim1],
1321 d__2 = smlnum, d__3 = ulp * tst1;
1322 if ((d__1 = h__[k + 1 + k * h_dim1], abs(d__1)) <= f2cmax(
1325 d__3 = (d__1 = h__[k + 1 + k * h_dim1], abs(d__1)),
1326 d__4 = (d__2 = h__[k + (k + 1) * h_dim1], abs(
1328 h12 = f2cmax(d__3,d__4);
1330 d__3 = (d__1 = h__[k + 1 + k * h_dim1], abs(d__1)),
1331 d__4 = (d__2 = h__[k + (k + 1) * h_dim1], abs(
1333 h21 = f2cmin(d__3,d__4);
1335 d__3 = (d__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1336 d__1)), d__4 = (d__2 = h__[k + k * h_dim1] -
1337 h__[k + 1 + (k + 1) * h_dim1], abs(d__2));
1338 h11 = f2cmax(d__3,d__4);
1340 d__3 = (d__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1341 d__1)), d__4 = (d__2 = h__[k + k * h_dim1] -
1342 h__[k + 1 + (k + 1) * h_dim1], abs(d__2));
1343 h22 = f2cmin(d__3,d__4);
1345 tst2 = h22 * (h11 / scl);
1348 d__1 = smlnum, d__2 = ulp * tst2;
1349 if (tst2 == 0. || h21 * (h12 / scl) <= f2cmax(d__1,d__2))
1351 h__[k + 1 + k * h_dim1] = 0.;
1358 /* ==== Multiply H by reflections from the left ==== */
1361 jbot = f2cmin(ndcol,*kbot);
1362 } else if (*wantt) {
1369 for (m = mbot; m >= i__6; --m) {
1370 k = krcol + (m - 1 << 1);
1372 i__4 = *ktop, i__5 = krcol + (m << 1);
1374 for (j = f2cmax(i__4,i__5); j <= i__7; ++j) {
1375 refsum = v[m * v_dim1 + 1] * (h__[k + 1 + j * h_dim1] + v[
1376 m * v_dim1 + 2] * h__[k + 2 + j * h_dim1] + v[m *
1377 v_dim1 + 3] * h__[k + 3 + j * h_dim1]);
1378 h__[k + 1 + j * h_dim1] -= refsum;
1379 h__[k + 2 + j * h_dim1] -= refsum * v[m * v_dim1 + 2];
1380 h__[k + 3 + j * h_dim1] -= refsum * v[m * v_dim1 + 3];
1386 /* ==== Accumulate orthogonal transformations. ==== */
1390 /* ==== Accumulate U. (If needed, update Z later */
1391 /* . with an efficient matrix-matrix */
1392 /* . multiply.) ==== */
1395 for (m = mbot; m >= i__6; --m) {
1396 k = krcol + (m - 1 << 1);
1399 i__7 = 1, i__4 = *ktop - incol;
1400 i2 = f2cmax(i__7,i__4);
1402 i__7 = i2, i__4 = kms - (krcol - incol) + 1;
1403 i2 = f2cmax(i__7,i__4);
1405 i__7 = kdu, i__4 = krcol + (mbot - 1 << 1) - incol + 5;
1406 i4 = f2cmin(i__7,i__4);
1408 for (j = i2; j <= i__7; ++j) {
1409 refsum = v[m * v_dim1 + 1] * (u[j + (kms + 1) *
1410 u_dim1] + v[m * v_dim1 + 2] * u[j + (kms + 2)
1411 * u_dim1] + v[m * v_dim1 + 3] * u[j + (kms +
1413 u[j + (kms + 1) * u_dim1] -= refsum;
1414 u[j + (kms + 2) * u_dim1] -= refsum * v[m * v_dim1 +
1416 u[j + (kms + 3) * u_dim1] -= refsum * v[m * v_dim1 +
1422 } else if (*wantz) {
1424 /* ==== U is not accumulated, so update Z */
1425 /* . now by multiplying by reflections */
1426 /* . from the right. ==== */
1429 for (m = mbot; m >= i__6; --m) {
1430 k = krcol + (m - 1 << 1);
1432 for (j = *iloz; j <= i__7; ++j) {
1433 refsum = v[m * v_dim1 + 1] * (z__[j + (k + 1) *
1434 z_dim1] + v[m * v_dim1 + 2] * z__[j + (k + 2)
1435 * z_dim1] + v[m * v_dim1 + 3] * z__[j + (k +
1437 z__[j + (k + 1) * z_dim1] -= refsum;
1438 z__[j + (k + 2) * z_dim1] -= refsum * v[m * v_dim1 +
1440 z__[j + (k + 3) * z_dim1] -= refsum * v[m * v_dim1 +
1448 /* ==== End of near-the-diagonal bulge chase. ==== */
1453 /* ==== Use U (if accumulated) to update far-from-diagonal */
1454 /* . entries in H. If required, use U to update Z as */
1466 i__3 = 1, i__6 = *ktop - incol;
1467 k1 = f2cmax(i__3,i__6);
1469 i__3 = 0, i__6 = ndcol - *kbot;
1470 nu = kdu - f2cmax(i__3,i__6) - k1 + 1;
1472 /* ==== Horizontal Multiply ==== */
1476 for (jcol = f2cmin(ndcol,*kbot) + 1; i__6 < 0 ? jcol >= i__3 : jcol
1477 <= i__3; jcol += i__6) {
1479 i__7 = *nh, i__4 = jbot - jcol + 1;
1480 jlen = f2cmin(i__7,i__4);
1481 dgemm_("C", "N", &nu, &jlen, &nu, &c_b8, &u[k1 + k1 * u_dim1],
1482 ldu, &h__[incol + k1 + jcol * h_dim1], ldh, &c_b7, &
1483 wh[wh_offset], ldwh);
1484 dlacpy_("ALL", &nu, &jlen, &wh[wh_offset], ldwh, &h__[incol +
1485 k1 + jcol * h_dim1], ldh);
1489 /* ==== Vertical multiply ==== */
1491 i__6 = f2cmax(*ktop,incol) - 1;
1493 for (jrow = jtop; i__3 < 0 ? jrow >= i__6 : jrow <= i__6; jrow +=
1496 i__7 = *nv, i__4 = f2cmax(*ktop,incol) - jrow;
1497 jlen = f2cmin(i__7,i__4);
1498 dgemm_("N", "N", &jlen, &nu, &nu, &c_b8, &h__[jrow + (incol +
1499 k1) * h_dim1], ldh, &u[k1 + k1 * u_dim1], ldu, &c_b7,
1500 &wv[wv_offset], ldwv);
1501 dlacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &h__[jrow + (
1502 incol + k1) * h_dim1], ldh);
1506 /* ==== Z multiply (also vertical) ==== */
1511 for (jrow = *iloz; i__6 < 0 ? jrow >= i__3 : jrow <= i__3;
1514 i__7 = *nv, i__4 = *ihiz - jrow + 1;
1515 jlen = f2cmin(i__7,i__4);
1516 dgemm_("N", "N", &jlen, &nu, &nu, &c_b8, &z__[jrow + (
1517 incol + k1) * z_dim1], ldz, &u[k1 + k1 * u_dim1],
1518 ldu, &c_b7, &wv[wv_offset], ldwv);
1519 dlacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &z__[
1520 jrow + (incol + k1) * z_dim1], ldz);
1528 /* ==== End of DLAQR5 ==== */