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)
513 /* Table of constant values */
515 static real c_b7 = 0.f;
516 static real c_b8 = 1.f;
517 static integer c__2 = 2;
518 static integer c__1 = 1;
519 static integer c__3 = 3;
521 /* > \brief \b SLAQR5 performs a single small-bulge multi-shift QR sweep. */
523 /* =========== DOCUMENTATION =========== */
525 /* Online html documentation available at */
526 /* http://www.netlib.org/lapack/explore-html/ */
529 /* > Download SLAQR5 + dependencies */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slaqr5.
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slaqr5.
536 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slaqr5.
544 /* SUBROUTINE SLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NSHFTS, */
545 /* SR, SI, H, LDH, ILOZ, IHIZ, Z, LDZ, V, LDV, U, */
546 /* LDU, NV, WV, LDWV, NH, WH, LDWH ) */
548 /* INTEGER IHIZ, ILOZ, KACC22, KBOT, KTOP, LDH, LDU, LDV, */
549 /* $ LDWH, LDWV, LDZ, N, NH, NSHFTS, NV */
550 /* LOGICAL WANTT, WANTZ */
551 /* REAL H( LDH, * ), SI( * ), SR( * ), U( LDU, * ), */
552 /* $ V( LDV, * ), WH( LDWH, * ), WV( LDWV, * ), */
556 /* > \par Purpose: */
561 /* > SLAQR5, called by SLAQR0, performs a */
562 /* > single small-bulge multi-shift QR sweep. */
568 /* > \param[in] WANTT */
570 /* > WANTT is LOGICAL */
571 /* > WANTT = .true. if the quasi-triangular Schur factor */
572 /* > is being computed. WANTT is set to .false. otherwise. */
575 /* > \param[in] WANTZ */
577 /* > WANTZ is LOGICAL */
578 /* > WANTZ = .true. if the orthogonal Schur factor is being */
579 /* > computed. WANTZ is set to .false. otherwise. */
582 /* > \param[in] KACC22 */
584 /* > KACC22 is INTEGER with value 0, 1, or 2. */
585 /* > Specifies the computation mode of far-from-diagonal */
586 /* > orthogonal updates. */
587 /* > = 0: SLAQR5 does not accumulate reflections and does not */
588 /* > use matrix-matrix multiply to update far-from-diagonal */
589 /* > matrix entries. */
590 /* > = 1: SLAQR5 accumulates reflections and uses matrix-matrix */
591 /* > multiply to update the far-from-diagonal matrix entries. */
592 /* > = 2: Same as KACC22 = 1. This option used to enable exploiting */
593 /* > the 2-by-2 structure during matrix multiplications, but */
594 /* > this is no longer supported. */
600 /* > N is the order of the Hessenberg matrix H upon which this */
601 /* > subroutine operates. */
604 /* > \param[in] KTOP */
606 /* > KTOP is INTEGER */
609 /* > \param[in] KBOT */
611 /* > KBOT is INTEGER */
612 /* > These are the first and last rows and columns of an */
613 /* > isolated diagonal block upon which the QR sweep is to be */
614 /* > applied. It is assumed without a check that */
615 /* > either KTOP = 1 or H(KTOP,KTOP-1) = 0 */
617 /* > either KBOT = N or H(KBOT+1,KBOT) = 0. */
620 /* > \param[in] NSHFTS */
622 /* > NSHFTS is INTEGER */
623 /* > NSHFTS gives the number of simultaneous shifts. NSHFTS */
624 /* > must be positive and even. */
627 /* > \param[in,out] SR */
629 /* > SR is REAL array, dimension (NSHFTS) */
632 /* > \param[in,out] SI */
634 /* > SI is REAL array, dimension (NSHFTS) */
635 /* > SR contains the real parts and SI contains the imaginary */
636 /* > parts of the NSHFTS shifts of origin that define the */
637 /* > multi-shift QR sweep. On output SR and SI may be */
641 /* > \param[in,out] H */
643 /* > H is REAL array, dimension (LDH,N) */
644 /* > On input H contains a Hessenberg matrix. On output a */
645 /* > multi-shift QR sweep with shifts SR(J)+i*SI(J) is applied */
646 /* > to the isolated diagonal block in rows and columns KTOP */
647 /* > through KBOT. */
650 /* > \param[in] LDH */
652 /* > LDH is INTEGER */
653 /* > LDH is the leading dimension of H just as declared in the */
654 /* > calling procedure. LDH >= MAX(1,N). */
657 /* > \param[in] ILOZ */
659 /* > ILOZ is INTEGER */
662 /* > \param[in] IHIZ */
664 /* > IHIZ is INTEGER */
665 /* > Specify the rows of Z to which transformations must be */
666 /* > applied if WANTZ is .TRUE.. 1 <= ILOZ <= IHIZ <= N */
669 /* > \param[in,out] Z */
671 /* > Z is REAL array, dimension (LDZ,IHIZ) */
672 /* > If WANTZ = .TRUE., then the QR Sweep orthogonal */
673 /* > similarity transformation is accumulated into */
674 /* > Z(ILOZ:IHIZ,ILOZ:IHIZ) from the right. */
675 /* > If WANTZ = .FALSE., then Z is unreferenced. */
678 /* > \param[in] LDZ */
680 /* > LDZ is INTEGER */
681 /* > LDA is the leading dimension of Z just as declared in */
682 /* > the calling procedure. LDZ >= N. */
685 /* > \param[out] V */
687 /* > V is REAL array, dimension (LDV,NSHFTS/2) */
690 /* > \param[in] LDV */
692 /* > LDV is INTEGER */
693 /* > LDV is the leading dimension of V as declared in the */
694 /* > calling procedure. LDV >= 3. */
697 /* > \param[out] U */
699 /* > U is REAL array, dimension (LDU,2*NSHFTS) */
702 /* > \param[in] LDU */
704 /* > LDU is INTEGER */
705 /* > LDU is the leading dimension of U just as declared in the */
706 /* > in the calling subroutine. LDU >= 2*NSHFTS. */
709 /* > \param[in] NV */
711 /* > NV is INTEGER */
712 /* > NV is the number of rows in WV agailable for workspace. */
716 /* > \param[out] WV */
718 /* > WV is REAL array, dimension (LDWV,2*NSHFTS) */
721 /* > \param[in] LDWV */
723 /* > LDWV is INTEGER */
724 /* > LDWV is the leading dimension of WV as declared in the */
725 /* > in the calling subroutine. LDWV >= NV. */
728 /* > \param[in] NH */
730 /* > NH is INTEGER */
731 /* > NH is the number of columns in array WH available for */
732 /* > workspace. NH >= 1. */
735 /* > \param[out] WH */
737 /* > WH is REAL array, dimension (LDWH,NH) */
740 /* > \param[in] LDWH */
742 /* > LDWH is INTEGER */
743 /* > Leading dimension of WH just as declared in the */
744 /* > calling procedure. LDWH >= 2*NSHFTS. */
750 /* > \author Univ. of Tennessee */
751 /* > \author Univ. of California Berkeley */
752 /* > \author Univ. of Colorado Denver */
753 /* > \author NAG Ltd. */
755 /* > \date January 2021 */
757 /* > \ingroup realOTHERauxiliary */
759 /* > \par Contributors: */
760 /* ================== */
762 /* > Karen Braman and Ralph Byers, Department of Mathematics, */
763 /* > University of Kansas, USA */
765 /* > Lars Karlsson, Daniel Kressner, and Bruno Lang */
767 /* > Thijs Steel, Department of Computer science, */
768 /* > KU Leuven, Belgium */
770 /* > \par References: */
771 /* ================ */
773 /* > K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */
774 /* > Algorithm Part I: Maintaining Well Focused Shifts, and Level 3 */
775 /* > Performance, SIAM Journal of Matrix Analysis, volume 23, pages */
776 /* > 929--947, 2002. */
778 /* > Lars Karlsson, Daniel Kressner, and Bruno Lang, Optimally packed */
779 /* > chains of bulges in multishift QR algorithms. */
780 /* > ACM Trans. Math. Softw. 40, 2, Article 12 (February 2014). */
782 /* ===================================================================== */
783 /* Subroutine */ int slaqr5_(logical *wantt, logical *wantz, integer *kacc22,
784 integer *n, integer *ktop, integer *kbot, integer *nshfts, real *sr,
785 real *si, real *h__, integer *ldh, integer *iloz, integer *ihiz, real
786 *z__, integer *ldz, real *v, integer *ldv, real *u, integer *ldu,
787 integer *nv, real *wv, integer *ldwv, integer *nh, real *wh, integer *
790 /* System generated locals */
791 integer h_dim1, h_offset, u_dim1, u_offset, v_dim1, v_offset, wh_dim1,
792 wh_offset, wv_dim1, wv_offset, z_dim1, z_offset, i__1, i__2, i__3,
793 i__4, i__5, i__6, i__7;
794 real r__1, r__2, r__3, r__4, r__5;
796 /* Local variables */
799 integer jcol, jlen, jbot, mbot;
801 integer jtop, jrow, mtop, i__, j, k, m;
804 integer ndcol, incol;
805 extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *,
806 integer *, real *, real *, integer *, real *, integer *, real *,
808 integer krcol, nbmps, i2, k1, i4;
809 extern /* Subroutine */ int slaqr1_(integer *, real *, integer *, real *,
810 real *, real *, real *, real *);
811 real h11, h12, h21, h22;
813 extern /* Subroutine */ int slabad_(real *, real *);
815 extern real slamch_(char *);
816 real vt[3], safmin, safmax;
817 extern /* Subroutine */ int slarfg_(integer *, real *, real *, integer *,
818 real *), slacpy_(char *, integer *, integer *, real *, integer *,
819 real *, integer *), slaset_(char *, integer *, integer *,
820 real *, real *, real *, integer *);
821 real refsum, smlnum, scl;
823 real ulp, tst1, tst2;
826 /* -- LAPACK auxiliary routine (version 3.7.1) -- */
827 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
828 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
832 /* ================================================================ */
835 /* ==== If there are no shifts, then there is nothing to do. ==== */
837 /* Parameter adjustments */
841 h_offset = 1 + h_dim1 * 1;
844 z_offset = 1 + z_dim1 * 1;
847 v_offset = 1 + v_dim1 * 1;
850 u_offset = 1 + u_dim1 * 1;
853 wv_offset = 1 + wv_dim1 * 1;
856 wh_offset = 1 + wh_dim1 * 1;
864 /* ==== If the active block is empty or 1-by-1, then there */
865 /* . is nothing to do. ==== */
867 if (*ktop >= *kbot) {
871 /* ==== Shuffle shifts into pairs of real shifts and pairs */
872 /* . of complex conjugate shifts assuming complex */
873 /* . conjugate shifts are already adjacent to one */
874 /* . another. ==== */
877 for (i__ = 1; i__ <= i__1; i__ += 2) {
878 if (si[i__] != -si[i__ + 1]) {
881 sr[i__] = sr[i__ + 1];
882 sr[i__ + 1] = sr[i__ + 2];
886 si[i__] = si[i__ + 1];
887 si[i__ + 1] = si[i__ + 2];
893 /* ==== NSHFTS is supposed to be even, but if it is odd, */
894 /* . then simply reduce it by one. The shuffle above */
895 /* . ensures that the dropped shift is real and that */
896 /* . the remaining shifts are paired. ==== */
898 ns = *nshfts - *nshfts % 2;
900 /* ==== Machine constants for deflation ==== */
902 safmin = slamch_("SAFE MINIMUM");
903 safmax = 1.f / safmin;
904 slabad_(&safmin, &safmax);
905 ulp = slamch_("PRECISION");
906 smlnum = safmin * ((real) (*n) / ulp);
908 /* ==== Use accumulated reflections to update far-from-diagonal */
909 /* . entries ? ==== */
911 accum = *kacc22 == 1 || *kacc22 == 2;
913 /* ==== clear trash ==== */
915 if (*ktop + 2 <= *kbot) {
916 h__[*ktop + 2 + *ktop * h_dim1] = 0.f;
919 /* ==== NBMPS = number of 2-shift bulges in the chain ==== */
923 /* ==== KDU = width of slab ==== */
927 /* ==== Create and chase chains of NBMPS bulges ==== */
931 for (incol = *ktop - (nbmps << 1) + 1; i__2 < 0 ? incol >= i__1 : incol <=
932 i__1; incol += i__2) {
934 /* JTOP = Index from which updates from the right start. */
937 jtop = f2cmax(*ktop,incol);
946 slaset_("ALL", &kdu, &kdu, &c_b7, &c_b8, &u[u_offset], ldu);
949 /* ==== Near-the-diagonal bulge chase. The following loop */
950 /* . performs the near-the-diagonal part of a small bulge */
951 /* . multi-shift QR sweep. Each 4*NBMPS column diagonal */
952 /* . chunk extends from column INCOL to column NDCOL */
953 /* . (including both column INCOL and column NDCOL). The */
954 /* . following loop chases a 2*NBMPS+1 column long chain of */
955 /* . NBMPS bulges 2*NBMPS-1 columns to the right. (INCOL */
956 /* . may be less than KTOP and and NDCOL may be greater than */
957 /* . KBOT indicating phantom columns from which to chase */
958 /* . bulges before they are actually introduced or to which */
959 /* . to chase bulges beyond column KBOT.) ==== */
962 i__4 = incol + (nbmps << 1) - 1, i__5 = *kbot - 2;
963 i__3 = f2cmin(i__4,i__5);
964 for (krcol = incol; krcol <= i__3; ++krcol) {
966 /* ==== Bulges number MTOP to MBOT are active double implicit */
967 /* . shift bulges. There may or may not also be small */
968 /* . 2-by-2 bulge, if there is room. The inactive bulges */
969 /* . (if any) must wait until the active bulges have moved */
970 /* . down the diagonal to make room. The phantom matrix */
971 /* . paradigm described above helps keep track. ==== */
974 i__4 = 1, i__5 = (*ktop - krcol) / 2 + 1;
975 mtop = f2cmax(i__4,i__5);
977 i__4 = nbmps, i__5 = (*kbot - krcol - 1) / 2;
978 mbot = f2cmin(i__4,i__5);
980 bmp22 = mbot < nbmps && krcol + (m22 - 1 << 1) == *kbot - 2;
982 /* ==== Generate reflections to chase the chain right */
983 /* . one column. (The minimum value of K is KTOP-1.) ==== */
987 /* ==== Special case: 2-by-2 reflection at bottom treated */
988 /* . separately ==== */
990 k = krcol + (m22 - 1 << 1);
991 if (k == *ktop - 1) {
992 slaqr1_(&c__2, &h__[k + 1 + (k + 1) * h_dim1], ldh, &sr[(
993 m22 << 1) - 1], &si[(m22 << 1) - 1], &sr[m22 * 2],
994 &si[m22 * 2], &v[m22 * v_dim1 + 1]);
995 beta = v[m22 * v_dim1 + 1];
996 slarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22
999 beta = h__[k + 1 + k * h_dim1];
1000 v[m22 * v_dim1 + 2] = h__[k + 2 + k * h_dim1];
1001 slarfg_(&c__2, &beta, &v[m22 * v_dim1 + 2], &c__1, &v[m22
1003 h__[k + 1 + k * h_dim1] = beta;
1004 h__[k + 2 + k * h_dim1] = 0.f;
1007 /* ==== Perform update from right within */
1008 /* . computational window. ==== */
1011 i__5 = *kbot, i__6 = k + 3;
1012 i__4 = f2cmin(i__5,i__6);
1013 for (j = jtop; j <= i__4; ++j) {
1014 refsum = v[m22 * v_dim1 + 1] * (h__[j + (k + 1) * h_dim1]
1015 + v[m22 * v_dim1 + 2] * h__[j + (k + 2) * h_dim1])
1017 h__[j + (k + 1) * h_dim1] -= refsum;
1018 h__[j + (k + 2) * h_dim1] -= refsum * v[m22 * v_dim1 + 2];
1022 /* ==== Perform update from left within */
1023 /* . computational window. ==== */
1026 jbot = f2cmin(ndcol,*kbot);
1027 } else if (*wantt) {
1033 for (j = k + 1; j <= i__4; ++j) {
1034 refsum = v[m22 * v_dim1 + 1] * (h__[k + 1 + j * h_dim1] +
1035 v[m22 * v_dim1 + 2] * h__[k + 2 + j * h_dim1]);
1036 h__[k + 1 + j * h_dim1] -= refsum;
1037 h__[k + 2 + j * h_dim1] -= refsum * v[m22 * v_dim1 + 2];
1041 /* ==== The following convergence test requires that */
1042 /* . the tradition small-compared-to-nearby-diagonals */
1043 /* . criterion and the Ahues & Tisseur (LAWN 122, 1997) */
1044 /* . criteria both be satisfied. The latter improves */
1045 /* . accuracy in some examples. Falling back on an */
1046 /* . alternate convergence criterion when TST1 or TST2 */
1047 /* . is zero (as done here) is traditional but probably */
1048 /* . unnecessary. ==== */
1051 if (h__[k + 1 + k * h_dim1] != 0.f) {
1052 tst1 = (r__1 = h__[k + k * h_dim1], abs(r__1)) + (
1053 r__2 = h__[k + 1 + (k + 1) * h_dim1], abs(
1056 if (k >= *ktop + 1) {
1057 tst1 += (r__1 = h__[k + (k - 1) * h_dim1],
1060 if (k >= *ktop + 2) {
1061 tst1 += (r__1 = h__[k + (k - 2) * h_dim1],
1064 if (k >= *ktop + 3) {
1065 tst1 += (r__1 = h__[k + (k - 3) * h_dim1],
1068 if (k <= *kbot - 2) {
1069 tst1 += (r__1 = h__[k + 2 + (k + 1) * h_dim1],
1072 if (k <= *kbot - 3) {
1073 tst1 += (r__1 = h__[k + 3 + (k + 1) * h_dim1],
1076 if (k <= *kbot - 4) {
1077 tst1 += (r__1 = h__[k + 4 + (k + 1) * h_dim1],
1082 r__2 = smlnum, r__3 = ulp * tst1;
1083 if ((r__1 = h__[k + 1 + k * h_dim1], abs(r__1)) <=
1084 f2cmax(r__2,r__3)) {
1086 r__3 = (r__1 = h__[k + 1 + k * h_dim1], abs(r__1))
1087 , r__4 = (r__2 = h__[k + (k + 1) * h_dim1]
1089 h12 = f2cmax(r__3,r__4);
1091 r__3 = (r__1 = h__[k + 1 + k * h_dim1], abs(r__1))
1092 , r__4 = (r__2 = h__[k + (k + 1) * h_dim1]
1094 h21 = f2cmin(r__3,r__4);
1096 r__3 = (r__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1097 r__1)), r__4 = (r__2 = h__[k + k * h_dim1]
1098 - h__[k + 1 + (k + 1) * h_dim1], abs(
1100 h11 = f2cmax(r__3,r__4);
1102 r__3 = (r__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1103 r__1)), r__4 = (r__2 = h__[k + k * h_dim1]
1104 - h__[k + 1 + (k + 1) * h_dim1], abs(
1106 h22 = f2cmin(r__3,r__4);
1108 tst2 = h22 * (h11 / scl);
1111 r__1 = smlnum, r__2 = ulp * tst2;
1112 if (tst2 == 0.f || h21 * (h12 / scl) <= f2cmax(r__1,
1114 h__[k + 1 + k * h_dim1] = 0.f;
1120 /* ==== Accumulate orthogonal transformations. ==== */
1125 i__4 = 1, i__5 = *ktop - incol;
1127 for (j = f2cmax(i__4,i__5); j <= i__6; ++j) {
1128 refsum = v[m22 * v_dim1 + 1] * (u[j + (kms + 1) *
1129 u_dim1] + v[m22 * v_dim1 + 2] * u[j + (kms +
1131 u[j + (kms + 1) * u_dim1] -= refsum;
1132 u[j + (kms + 2) * u_dim1] -= refsum * v[m22 * v_dim1
1136 } else if (*wantz) {
1138 for (j = *iloz; j <= i__6; ++j) {
1139 refsum = v[m22 * v_dim1 + 1] * (z__[j + (k + 1) *
1140 z_dim1] + v[m22 * v_dim1 + 2] * z__[j + (k +
1142 z__[j + (k + 1) * z_dim1] -= refsum;
1143 z__[j + (k + 2) * z_dim1] -= refsum * v[m22 * v_dim1
1150 /* ==== Normal case: Chain of 3-by-3 reflections ==== */
1153 for (m = mbot; m >= i__6; --m) {
1154 k = krcol + (m - 1 << 1);
1155 if (k == *ktop - 1) {
1156 slaqr1_(&c__3, &h__[*ktop + *ktop * h_dim1], ldh, &sr[(m
1157 << 1) - 1], &si[(m << 1) - 1], &sr[m * 2], &si[m *
1158 2], &v[m * v_dim1 + 1]);
1159 alpha = v[m * v_dim1 + 1];
1160 slarfg_(&c__3, &alpha, &v[m * v_dim1 + 2], &c__1, &v[m *
1164 /* ==== Perform delayed transformation of row below */
1165 /* . Mth bulge. Exploit fact that first two elements */
1166 /* . of row are actually zero. ==== */
1168 refsum = v[m * v_dim1 + 1] * v[m * v_dim1 + 3] * h__[k +
1169 3 + (k + 2) * h_dim1];
1170 h__[k + 3 + k * h_dim1] = -refsum;
1171 h__[k + 3 + (k + 1) * h_dim1] = -refsum * v[m * v_dim1 +
1173 h__[k + 3 + (k + 2) * h_dim1] -= refsum * v[m * v_dim1 +
1176 /* ==== Calculate reflection to move */
1177 /* . Mth bulge one step. ==== */
1179 beta = h__[k + 1 + k * h_dim1];
1180 v[m * v_dim1 + 2] = h__[k + 2 + k * h_dim1];
1181 v[m * v_dim1 + 3] = h__[k + 3 + k * h_dim1];
1182 slarfg_(&c__3, &beta, &v[m * v_dim1 + 2], &c__1, &v[m *
1185 /* ==== A Bulge may collapse because of vigilant */
1186 /* . deflation or destructive underflow. In the */
1187 /* . underflow case, try the two-small-subdiagonals */
1188 /* . trick to try to reinflate the bulge. ==== */
1190 if (h__[k + 3 + k * h_dim1] != 0.f || h__[k + 3 + (k + 1)
1191 * h_dim1] != 0.f || h__[k + 3 + (k + 2) * h_dim1]
1194 /* ==== Typical case: not collapsed (yet). ==== */
1196 h__[k + 1 + k * h_dim1] = beta;
1197 h__[k + 2 + k * h_dim1] = 0.f;
1198 h__[k + 3 + k * h_dim1] = 0.f;
1201 /* ==== Atypical case: collapsed. Attempt to */
1202 /* . reintroduce ignoring H(K+1,K) and H(K+2,K). */
1203 /* . If the fill resulting from the new */
1204 /* . reflector is too large, then abandon it. */
1205 /* . Otherwise, use the new one. ==== */
1207 slaqr1_(&c__3, &h__[k + 1 + (k + 1) * h_dim1], ldh, &
1208 sr[(m << 1) - 1], &si[(m << 1) - 1], &sr[m *
1209 2], &si[m * 2], vt);
1211 slarfg_(&c__3, &alpha, &vt[1], &c__1, vt);
1212 refsum = vt[0] * (h__[k + 1 + k * h_dim1] + vt[1] *
1213 h__[k + 2 + k * h_dim1]);
1215 if ((r__1 = h__[k + 2 + k * h_dim1] - refsum * vt[1],
1216 abs(r__1)) + (r__2 = refsum * vt[2], abs(r__2)
1217 ) > ulp * ((r__3 = h__[k + k * h_dim1], abs(
1218 r__3)) + (r__4 = h__[k + 1 + (k + 1) * h_dim1]
1219 , abs(r__4)) + (r__5 = h__[k + 2 + (k + 2) *
1220 h_dim1], abs(r__5)))) {
1222 /* ==== Starting a new bulge here would */
1223 /* . create non-negligible fill. Use */
1224 /* . the old one with trepidation. ==== */
1226 h__[k + 1 + k * h_dim1] = beta;
1227 h__[k + 2 + k * h_dim1] = 0.f;
1228 h__[k + 3 + k * h_dim1] = 0.f;
1231 /* ==== Starting a new bulge here would */
1232 /* . create only negligible fill. */
1233 /* . Replace the old reflector with */
1234 /* . the new one. ==== */
1236 h__[k + 1 + k * h_dim1] -= refsum;
1237 h__[k + 2 + k * h_dim1] = 0.f;
1238 h__[k + 3 + k * h_dim1] = 0.f;
1239 v[m * v_dim1 + 1] = vt[0];
1240 v[m * v_dim1 + 2] = vt[1];
1241 v[m * v_dim1 + 3] = vt[2];
1246 /* ==== Apply reflection from the right and */
1247 /* . the first column of update from the left. */
1248 /* . These updates are required for the vigilant */
1249 /* . deflation check. We still delay most of the */
1250 /* . updates from the left for efficiency. ==== */
1253 i__5 = *kbot, i__7 = k + 3;
1254 i__4 = f2cmin(i__5,i__7);
1255 for (j = jtop; j <= i__4; ++j) {
1256 refsum = v[m * v_dim1 + 1] * (h__[j + (k + 1) * h_dim1] +
1257 v[m * v_dim1 + 2] * h__[j + (k + 2) * h_dim1] + v[
1258 m * v_dim1 + 3] * h__[j + (k + 3) * h_dim1]);
1259 h__[j + (k + 1) * h_dim1] -= refsum;
1260 h__[j + (k + 2) * h_dim1] -= refsum * v[m * v_dim1 + 2];
1261 h__[j + (k + 3) * h_dim1] -= refsum * v[m * v_dim1 + 3];
1265 /* ==== Perform update from left for subsequent */
1266 /* . column. ==== */
1268 refsum = v[m * v_dim1 + 1] * (h__[k + 1 + (k + 1) * h_dim1] +
1269 v[m * v_dim1 + 2] * h__[k + 2 + (k + 1) * h_dim1] + v[
1270 m * v_dim1 + 3] * h__[k + 3 + (k + 1) * h_dim1]);
1271 h__[k + 1 + (k + 1) * h_dim1] -= refsum;
1272 h__[k + 2 + (k + 1) * h_dim1] -= refsum * v[m * v_dim1 + 2];
1273 h__[k + 3 + (k + 1) * h_dim1] -= refsum * v[m * v_dim1 + 3];
1275 /* ==== The following convergence test requires that */
1276 /* . the tradition small-compared-to-nearby-diagonals */
1277 /* . criterion and the Ahues & Tisseur (LAWN 122, 1997) */
1278 /* . criteria both be satisfied. The latter improves */
1279 /* . accuracy in some examples. Falling back on an */
1280 /* . alternate convergence criterion when TST1 or TST2 */
1281 /* . is zero (as done here) is traditional but probably */
1282 /* . unnecessary. ==== */
1287 /* $ CALL MYCYCLE */
1288 if (h__[k + 1 + k * h_dim1] != 0.f) {
1289 tst1 = (r__1 = h__[k + k * h_dim1], abs(r__1)) + (r__2 =
1290 h__[k + 1 + (k + 1) * h_dim1], abs(r__2));
1292 if (k >= *ktop + 1) {
1293 tst1 += (r__1 = h__[k + (k - 1) * h_dim1], abs(
1296 if (k >= *ktop + 2) {
1297 tst1 += (r__1 = h__[k + (k - 2) * h_dim1], abs(
1300 if (k >= *ktop + 3) {
1301 tst1 += (r__1 = h__[k + (k - 3) * h_dim1], abs(
1304 if (k <= *kbot - 2) {
1305 tst1 += (r__1 = h__[k + 2 + (k + 1) * h_dim1],
1308 if (k <= *kbot - 3) {
1309 tst1 += (r__1 = h__[k + 3 + (k + 1) * h_dim1],
1312 if (k <= *kbot - 4) {
1313 tst1 += (r__1 = h__[k + 4 + (k + 1) * h_dim1],
1318 r__2 = smlnum, r__3 = ulp * tst1;
1319 if ((r__1 = h__[k + 1 + k * h_dim1], abs(r__1)) <= f2cmax(
1322 r__3 = (r__1 = h__[k + 1 + k * h_dim1], abs(r__1)),
1323 r__4 = (r__2 = h__[k + (k + 1) * h_dim1], abs(
1325 h12 = f2cmax(r__3,r__4);
1327 r__3 = (r__1 = h__[k + 1 + k * h_dim1], abs(r__1)),
1328 r__4 = (r__2 = h__[k + (k + 1) * h_dim1], abs(
1330 h21 = f2cmin(r__3,r__4);
1332 r__3 = (r__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1333 r__1)), r__4 = (r__2 = h__[k + k * h_dim1] -
1334 h__[k + 1 + (k + 1) * h_dim1], abs(r__2));
1335 h11 = f2cmax(r__3,r__4);
1337 r__3 = (r__1 = h__[k + 1 + (k + 1) * h_dim1], abs(
1338 r__1)), r__4 = (r__2 = h__[k + k * h_dim1] -
1339 h__[k + 1 + (k + 1) * h_dim1], abs(r__2));
1340 h22 = f2cmin(r__3,r__4);
1342 tst2 = h22 * (h11 / scl);
1345 r__1 = smlnum, r__2 = ulp * tst2;
1346 if (tst2 == 0.f || h21 * (h12 / scl) <= f2cmax(r__1,r__2)
1348 h__[k + 1 + k * h_dim1] = 0.f;
1357 /* ==== Multiply H by reflections from the left ==== */
1360 jbot = f2cmin(ndcol,*kbot);
1361 } else if (*wantt) {
1368 for (m = mbot; m >= i__6; --m) {
1369 k = krcol + (m - 1 << 1);
1371 i__4 = *ktop, i__5 = krcol + (m << 1);
1373 for (j = f2cmax(i__4,i__5); j <= i__7; ++j) {
1374 refsum = v[m * v_dim1 + 1] * (h__[k + 1 + j * h_dim1] + v[
1375 m * v_dim1 + 2] * h__[k + 2 + j * h_dim1] + v[m *
1376 v_dim1 + 3] * h__[k + 3 + j * h_dim1]);
1377 h__[k + 1 + j * h_dim1] -= refsum;
1378 h__[k + 2 + j * h_dim1] -= refsum * v[m * v_dim1 + 2];
1379 h__[k + 3 + j * h_dim1] -= refsum * v[m * v_dim1 + 3];
1385 /* ==== Accumulate orthogonal transformations. ==== */
1389 /* ==== Accumulate U. (If needed, update Z later */
1390 /* . with an efficient matrix-matrix */
1391 /* . multiply.) ==== */
1394 for (m = mbot; m >= i__6; --m) {
1395 k = krcol + (m - 1 << 1);
1398 i__7 = 1, i__4 = *ktop - incol;
1399 i2 = f2cmax(i__7,i__4);
1401 i__7 = i2, i__4 = kms - (krcol - incol) + 1;
1402 i2 = f2cmax(i__7,i__4);
1404 i__7 = kdu, i__4 = krcol + (mbot - 1 << 1) - incol + 5;
1405 i4 = f2cmin(i__7,i__4);
1407 for (j = i2; j <= i__7; ++j) {
1408 refsum = v[m * v_dim1 + 1] * (u[j + (kms + 1) *
1409 u_dim1] + v[m * v_dim1 + 2] * u[j + (kms + 2)
1410 * u_dim1] + v[m * v_dim1 + 3] * u[j + (kms +
1412 u[j + (kms + 1) * u_dim1] -= refsum;
1413 u[j + (kms + 2) * u_dim1] -= refsum * v[m * v_dim1 +
1415 u[j + (kms + 3) * u_dim1] -= refsum * v[m * v_dim1 +
1421 } else if (*wantz) {
1423 /* ==== U is not accumulated, so update Z */
1424 /* . now by multiplying by reflections */
1425 /* . from the right. ==== */
1428 for (m = mbot; m >= i__6; --m) {
1429 k = krcol + (m - 1 << 1);
1431 for (j = *iloz; j <= i__7; ++j) {
1432 refsum = v[m * v_dim1 + 1] * (z__[j + (k + 1) *
1433 z_dim1] + v[m * v_dim1 + 2] * z__[j + (k + 2)
1434 * z_dim1] + v[m * v_dim1 + 3] * z__[j + (k +
1436 z__[j + (k + 1) * z_dim1] -= refsum;
1437 z__[j + (k + 2) * z_dim1] -= refsum * v[m * v_dim1 +
1439 z__[j + (k + 3) * z_dim1] -= refsum * v[m * v_dim1 +
1447 /* ==== End of near-the-diagonal bulge chase. ==== */
1452 /* ==== Use U (if accumulated) to update far-from-diagonal */
1453 /* . entries in H. If required, use U to update Z as */
1465 i__3 = 1, i__6 = *ktop - incol;
1466 k1 = f2cmax(i__3,i__6);
1468 i__3 = 0, i__6 = ndcol - *kbot;
1469 nu = kdu - f2cmax(i__3,i__6) - k1 + 1;
1471 /* ==== Horizontal Multiply ==== */
1475 for (jcol = f2cmin(ndcol,*kbot) + 1; i__6 < 0 ? jcol >= i__3 : jcol
1476 <= i__3; jcol += i__6) {
1478 i__7 = *nh, i__4 = jbot - jcol + 1;
1479 jlen = f2cmin(i__7,i__4);
1480 sgemm_("C", "N", &nu, &jlen, &nu, &c_b8, &u[k1 + k1 * u_dim1],
1481 ldu, &h__[incol + k1 + jcol * h_dim1], ldh, &c_b7, &
1482 wh[wh_offset], ldwh);
1483 slacpy_("ALL", &nu, &jlen, &wh[wh_offset], ldwh, &h__[incol +
1484 k1 + jcol * h_dim1], ldh);
1488 /* ==== Vertical multiply ==== */
1490 i__6 = f2cmax(*ktop,incol) - 1;
1492 for (jrow = jtop; i__3 < 0 ? jrow >= i__6 : jrow <= i__6; jrow +=
1495 i__7 = *nv, i__4 = f2cmax(*ktop,incol) - jrow;
1496 jlen = f2cmin(i__7,i__4);
1497 sgemm_("N", "N", &jlen, &nu, &nu, &c_b8, &h__[jrow + (incol +
1498 k1) * h_dim1], ldh, &u[k1 + k1 * u_dim1], ldu, &c_b7,
1499 &wv[wv_offset], ldwv);
1500 slacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &h__[jrow + (
1501 incol + k1) * h_dim1], ldh);
1505 /* ==== Z multiply (also vertical) ==== */
1510 for (jrow = *iloz; i__6 < 0 ? jrow >= i__3 : jrow <= i__3;
1513 i__7 = *nv, i__4 = *ihiz - jrow + 1;
1514 jlen = f2cmin(i__7,i__4);
1515 sgemm_("N", "N", &jlen, &nu, &nu, &c_b8, &z__[jrow + (
1516 incol + k1) * z_dim1], ldz, &u[k1 + k1 * u_dim1],
1517 ldu, &c_b7, &wv[wv_offset], ldwv);
1518 slacpy_("ALL", &jlen, &nu, &wv[wv_offset], ldwv, &z__[
1519 jrow + (incol + k1) * z_dim1], ldz);
1527 /* ==== End of SLAQR5 ==== */