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]/df(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 integer c__8 = 8;
516 static integer c__1 = 1;
517 static doublereal c_b27 = -1.;
518 static doublereal c_b42 = 1.;
519 static doublereal c_b56 = 0.;
521 /* > \brief \b DTGSY2 solves the generalized Sylvester equation (unblocked algorithm). */
523 /* =========== DOCUMENTATION =========== */
525 /* Online html documentation available at */
526 /* http://www.netlib.org/lapack/explore-html/ */
529 /* > Download DTGSY2 + dependencies */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtgsy2.
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtgsy2.
536 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtgsy2.
544 /* SUBROUTINE DTGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D, */
545 /* LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL, */
546 /* IWORK, PQ, INFO ) */
548 /* CHARACTER TRANS */
549 /* INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N, */
551 /* DOUBLE PRECISION RDSCAL, RDSUM, SCALE */
552 /* INTEGER IWORK( * ) */
553 /* DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * ), */
554 /* $ D( LDD, * ), E( LDE, * ), F( LDF, * ) */
557 /* > \par Purpose: */
562 /* > DTGSY2 solves the generalized Sylvester equation: */
564 /* > A * R - L * B = scale * C (1) */
565 /* > D * R - L * E = scale * F, */
567 /* > using Level 1 and 2 BLAS. where R and L are unknown M-by-N matrices, */
568 /* > (A, D), (B, E) and (C, F) are given matrix pairs of size M-by-M, */
569 /* > N-by-N and M-by-N, respectively, with real entries. (A, D) and (B, E) */
570 /* > must be in generalized Schur canonical form, i.e. A, B are upper */
571 /* > quasi triangular and D, E are upper triangular. The solution (R, L) */
572 /* > overwrites (C, F). 0 <= SCALE <= 1 is an output scaling factor */
573 /* > chosen to avoid overflow. */
575 /* > In matrix notation solving equation (1) corresponds to solve */
576 /* > Z*x = scale*b, where Z is defined as */
578 /* > Z = [ kron(In, A) -kron(B**T, Im) ] (2) */
579 /* > [ kron(In, D) -kron(E**T, Im) ], */
581 /* > Ik is the identity matrix of size k and X**T is the transpose of X. */
582 /* > kron(X, Y) is the Kronecker product between the matrices X and Y. */
583 /* > In the process of solving (1), we solve a number of such systems */
584 /* > where Dim(In), Dim(In) = 1 or 2. */
586 /* > If TRANS = 'T', solve the transposed system Z**T*y = scale*b for y, */
587 /* > which is equivalent to solve for R and L in */
589 /* > A**T * R + D**T * L = scale * C (3) */
590 /* > R * B**T + L * E**T = scale * -F */
592 /* > This case is used to compute an estimate of Dif[(A, D), (B, E)] = */
593 /* > sigma_min(Z) using reverse communication with DLACON. */
595 /* > DTGSY2 also (IJOB >= 1) contributes to the computation in DTGSYL */
596 /* > of an upper bound on the separation between to matrix pairs. Then */
597 /* > the input (A, D), (B, E) are sub-pencils of the matrix pair in */
598 /* > DTGSYL. See DTGSYL for details. */
604 /* > \param[in] TRANS */
606 /* > TRANS is CHARACTER*1 */
607 /* > = 'N': solve the generalized Sylvester equation (1). */
608 /* > = 'T': solve the 'transposed' system (3). */
611 /* > \param[in] IJOB */
613 /* > IJOB is INTEGER */
614 /* > Specifies what kind of functionality to be performed. */
615 /* > = 0: solve (1) only. */
616 /* > = 1: A contribution from this subsystem to a Frobenius */
617 /* > norm-based estimate of the separation between two matrix */
618 /* > pairs is computed. (look ahead strategy is used). */
619 /* > = 2: A contribution from this subsystem to a Frobenius */
620 /* > norm-based estimate of the separation between two matrix */
621 /* > pairs is computed. (DGECON on sub-systems is used.) */
622 /* > Not referenced if TRANS = 'T'. */
628 /* > On entry, M specifies the order of A and D, and the row */
629 /* > dimension of C, F, R and L. */
635 /* > On entry, N specifies the order of B and E, and the column */
636 /* > dimension of C, F, R and L. */
641 /* > A is DOUBLE PRECISION array, dimension (LDA, M) */
642 /* > On entry, A contains an upper quasi triangular matrix. */
645 /* > \param[in] LDA */
647 /* > LDA is INTEGER */
648 /* > The leading dimension of the matrix A. LDA >= f2cmax(1, M). */
653 /* > B is DOUBLE PRECISION array, dimension (LDB, N) */
654 /* > On entry, B contains an upper quasi triangular matrix. */
657 /* > \param[in] LDB */
659 /* > LDB is INTEGER */
660 /* > The leading dimension of the matrix B. LDB >= f2cmax(1, N). */
663 /* > \param[in,out] C */
665 /* > C is DOUBLE PRECISION array, dimension (LDC, N) */
666 /* > On entry, C contains the right-hand-side of the first matrix */
667 /* > equation in (1). */
668 /* > On exit, if IJOB = 0, C has been overwritten by the */
672 /* > \param[in] LDC */
674 /* > LDC is INTEGER */
675 /* > The leading dimension of the matrix C. LDC >= f2cmax(1, M). */
680 /* > D is DOUBLE PRECISION array, dimension (LDD, M) */
681 /* > On entry, D contains an upper triangular matrix. */
684 /* > \param[in] LDD */
686 /* > LDD is INTEGER */
687 /* > The leading dimension of the matrix D. LDD >= f2cmax(1, M). */
692 /* > E is DOUBLE PRECISION array, dimension (LDE, N) */
693 /* > On entry, E contains an upper triangular matrix. */
696 /* > \param[in] LDE */
698 /* > LDE is INTEGER */
699 /* > The leading dimension of the matrix E. LDE >= f2cmax(1, N). */
702 /* > \param[in,out] F */
704 /* > F is DOUBLE PRECISION array, dimension (LDF, N) */
705 /* > On entry, F contains the right-hand-side of the second matrix */
706 /* > equation in (1). */
707 /* > On exit, if IJOB = 0, F has been overwritten by the */
711 /* > \param[in] LDF */
713 /* > LDF is INTEGER */
714 /* > The leading dimension of the matrix F. LDF >= f2cmax(1, M). */
717 /* > \param[out] SCALE */
719 /* > SCALE is DOUBLE PRECISION */
720 /* > On exit, 0 <= SCALE <= 1. If 0 < SCALE < 1, the solutions */
721 /* > R and L (C and F on entry) will hold the solutions to a */
722 /* > slightly perturbed system but the input matrices A, B, D and */
723 /* > E have not been changed. If SCALE = 0, R and L will hold the */
724 /* > solutions to the homogeneous system with C = F = 0. Normally, */
728 /* > \param[in,out] RDSUM */
730 /* > RDSUM is DOUBLE PRECISION */
731 /* > On entry, the sum of squares of computed contributions to */
732 /* > the Dif-estimate under computation by DTGSYL, where the */
733 /* > scaling factor RDSCAL (see below) has been factored out. */
734 /* > On exit, the corresponding sum of squares updated with the */
735 /* > contributions from the current sub-system. */
736 /* > If TRANS = 'T' RDSUM is not touched. */
737 /* > NOTE: RDSUM only makes sense when DTGSY2 is called by DTGSYL. */
740 /* > \param[in,out] RDSCAL */
742 /* > RDSCAL is DOUBLE PRECISION */
743 /* > On entry, scaling factor used to prevent overflow in RDSUM. */
744 /* > On exit, RDSCAL is updated w.r.t. the current contributions */
746 /* > If TRANS = 'T', RDSCAL is not touched. */
747 /* > NOTE: RDSCAL only makes sense when DTGSY2 is called by */
751 /* > \param[out] IWORK */
753 /* > IWORK is INTEGER array, dimension (M+N+2) */
756 /* > \param[out] PQ */
758 /* > PQ is INTEGER */
759 /* > On exit, the number of subsystems (of size 2-by-2, 4-by-4 and */
760 /* > 8-by-8) solved by this routine. */
763 /* > \param[out] INFO */
765 /* > INFO is INTEGER */
766 /* > On exit, if INFO is set to */
767 /* > =0: Successful exit */
768 /* > <0: If INFO = -i, the i-th argument had an illegal value. */
769 /* > >0: The matrix pairs (A, D) and (B, E) have common or very */
770 /* > close eigenvalues. */
776 /* > \author Univ. of Tennessee */
777 /* > \author Univ. of California Berkeley */
778 /* > \author Univ. of Colorado Denver */
779 /* > \author NAG Ltd. */
781 /* > \date December 2016 */
783 /* > \ingroup doubleSYauxiliary */
785 /* > \par Contributors: */
786 /* ================== */
788 /* > Bo Kagstrom and Peter Poromaa, Department of Computing Science, */
789 /* > Umea University, S-901 87 Umea, Sweden. */
791 /* ===================================================================== */
792 /* Subroutine */ int dtgsy2_(char *trans, integer *ijob, integer *m, integer *
793 n, doublereal *a, integer *lda, doublereal *b, integer *ldb,
794 doublereal *c__, integer *ldc, doublereal *d__, integer *ldd,
795 doublereal *e, integer *lde, doublereal *f, integer *ldf, doublereal *
796 scale, doublereal *rdsum, doublereal *rdscal, integer *iwork, integer
799 /* System generated locals */
800 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1,
801 d_offset, e_dim1, e_offset, f_dim1, f_offset, i__1, i__2, i__3;
803 /* Local variables */
804 extern /* Subroutine */ int dger_(integer *, integer *, doublereal *,
805 doublereal *, integer *, doublereal *, integer *, doublereal *,
807 integer ierr, zdim, ipiv[8], jpiv[8], i__, j, k, p, q;
809 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
810 integer *), dgemm_(char *, char *, integer *, integer *, integer *
811 , doublereal *, doublereal *, integer *, doublereal *, integer *,
812 doublereal *, doublereal *, integer *);
813 doublereal z__[64] /* was [8][8] */;
814 extern logical lsame_(char *, char *);
815 extern /* Subroutine */ int dgemv_(char *, integer *, integer *,
816 doublereal *, doublereal *, integer *, doublereal *, integer *,
817 doublereal *, doublereal *, integer *), dcopy_(integer *,
818 doublereal *, integer *, doublereal *, integer *), daxpy_(integer
819 *, doublereal *, doublereal *, integer *, doublereal *, integer *)
820 , dgesc2_(integer *, doublereal *, integer *, doublereal *,
821 integer *, integer *, doublereal *), dgetc2_(integer *,
822 doublereal *, integer *, integer *, integer *, integer *);
823 integer ie, je, mb, nb, ii, jj, is, js;
824 extern /* Subroutine */ int dlatdf_(integer *, integer *, doublereal *,
825 integer *, doublereal *, doublereal *, doublereal *, integer *,
828 extern /* Subroutine */ int dlaset_(char *, integer *, integer *,
829 doublereal *, doublereal *, doublereal *, integer *),
830 xerbla_(char *, integer *, ftnlen);
836 /* -- LAPACK auxiliary routine (version 3.7.0) -- */
837 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
838 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
842 /* ===================================================================== */
843 /* Replaced various illegal calls to DCOPY by calls to DLASET. */
844 /* Sven Hammarling, 27/5/02. */
847 /* Decode and test input parameters */
849 /* Parameter adjustments */
851 a_offset = 1 + a_dim1 * 1;
854 b_offset = 1 + b_dim1 * 1;
857 c_offset = 1 + c_dim1 * 1;
860 d_offset = 1 + d_dim1 * 1;
863 e_offset = 1 + e_dim1 * 1;
866 f_offset = 1 + f_dim1 * 1;
873 notran = lsame_(trans, "N");
874 if (! notran && ! lsame_(trans, "T")) {
877 if (*ijob < 0 || *ijob > 2) {
884 } else if (*n <= 0) {
886 } else if (*lda < f2cmax(1,*m)) {
888 } else if (*ldb < f2cmax(1,*n)) {
890 } else if (*ldc < f2cmax(1,*m)) {
892 } else if (*ldd < f2cmax(1,*m)) {
894 } else if (*lde < f2cmax(1,*n)) {
896 } else if (*ldf < f2cmax(1,*m)) {
902 xerbla_("DTGSY2", &i__1, (ftnlen)6);
906 /* Determine block structure of A */
920 if (a[i__ + 1 + i__ * a_dim1] != 0.) {
927 iwork[p + 1] = *m + 1;
929 /* Determine block structure of B */
942 if (b[j + 1 + j * b_dim1] != 0.) {
949 iwork[q + 1] = *n + 1;
950 *pq = p * (q - p - 1);
954 /* Solve (I, J) - subsystem */
955 /* A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J) */
956 /* D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J) */
957 /* for I = P, P - 1, ..., 1; J = 1, 2, ..., Q */
962 for (j = p + 2; j <= i__1; ++j) {
965 je = iwork[j + 1] - 1;
967 for (i__ = p; i__ >= 1; --i__) {
971 ie = iwork[i__ + 1] - 1;
975 if (mb == 1 && nb == 1) {
977 /* Build a 2-by-2 system Z * x = RHS */
979 z__[0] = a[is + is * a_dim1];
980 z__[1] = d__[is + is * d_dim1];
981 z__[8] = -b[js + js * b_dim1];
982 z__[9] = -e[js + js * e_dim1];
984 /* Set up right hand side(s) */
986 rhs[0] = c__[is + js * c_dim1];
987 rhs[1] = f[is + js * f_dim1];
989 /* Solve Z * x = RHS */
991 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
997 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1000 for (k = 1; k <= i__2; ++k) {
1001 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
1003 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1009 dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1013 /* Unpack solution vector(s) */
1015 c__[is + js * c_dim1] = rhs[0];
1016 f[is + js * f_dim1] = rhs[1];
1018 /* Substitute R(I, J) and L(I, J) into remaining */
1024 daxpy_(&i__2, &alpha, &a[is * a_dim1 + 1], &c__1, &
1025 c__[js * c_dim1 + 1], &c__1);
1027 daxpy_(&i__2, &alpha, &d__[is * d_dim1 + 1], &c__1, &
1028 f[js * f_dim1 + 1], &c__1);
1032 daxpy_(&i__2, &rhs[1], &b[js + (je + 1) * b_dim1],
1033 ldb, &c__[is + (je + 1) * c_dim1], ldc);
1035 daxpy_(&i__2, &rhs[1], &e[js + (je + 1) * e_dim1],
1036 lde, &f[is + (je + 1) * f_dim1], ldf);
1039 } else if (mb == 1 && nb == 2) {
1041 /* Build a 4-by-4 system Z * x = RHS */
1043 z__[0] = a[is + is * a_dim1];
1045 z__[2] = d__[is + is * d_dim1];
1049 z__[9] = a[is + is * a_dim1];
1051 z__[11] = d__[is + is * d_dim1];
1053 z__[16] = -b[js + js * b_dim1];
1054 z__[17] = -b[js + jsp1 * b_dim1];
1055 z__[18] = -e[js + js * e_dim1];
1056 z__[19] = -e[js + jsp1 * e_dim1];
1058 z__[24] = -b[jsp1 + js * b_dim1];
1059 z__[25] = -b[jsp1 + jsp1 * b_dim1];
1061 z__[27] = -e[jsp1 + jsp1 * e_dim1];
1063 /* Set up right hand side(s) */
1065 rhs[0] = c__[is + js * c_dim1];
1066 rhs[1] = c__[is + jsp1 * c_dim1];
1067 rhs[2] = f[is + js * f_dim1];
1068 rhs[3] = f[is + jsp1 * f_dim1];
1070 /* Solve Z * x = RHS */
1072 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1078 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1081 for (k = 1; k <= i__2; ++k) {
1082 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
1084 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1090 dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1094 /* Unpack solution vector(s) */
1096 c__[is + js * c_dim1] = rhs[0];
1097 c__[is + jsp1 * c_dim1] = rhs[1];
1098 f[is + js * f_dim1] = rhs[2];
1099 f[is + jsp1 * f_dim1] = rhs[3];
1101 /* Substitute R(I, J) and L(I, J) into remaining */
1106 dger_(&i__2, &nb, &c_b27, &a[is * a_dim1 + 1], &c__1,
1107 rhs, &c__1, &c__[js * c_dim1 + 1], ldc);
1109 dger_(&i__2, &nb, &c_b27, &d__[is * d_dim1 + 1], &
1110 c__1, rhs, &c__1, &f[js * f_dim1 + 1], ldf);
1114 daxpy_(&i__2, &rhs[2], &b[js + (je + 1) * b_dim1],
1115 ldb, &c__[is + (je + 1) * c_dim1], ldc);
1117 daxpy_(&i__2, &rhs[2], &e[js + (je + 1) * e_dim1],
1118 lde, &f[is + (je + 1) * f_dim1], ldf);
1120 daxpy_(&i__2, &rhs[3], &b[jsp1 + (je + 1) * b_dim1],
1121 ldb, &c__[is + (je + 1) * c_dim1], ldc);
1123 daxpy_(&i__2, &rhs[3], &e[jsp1 + (je + 1) * e_dim1],
1124 lde, &f[is + (je + 1) * f_dim1], ldf);
1127 } else if (mb == 2 && nb == 1) {
1129 /* Build a 4-by-4 system Z * x = RHS */
1131 z__[0] = a[is + is * a_dim1];
1132 z__[1] = a[isp1 + is * a_dim1];
1133 z__[2] = d__[is + is * d_dim1];
1136 z__[8] = a[is + isp1 * a_dim1];
1137 z__[9] = a[isp1 + isp1 * a_dim1];
1138 z__[10] = d__[is + isp1 * d_dim1];
1139 z__[11] = d__[isp1 + isp1 * d_dim1];
1141 z__[16] = -b[js + js * b_dim1];
1143 z__[18] = -e[js + js * e_dim1];
1147 z__[25] = -b[js + js * b_dim1];
1149 z__[27] = -e[js + js * e_dim1];
1151 /* Set up right hand side(s) */
1153 rhs[0] = c__[is + js * c_dim1];
1154 rhs[1] = c__[isp1 + js * c_dim1];
1155 rhs[2] = f[is + js * f_dim1];
1156 rhs[3] = f[isp1 + js * f_dim1];
1158 /* Solve Z * x = RHS */
1160 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1165 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1168 for (k = 1; k <= i__2; ++k) {
1169 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
1171 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1177 dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1181 /* Unpack solution vector(s) */
1183 c__[is + js * c_dim1] = rhs[0];
1184 c__[isp1 + js * c_dim1] = rhs[1];
1185 f[is + js * f_dim1] = rhs[2];
1186 f[isp1 + js * f_dim1] = rhs[3];
1188 /* Substitute R(I, J) and L(I, J) into remaining */
1193 dgemv_("N", &i__2, &mb, &c_b27, &a[is * a_dim1 + 1],
1194 lda, rhs, &c__1, &c_b42, &c__[js * c_dim1 + 1]
1197 dgemv_("N", &i__2, &mb, &c_b27, &d__[is * d_dim1 + 1],
1198 ldd, rhs, &c__1, &c_b42, &f[js * f_dim1 + 1],
1203 dger_(&mb, &i__2, &c_b42, &rhs[2], &c__1, &b[js + (je
1204 + 1) * b_dim1], ldb, &c__[is + (je + 1) *
1207 dger_(&mb, &i__2, &c_b42, &rhs[2], &c__1, &e[js + (je
1208 + 1) * e_dim1], lde, &f[is + (je + 1) *
1212 } else if (mb == 2 && nb == 2) {
1214 /* Build an 8-by-8 system Z * x = RHS */
1216 dlaset_("F", &c__8, &c__8, &c_b56, &c_b56, z__, &c__8);
1218 z__[0] = a[is + is * a_dim1];
1219 z__[1] = a[isp1 + is * a_dim1];
1220 z__[4] = d__[is + is * d_dim1];
1222 z__[8] = a[is + isp1 * a_dim1];
1223 z__[9] = a[isp1 + isp1 * a_dim1];
1224 z__[12] = d__[is + isp1 * d_dim1];
1225 z__[13] = d__[isp1 + isp1 * d_dim1];
1227 z__[18] = a[is + is * a_dim1];
1228 z__[19] = a[isp1 + is * a_dim1];
1229 z__[22] = d__[is + is * d_dim1];
1231 z__[26] = a[is + isp1 * a_dim1];
1232 z__[27] = a[isp1 + isp1 * a_dim1];
1233 z__[30] = d__[is + isp1 * d_dim1];
1234 z__[31] = d__[isp1 + isp1 * d_dim1];
1236 z__[32] = -b[js + js * b_dim1];
1237 z__[34] = -b[js + jsp1 * b_dim1];
1238 z__[36] = -e[js + js * e_dim1];
1239 z__[38] = -e[js + jsp1 * e_dim1];
1241 z__[41] = -b[js + js * b_dim1];
1242 z__[43] = -b[js + jsp1 * b_dim1];
1243 z__[45] = -e[js + js * e_dim1];
1244 z__[47] = -e[js + jsp1 * e_dim1];
1246 z__[48] = -b[jsp1 + js * b_dim1];
1247 z__[50] = -b[jsp1 + jsp1 * b_dim1];
1248 z__[54] = -e[jsp1 + jsp1 * e_dim1];
1250 z__[57] = -b[jsp1 + js * b_dim1];
1251 z__[59] = -b[jsp1 + jsp1 * b_dim1];
1252 z__[63] = -e[jsp1 + jsp1 * e_dim1];
1254 /* Set up right hand side(s) */
1259 for (jj = 0; jj <= i__2; ++jj) {
1260 dcopy_(&mb, &c__[is + (js + jj) * c_dim1], &c__1, &
1262 dcopy_(&mb, &f[is + (js + jj) * f_dim1], &c__1, &rhs[
1269 /* Solve Z * x = RHS */
1271 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1276 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1279 for (k = 1; k <= i__2; ++k) {
1280 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
1282 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1288 dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1292 /* Unpack solution vector(s) */
1297 for (jj = 0; jj <= i__2; ++jj) {
1298 dcopy_(&mb, &rhs[k - 1], &c__1, &c__[is + (js + jj) *
1300 dcopy_(&mb, &rhs[ii - 1], &c__1, &f[is + (js + jj) *
1307 /* Substitute R(I, J) and L(I, J) into remaining */
1312 dgemm_("N", "N", &i__2, &nb, &mb, &c_b27, &a[is *
1313 a_dim1 + 1], lda, rhs, &mb, &c_b42, &c__[js *
1316 dgemm_("N", "N", &i__2, &nb, &mb, &c_b27, &d__[is *
1317 d_dim1 + 1], ldd, rhs, &mb, &c_b42, &f[js *
1323 dgemm_("N", "N", &mb, &i__2, &nb, &c_b42, &rhs[k - 1],
1324 &mb, &b[js + (je + 1) * b_dim1], ldb, &c_b42,
1325 &c__[is + (je + 1) * c_dim1], ldc);
1327 dgemm_("N", "N", &mb, &i__2, &nb, &c_b42, &rhs[k - 1],
1328 &mb, &e[js + (je + 1) * e_dim1], lde, &c_b42,
1329 &f[is + (je + 1) * f_dim1], ldf);
1340 /* Solve (I, J) - subsystem */
1341 /* A(I, I)**T * R(I, J) + D(I, I)**T * L(J, J) = C(I, J) */
1342 /* R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J) */
1343 /* for I = 1, 2, ..., P, J = Q, Q - 1, ..., 1 */
1348 for (i__ = 1; i__ <= i__1; ++i__) {
1352 ie = iwork[i__ + 1] - 1;
1355 for (j = q; j >= i__2; --j) {
1359 je = iwork[j + 1] - 1;
1361 zdim = mb * nb << 1;
1362 if (mb == 1 && nb == 1) {
1364 /* Build a 2-by-2 system Z**T * x = RHS */
1366 z__[0] = a[is + is * a_dim1];
1367 z__[1] = -b[js + js * b_dim1];
1368 z__[8] = d__[is + is * d_dim1];
1369 z__[9] = -e[js + js * e_dim1];
1371 /* Set up right hand side(s) */
1373 rhs[0] = c__[is + js * c_dim1];
1374 rhs[1] = f[is + js * f_dim1];
1376 /* Solve Z**T * x = RHS */
1378 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1383 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1386 for (k = 1; k <= i__3; ++k) {
1387 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1388 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1394 /* Unpack solution vector(s) */
1396 c__[is + js * c_dim1] = rhs[0];
1397 f[is + js * f_dim1] = rhs[1];
1399 /* Substitute R(I, J) and L(I, J) into remaining */
1405 daxpy_(&i__3, &alpha, &b[js * b_dim1 + 1], &c__1, &f[
1409 daxpy_(&i__3, &alpha, &e[js * e_dim1 + 1], &c__1, &f[
1415 daxpy_(&i__3, &alpha, &a[is + (ie + 1) * a_dim1], lda,
1416 &c__[ie + 1 + js * c_dim1], &c__1);
1419 daxpy_(&i__3, &alpha, &d__[is + (ie + 1) * d_dim1],
1420 ldd, &c__[ie + 1 + js * c_dim1], &c__1);
1423 } else if (mb == 1 && nb == 2) {
1425 /* Build a 4-by-4 system Z**T * x = RHS */
1427 z__[0] = a[is + is * a_dim1];
1429 z__[2] = -b[js + js * b_dim1];
1430 z__[3] = -b[jsp1 + js * b_dim1];
1433 z__[9] = a[is + is * a_dim1];
1434 z__[10] = -b[js + jsp1 * b_dim1];
1435 z__[11] = -b[jsp1 + jsp1 * b_dim1];
1437 z__[16] = d__[is + is * d_dim1];
1439 z__[18] = -e[js + js * e_dim1];
1443 z__[25] = d__[is + is * d_dim1];
1444 z__[26] = -e[js + jsp1 * e_dim1];
1445 z__[27] = -e[jsp1 + jsp1 * e_dim1];
1447 /* Set up right hand side(s) */
1449 rhs[0] = c__[is + js * c_dim1];
1450 rhs[1] = c__[is + jsp1 * c_dim1];
1451 rhs[2] = f[is + js * f_dim1];
1452 rhs[3] = f[is + jsp1 * f_dim1];
1454 /* Solve Z**T * x = RHS */
1456 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1460 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1463 for (k = 1; k <= i__3; ++k) {
1464 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1465 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1471 /* Unpack solution vector(s) */
1473 c__[is + js * c_dim1] = rhs[0];
1474 c__[is + jsp1 * c_dim1] = rhs[1];
1475 f[is + js * f_dim1] = rhs[2];
1476 f[is + jsp1 * f_dim1] = rhs[3];
1478 /* Substitute R(I, J) and L(I, J) into remaining */
1483 daxpy_(&i__3, rhs, &b[js * b_dim1 + 1], &c__1, &f[is
1486 daxpy_(&i__3, &rhs[1], &b[jsp1 * b_dim1 + 1], &c__1, &
1487 f[is + f_dim1], ldf);
1489 daxpy_(&i__3, &rhs[2], &e[js * e_dim1 + 1], &c__1, &f[
1492 daxpy_(&i__3, &rhs[3], &e[jsp1 * e_dim1 + 1], &c__1, &
1493 f[is + f_dim1], ldf);
1497 dger_(&i__3, &nb, &c_b27, &a[is + (ie + 1) * a_dim1],
1498 lda, rhs, &c__1, &c__[ie + 1 + js * c_dim1],
1501 dger_(&i__3, &nb, &c_b27, &d__[is + (ie + 1) * d_dim1]
1502 , ldd, &rhs[2], &c__1, &c__[ie + 1 + js *
1506 } else if (mb == 2 && nb == 1) {
1508 /* Build a 4-by-4 system Z**T * x = RHS */
1510 z__[0] = a[is + is * a_dim1];
1511 z__[1] = a[is + isp1 * a_dim1];
1512 z__[2] = -b[js + js * b_dim1];
1515 z__[8] = a[isp1 + is * a_dim1];
1516 z__[9] = a[isp1 + isp1 * a_dim1];
1518 z__[11] = -b[js + js * b_dim1];
1520 z__[16] = d__[is + is * d_dim1];
1521 z__[17] = d__[is + isp1 * d_dim1];
1522 z__[18] = -e[js + js * e_dim1];
1526 z__[25] = d__[isp1 + isp1 * d_dim1];
1528 z__[27] = -e[js + js * e_dim1];
1530 /* Set up right hand side(s) */
1532 rhs[0] = c__[is + js * c_dim1];
1533 rhs[1] = c__[isp1 + js * c_dim1];
1534 rhs[2] = f[is + js * f_dim1];
1535 rhs[3] = f[isp1 + js * f_dim1];
1537 /* Solve Z**T * x = RHS */
1539 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1544 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1547 for (k = 1; k <= i__3; ++k) {
1548 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1549 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1555 /* Unpack solution vector(s) */
1557 c__[is + js * c_dim1] = rhs[0];
1558 c__[isp1 + js * c_dim1] = rhs[1];
1559 f[is + js * f_dim1] = rhs[2];
1560 f[isp1 + js * f_dim1] = rhs[3];
1562 /* Substitute R(I, J) and L(I, J) into remaining */
1567 dger_(&mb, &i__3, &c_b42, rhs, &c__1, &b[js * b_dim1
1568 + 1], &c__1, &f[is + f_dim1], ldf);
1570 dger_(&mb, &i__3, &c_b42, &rhs[2], &c__1, &e[js *
1571 e_dim1 + 1], &c__1, &f[is + f_dim1], ldf);
1575 dgemv_("T", &mb, &i__3, &c_b27, &a[is + (ie + 1) *
1576 a_dim1], lda, rhs, &c__1, &c_b42, &c__[ie + 1
1577 + js * c_dim1], &c__1);
1579 dgemv_("T", &mb, &i__3, &c_b27, &d__[is + (ie + 1) *
1580 d_dim1], ldd, &rhs[2], &c__1, &c_b42, &c__[ie
1581 + 1 + js * c_dim1], &c__1);
1584 } else if (mb == 2 && nb == 2) {
1586 /* Build an 8-by-8 system Z**T * x = RHS */
1588 dlaset_("F", &c__8, &c__8, &c_b56, &c_b56, z__, &c__8);
1590 z__[0] = a[is + is * a_dim1];
1591 z__[1] = a[is + isp1 * a_dim1];
1592 z__[4] = -b[js + js * b_dim1];
1593 z__[6] = -b[jsp1 + js * b_dim1];
1595 z__[8] = a[isp1 + is * a_dim1];
1596 z__[9] = a[isp1 + isp1 * a_dim1];
1597 z__[13] = -b[js + js * b_dim1];
1598 z__[15] = -b[jsp1 + js * b_dim1];
1600 z__[18] = a[is + is * a_dim1];
1601 z__[19] = a[is + isp1 * a_dim1];
1602 z__[20] = -b[js + jsp1 * b_dim1];
1603 z__[22] = -b[jsp1 + jsp1 * b_dim1];
1605 z__[26] = a[isp1 + is * a_dim1];
1606 z__[27] = a[isp1 + isp1 * a_dim1];
1607 z__[29] = -b[js + jsp1 * b_dim1];
1608 z__[31] = -b[jsp1 + jsp1 * b_dim1];
1610 z__[32] = d__[is + is * d_dim1];
1611 z__[33] = d__[is + isp1 * d_dim1];
1612 z__[36] = -e[js + js * e_dim1];
1614 z__[41] = d__[isp1 + isp1 * d_dim1];
1615 z__[45] = -e[js + js * e_dim1];
1617 z__[50] = d__[is + is * d_dim1];
1618 z__[51] = d__[is + isp1 * d_dim1];
1619 z__[52] = -e[js + jsp1 * e_dim1];
1620 z__[54] = -e[jsp1 + jsp1 * e_dim1];
1622 z__[59] = d__[isp1 + isp1 * d_dim1];
1623 z__[61] = -e[js + jsp1 * e_dim1];
1624 z__[63] = -e[jsp1 + jsp1 * e_dim1];
1626 /* Set up right hand side(s) */
1631 for (jj = 0; jj <= i__3; ++jj) {
1632 dcopy_(&mb, &c__[is + (js + jj) * c_dim1], &c__1, &
1634 dcopy_(&mb, &f[is + (js + jj) * f_dim1], &c__1, &rhs[
1642 /* Solve Z**T * x = RHS */
1644 dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1649 dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1652 for (k = 1; k <= i__3; ++k) {
1653 dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1654 dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1660 /* Unpack solution vector(s) */
1665 for (jj = 0; jj <= i__3; ++jj) {
1666 dcopy_(&mb, &rhs[k - 1], &c__1, &c__[is + (js + jj) *
1668 dcopy_(&mb, &rhs[ii - 1], &c__1, &f[is + (js + jj) *
1675 /* Substitute R(I, J) and L(I, J) into remaining */
1680 dgemm_("N", "T", &mb, &i__3, &nb, &c_b42, &c__[is +
1681 js * c_dim1], ldc, &b[js * b_dim1 + 1], ldb, &
1682 c_b42, &f[is + f_dim1], ldf);
1684 dgemm_("N", "T", &mb, &i__3, &nb, &c_b42, &f[is + js *
1685 f_dim1], ldf, &e[js * e_dim1 + 1], lde, &
1686 c_b42, &f[is + f_dim1], ldf);
1690 dgemm_("T", "N", &i__3, &nb, &mb, &c_b27, &a[is + (ie
1691 + 1) * a_dim1], lda, &c__[is + js * c_dim1],
1692 ldc, &c_b42, &c__[ie + 1 + js * c_dim1], ldc);
1694 dgemm_("T", "N", &i__3, &nb, &mb, &c_b27, &d__[is + (
1695 ie + 1) * d_dim1], ldd, &f[is + js * f_dim1],
1696 ldf, &c_b42, &c__[ie + 1 + js * c_dim1], ldc);