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 real c_b27 = -1.f;
518 static real c_b42 = 1.f;
519 static real c_b56 = 0.f;
521 /* > \brief \b STGSY2 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 STGSY2 + dependencies */
530 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/stgsy2.
533 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/stgsy2.
536 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/stgsy2.
544 /* SUBROUTINE STGSY2( 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 /* REAL RDSCAL, RDSUM, SCALE */
552 /* INTEGER IWORK( * ) */
553 /* REAL A( LDA, * ), B( LDB, * ), C( LDC, * ), */
554 /* $ D( LDD, * ), E( LDE, * ), F( LDF, * ) */
557 /* > \par Purpose: */
562 /* > STGSY2 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 SLACON. */
595 /* > STGSY2 also (IJOB >= 1) contributes to the computation in STGSYL */
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 /* > STGSYL. See STGSYL 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. (SGECON 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL */
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 REAL */
731 /* > On entry, the sum of squares of computed contributions to */
732 /* > the Dif-estimate under computation by STGSYL, 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 STGSY2 is called by STGSYL. */
740 /* > \param[in,out] RDSCAL */
742 /* > RDSCAL is REAL */
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 STGSY2 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 realSYauxiliary */
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 stgsy2_(char *trans, integer *ijob, integer *m, integer *
793 n, real *a, integer *lda, real *b, integer *ldb, real *c__, integer *
794 ldc, real *d__, integer *ldd, real *e, integer *lde, real *f, integer
795 *ldf, real *scale, real *rdsum, real *rdscal, integer *iwork, integer
798 /* System generated locals */
799 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1,
800 d_offset, e_dim1, e_offset, f_dim1, f_offset, i__1, i__2, i__3;
802 /* Local variables */
803 extern /* Subroutine */ int sger_(integer *, integer *, real *, real *,
804 integer *, real *, integer *, real *, integer *);
805 integer ierr, zdim, ipiv[8], jpiv[8], i__, j, k, p, q;
806 real alpha, z__[64] /* was [8][8] */;
807 extern logical lsame_(char *, char *);
808 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *),
809 sgemm_(char *, char *, integer *, integer *, integer *, real *,
810 real *, integer *, real *, integer *, real *, real *, integer *), sgemv_(char *, integer *, integer *, real *,
811 real *, integer *, real *, integer *, real *, real *, integer *), scopy_(integer *, real *, integer *, real *, integer *),
812 saxpy_(integer *, real *, real *, integer *, real *, integer *),
813 sgesc2_(integer *, real *, integer *, real *, integer *, integer *
814 , real *), sgetc2_(integer *, real *, integer *, integer *,
815 integer *, integer *);
816 integer ie, je, mb, nb, ii, jj, is, js;
818 extern /* Subroutine */ int slatdf_(integer *, integer *, real *, integer
819 *, real *, real *, real *, integer *, integer *), xerbla_(char *,
820 integer *, ftnlen), slaset_(char *, integer *, integer *, real *,
821 real *, real *, integer *);
827 /* -- LAPACK auxiliary routine (version 3.7.0) -- */
828 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
829 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
833 /* ===================================================================== */
834 /* Replaced various illegal calls to SCOPY by calls to SLASET. */
835 /* Sven Hammarling, 27/5/02. */
838 /* Decode and test input parameters */
840 /* Parameter adjustments */
842 a_offset = 1 + a_dim1 * 1;
845 b_offset = 1 + b_dim1 * 1;
848 c_offset = 1 + c_dim1 * 1;
851 d_offset = 1 + d_dim1 * 1;
854 e_offset = 1 + e_dim1 * 1;
857 f_offset = 1 + f_dim1 * 1;
864 notran = lsame_(trans, "N");
865 if (! notran && ! lsame_(trans, "T")) {
868 if (*ijob < 0 || *ijob > 2) {
875 } else if (*n <= 0) {
877 } else if (*lda < f2cmax(1,*m)) {
879 } else if (*ldb < f2cmax(1,*n)) {
881 } else if (*ldc < f2cmax(1,*m)) {
883 } else if (*ldd < f2cmax(1,*m)) {
885 } else if (*lde < f2cmax(1,*n)) {
887 } else if (*ldf < f2cmax(1,*m)) {
893 xerbla_("STGSY2", &i__1, (ftnlen)6);
897 /* Determine block structure of A */
911 if (a[i__ + 1 + i__ * a_dim1] != 0.f) {
918 iwork[p + 1] = *m + 1;
920 /* Determine block structure of B */
933 if (b[j + 1 + j * b_dim1] != 0.f) {
940 iwork[q + 1] = *n + 1;
941 *pq = p * (q - p - 1);
945 /* Solve (I, J) - subsystem */
946 /* A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J) */
947 /* D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J) */
948 /* for I = P, P - 1, ..., 1; J = 1, 2, ..., Q */
953 for (j = p + 2; j <= i__1; ++j) {
956 je = iwork[j + 1] - 1;
958 for (i__ = p; i__ >= 1; --i__) {
962 ie = iwork[i__ + 1] - 1;
966 if (mb == 1 && nb == 1) {
968 /* Build a 2-by-2 system Z * x = RHS */
970 z__[0] = a[is + is * a_dim1];
971 z__[1] = d__[is + is * d_dim1];
972 z__[8] = -b[js + js * b_dim1];
973 z__[9] = -e[js + js * e_dim1];
975 /* Set up right hand side(s) */
977 rhs[0] = c__[is + js * c_dim1];
978 rhs[1] = f[is + js * f_dim1];
980 /* Solve Z * x = RHS */
982 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
988 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
991 for (k = 1; k <= i__2; ++k) {
992 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
994 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1000 slatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1004 /* Unpack solution vector(s) */
1006 c__[is + js * c_dim1] = rhs[0];
1007 f[is + js * f_dim1] = rhs[1];
1009 /* Substitute R(I, J) and L(I, J) into remaining */
1015 saxpy_(&i__2, &alpha, &a[is * a_dim1 + 1], &c__1, &
1016 c__[js * c_dim1 + 1], &c__1);
1018 saxpy_(&i__2, &alpha, &d__[is * d_dim1 + 1], &c__1, &
1019 f[js * f_dim1 + 1], &c__1);
1023 saxpy_(&i__2, &rhs[1], &b[js + (je + 1) * b_dim1],
1024 ldb, &c__[is + (je + 1) * c_dim1], ldc);
1026 saxpy_(&i__2, &rhs[1], &e[js + (je + 1) * e_dim1],
1027 lde, &f[is + (je + 1) * f_dim1], ldf);
1030 } else if (mb == 1 && nb == 2) {
1032 /* Build a 4-by-4 system Z * x = RHS */
1034 z__[0] = a[is + is * a_dim1];
1036 z__[2] = d__[is + is * d_dim1];
1040 z__[9] = a[is + is * a_dim1];
1042 z__[11] = d__[is + is * d_dim1];
1044 z__[16] = -b[js + js * b_dim1];
1045 z__[17] = -b[js + jsp1 * b_dim1];
1046 z__[18] = -e[js + js * e_dim1];
1047 z__[19] = -e[js + jsp1 * e_dim1];
1049 z__[24] = -b[jsp1 + js * b_dim1];
1050 z__[25] = -b[jsp1 + jsp1 * b_dim1];
1052 z__[27] = -e[jsp1 + jsp1 * e_dim1];
1054 /* Set up right hand side(s) */
1056 rhs[0] = c__[is + js * c_dim1];
1057 rhs[1] = c__[is + jsp1 * c_dim1];
1058 rhs[2] = f[is + js * f_dim1];
1059 rhs[3] = f[is + jsp1 * f_dim1];
1061 /* Solve Z * x = RHS */
1063 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1069 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1070 if (scaloc != 1.f) {
1072 for (k = 1; k <= i__2; ++k) {
1073 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
1075 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1081 slatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1085 /* Unpack solution vector(s) */
1087 c__[is + js * c_dim1] = rhs[0];
1088 c__[is + jsp1 * c_dim1] = rhs[1];
1089 f[is + js * f_dim1] = rhs[2];
1090 f[is + jsp1 * f_dim1] = rhs[3];
1092 /* Substitute R(I, J) and L(I, J) into remaining */
1097 sger_(&i__2, &nb, &c_b27, &a[is * a_dim1 + 1], &c__1,
1098 rhs, &c__1, &c__[js * c_dim1 + 1], ldc);
1100 sger_(&i__2, &nb, &c_b27, &d__[is * d_dim1 + 1], &
1101 c__1, rhs, &c__1, &f[js * f_dim1 + 1], ldf);
1105 saxpy_(&i__2, &rhs[2], &b[js + (je + 1) * b_dim1],
1106 ldb, &c__[is + (je + 1) * c_dim1], ldc);
1108 saxpy_(&i__2, &rhs[2], &e[js + (je + 1) * e_dim1],
1109 lde, &f[is + (je + 1) * f_dim1], ldf);
1111 saxpy_(&i__2, &rhs[3], &b[jsp1 + (je + 1) * b_dim1],
1112 ldb, &c__[is + (je + 1) * c_dim1], ldc);
1114 saxpy_(&i__2, &rhs[3], &e[jsp1 + (je + 1) * e_dim1],
1115 lde, &f[is + (je + 1) * f_dim1], ldf);
1118 } else if (mb == 2 && nb == 1) {
1120 /* Build a 4-by-4 system Z * x = RHS */
1122 z__[0] = a[is + is * a_dim1];
1123 z__[1] = a[isp1 + is * a_dim1];
1124 z__[2] = d__[is + is * d_dim1];
1127 z__[8] = a[is + isp1 * a_dim1];
1128 z__[9] = a[isp1 + isp1 * a_dim1];
1129 z__[10] = d__[is + isp1 * d_dim1];
1130 z__[11] = d__[isp1 + isp1 * d_dim1];
1132 z__[16] = -b[js + js * b_dim1];
1134 z__[18] = -e[js + js * e_dim1];
1138 z__[25] = -b[js + js * b_dim1];
1140 z__[27] = -e[js + js * e_dim1];
1142 /* Set up right hand side(s) */
1144 rhs[0] = c__[is + js * c_dim1];
1145 rhs[1] = c__[isp1 + js * c_dim1];
1146 rhs[2] = f[is + js * f_dim1];
1147 rhs[3] = f[isp1 + js * f_dim1];
1149 /* Solve Z * x = RHS */
1151 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1156 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1157 if (scaloc != 1.f) {
1159 for (k = 1; k <= i__2; ++k) {
1160 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
1162 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1168 slatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1172 /* Unpack solution vector(s) */
1174 c__[is + js * c_dim1] = rhs[0];
1175 c__[isp1 + js * c_dim1] = rhs[1];
1176 f[is + js * f_dim1] = rhs[2];
1177 f[isp1 + js * f_dim1] = rhs[3];
1179 /* Substitute R(I, J) and L(I, J) into remaining */
1184 sgemv_("N", &i__2, &mb, &c_b27, &a[is * a_dim1 + 1],
1185 lda, rhs, &c__1, &c_b42, &c__[js * c_dim1 + 1]
1188 sgemv_("N", &i__2, &mb, &c_b27, &d__[is * d_dim1 + 1],
1189 ldd, rhs, &c__1, &c_b42, &f[js * f_dim1 + 1],
1194 sger_(&mb, &i__2, &c_b42, &rhs[2], &c__1, &b[js + (je
1195 + 1) * b_dim1], ldb, &c__[is + (je + 1) *
1198 sger_(&mb, &i__2, &c_b42, &rhs[2], &c__1, &e[js + (je
1199 + 1) * e_dim1], lde, &f[is + (je + 1) *
1203 } else if (mb == 2 && nb == 2) {
1205 /* Build an 8-by-8 system Z * x = RHS */
1207 slaset_("F", &c__8, &c__8, &c_b56, &c_b56, z__, &c__8);
1209 z__[0] = a[is + is * a_dim1];
1210 z__[1] = a[isp1 + is * a_dim1];
1211 z__[4] = d__[is + is * d_dim1];
1213 z__[8] = a[is + isp1 * a_dim1];
1214 z__[9] = a[isp1 + isp1 * a_dim1];
1215 z__[12] = d__[is + isp1 * d_dim1];
1216 z__[13] = d__[isp1 + isp1 * d_dim1];
1218 z__[18] = a[is + is * a_dim1];
1219 z__[19] = a[isp1 + is * a_dim1];
1220 z__[22] = d__[is + is * d_dim1];
1222 z__[26] = a[is + isp1 * a_dim1];
1223 z__[27] = a[isp1 + isp1 * a_dim1];
1224 z__[30] = d__[is + isp1 * d_dim1];
1225 z__[31] = d__[isp1 + isp1 * d_dim1];
1227 z__[32] = -b[js + js * b_dim1];
1228 z__[34] = -b[js + jsp1 * b_dim1];
1229 z__[36] = -e[js + js * e_dim1];
1230 z__[38] = -e[js + jsp1 * e_dim1];
1232 z__[41] = -b[js + js * b_dim1];
1233 z__[43] = -b[js + jsp1 * b_dim1];
1234 z__[45] = -e[js + js * e_dim1];
1235 z__[47] = -e[js + jsp1 * e_dim1];
1237 z__[48] = -b[jsp1 + js * b_dim1];
1238 z__[50] = -b[jsp1 + jsp1 * b_dim1];
1239 z__[54] = -e[jsp1 + jsp1 * e_dim1];
1241 z__[57] = -b[jsp1 + js * b_dim1];
1242 z__[59] = -b[jsp1 + jsp1 * b_dim1];
1243 z__[63] = -e[jsp1 + jsp1 * e_dim1];
1245 /* Set up right hand side(s) */
1250 for (jj = 0; jj <= i__2; ++jj) {
1251 scopy_(&mb, &c__[is + (js + jj) * c_dim1], &c__1, &
1253 scopy_(&mb, &f[is + (js + jj) * f_dim1], &c__1, &rhs[
1260 /* Solve Z * x = RHS */
1262 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1267 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1268 if (scaloc != 1.f) {
1270 for (k = 1; k <= i__2; ++k) {
1271 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
1273 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1279 slatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
1283 /* Unpack solution vector(s) */
1288 for (jj = 0; jj <= i__2; ++jj) {
1289 scopy_(&mb, &rhs[k - 1], &c__1, &c__[is + (js + jj) *
1291 scopy_(&mb, &rhs[ii - 1], &c__1, &f[is + (js + jj) *
1298 /* Substitute R(I, J) and L(I, J) into remaining */
1303 sgemm_("N", "N", &i__2, &nb, &mb, &c_b27, &a[is *
1304 a_dim1 + 1], lda, rhs, &mb, &c_b42, &c__[js *
1307 sgemm_("N", "N", &i__2, &nb, &mb, &c_b27, &d__[is *
1308 d_dim1 + 1], ldd, rhs, &mb, &c_b42, &f[js *
1314 sgemm_("N", "N", &mb, &i__2, &nb, &c_b42, &rhs[k - 1],
1315 &mb, &b[js + (je + 1) * b_dim1], ldb, &c_b42,
1316 &c__[is + (je + 1) * c_dim1], ldc);
1318 sgemm_("N", "N", &mb, &i__2, &nb, &c_b42, &rhs[k - 1],
1319 &mb, &e[js + (je + 1) * e_dim1], lde, &c_b42,
1320 &f[is + (je + 1) * f_dim1], ldf);
1331 /* Solve (I, J) - subsystem */
1332 /* A(I, I)**T * R(I, J) + D(I, I)**T * L(J, J) = C(I, J) */
1333 /* R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J) */
1334 /* for I = 1, 2, ..., P, J = Q, Q - 1, ..., 1 */
1339 for (i__ = 1; i__ <= i__1; ++i__) {
1343 ie = iwork[i__ + 1] - 1;
1346 for (j = q; j >= i__2; --j) {
1350 je = iwork[j + 1] - 1;
1352 zdim = mb * nb << 1;
1353 if (mb == 1 && nb == 1) {
1355 /* Build a 2-by-2 system Z**T * x = RHS */
1357 z__[0] = a[is + is * a_dim1];
1358 z__[1] = -b[js + js * b_dim1];
1359 z__[8] = d__[is + is * d_dim1];
1360 z__[9] = -e[js + js * e_dim1];
1362 /* Set up right hand side(s) */
1364 rhs[0] = c__[is + js * c_dim1];
1365 rhs[1] = f[is + js * f_dim1];
1367 /* Solve Z**T * x = RHS */
1369 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1374 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1375 if (scaloc != 1.f) {
1377 for (k = 1; k <= i__3; ++k) {
1378 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1379 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1385 /* Unpack solution vector(s) */
1387 c__[is + js * c_dim1] = rhs[0];
1388 f[is + js * f_dim1] = rhs[1];
1390 /* Substitute R(I, J) and L(I, J) into remaining */
1396 saxpy_(&i__3, &alpha, &b[js * b_dim1 + 1], &c__1, &f[
1400 saxpy_(&i__3, &alpha, &e[js * e_dim1 + 1], &c__1, &f[
1406 saxpy_(&i__3, &alpha, &a[is + (ie + 1) * a_dim1], lda,
1407 &c__[ie + 1 + js * c_dim1], &c__1);
1410 saxpy_(&i__3, &alpha, &d__[is + (ie + 1) * d_dim1],
1411 ldd, &c__[ie + 1 + js * c_dim1], &c__1);
1414 } else if (mb == 1 && nb == 2) {
1416 /* Build a 4-by-4 system Z**T * x = RHS */
1418 z__[0] = a[is + is * a_dim1];
1420 z__[2] = -b[js + js * b_dim1];
1421 z__[3] = -b[jsp1 + js * b_dim1];
1424 z__[9] = a[is + is * a_dim1];
1425 z__[10] = -b[js + jsp1 * b_dim1];
1426 z__[11] = -b[jsp1 + jsp1 * b_dim1];
1428 z__[16] = d__[is + is * d_dim1];
1430 z__[18] = -e[js + js * e_dim1];
1434 z__[25] = d__[is + is * d_dim1];
1435 z__[26] = -e[js + jsp1 * e_dim1];
1436 z__[27] = -e[jsp1 + jsp1 * e_dim1];
1438 /* Set up right hand side(s) */
1440 rhs[0] = c__[is + js * c_dim1];
1441 rhs[1] = c__[is + jsp1 * c_dim1];
1442 rhs[2] = f[is + js * f_dim1];
1443 rhs[3] = f[is + jsp1 * f_dim1];
1445 /* Solve Z**T * x = RHS */
1447 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1451 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1452 if (scaloc != 1.f) {
1454 for (k = 1; k <= i__3; ++k) {
1455 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1456 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1462 /* Unpack solution vector(s) */
1464 c__[is + js * c_dim1] = rhs[0];
1465 c__[is + jsp1 * c_dim1] = rhs[1];
1466 f[is + js * f_dim1] = rhs[2];
1467 f[is + jsp1 * f_dim1] = rhs[3];
1469 /* Substitute R(I, J) and L(I, J) into remaining */
1474 saxpy_(&i__3, rhs, &b[js * b_dim1 + 1], &c__1, &f[is
1477 saxpy_(&i__3, &rhs[1], &b[jsp1 * b_dim1 + 1], &c__1, &
1478 f[is + f_dim1], ldf);
1480 saxpy_(&i__3, &rhs[2], &e[js * e_dim1 + 1], &c__1, &f[
1483 saxpy_(&i__3, &rhs[3], &e[jsp1 * e_dim1 + 1], &c__1, &
1484 f[is + f_dim1], ldf);
1488 sger_(&i__3, &nb, &c_b27, &a[is + (ie + 1) * a_dim1],
1489 lda, rhs, &c__1, &c__[ie + 1 + js * c_dim1],
1492 sger_(&i__3, &nb, &c_b27, &d__[is + (ie + 1) * d_dim1]
1493 , ldd, &rhs[2], &c__1, &c__[ie + 1 + js *
1497 } else if (mb == 2 && nb == 1) {
1499 /* Build a 4-by-4 system Z**T * x = RHS */
1501 z__[0] = a[is + is * a_dim1];
1502 z__[1] = a[is + isp1 * a_dim1];
1503 z__[2] = -b[js + js * b_dim1];
1506 z__[8] = a[isp1 + is * a_dim1];
1507 z__[9] = a[isp1 + isp1 * a_dim1];
1509 z__[11] = -b[js + js * b_dim1];
1511 z__[16] = d__[is + is * d_dim1];
1512 z__[17] = d__[is + isp1 * d_dim1];
1513 z__[18] = -e[js + js * e_dim1];
1517 z__[25] = d__[isp1 + isp1 * d_dim1];
1519 z__[27] = -e[js + js * e_dim1];
1521 /* Set up right hand side(s) */
1523 rhs[0] = c__[is + js * c_dim1];
1524 rhs[1] = c__[isp1 + js * c_dim1];
1525 rhs[2] = f[is + js * f_dim1];
1526 rhs[3] = f[isp1 + js * f_dim1];
1528 /* Solve Z**T * x = RHS */
1530 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1535 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1536 if (scaloc != 1.f) {
1538 for (k = 1; k <= i__3; ++k) {
1539 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1540 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1546 /* Unpack solution vector(s) */
1548 c__[is + js * c_dim1] = rhs[0];
1549 c__[isp1 + js * c_dim1] = rhs[1];
1550 f[is + js * f_dim1] = rhs[2];
1551 f[isp1 + js * f_dim1] = rhs[3];
1553 /* Substitute R(I, J) and L(I, J) into remaining */
1558 sger_(&mb, &i__3, &c_b42, rhs, &c__1, &b[js * b_dim1
1559 + 1], &c__1, &f[is + f_dim1], ldf);
1561 sger_(&mb, &i__3, &c_b42, &rhs[2], &c__1, &e[js *
1562 e_dim1 + 1], &c__1, &f[is + f_dim1], ldf);
1566 sgemv_("T", &mb, &i__3, &c_b27, &a[is + (ie + 1) *
1567 a_dim1], lda, rhs, &c__1, &c_b42, &c__[ie + 1
1568 + js * c_dim1], &c__1);
1570 sgemv_("T", &mb, &i__3, &c_b27, &d__[is + (ie + 1) *
1571 d_dim1], ldd, &rhs[2], &c__1, &c_b42, &c__[ie
1572 + 1 + js * c_dim1], &c__1);
1575 } else if (mb == 2 && nb == 2) {
1577 /* Build an 8-by-8 system Z**T * x = RHS */
1579 slaset_("F", &c__8, &c__8, &c_b56, &c_b56, z__, &c__8);
1581 z__[0] = a[is + is * a_dim1];
1582 z__[1] = a[is + isp1 * a_dim1];
1583 z__[4] = -b[js + js * b_dim1];
1584 z__[6] = -b[jsp1 + js * b_dim1];
1586 z__[8] = a[isp1 + is * a_dim1];
1587 z__[9] = a[isp1 + isp1 * a_dim1];
1588 z__[13] = -b[js + js * b_dim1];
1589 z__[15] = -b[jsp1 + js * b_dim1];
1591 z__[18] = a[is + is * a_dim1];
1592 z__[19] = a[is + isp1 * a_dim1];
1593 z__[20] = -b[js + jsp1 * b_dim1];
1594 z__[22] = -b[jsp1 + jsp1 * b_dim1];
1596 z__[26] = a[isp1 + is * a_dim1];
1597 z__[27] = a[isp1 + isp1 * a_dim1];
1598 z__[29] = -b[js + jsp1 * b_dim1];
1599 z__[31] = -b[jsp1 + jsp1 * b_dim1];
1601 z__[32] = d__[is + is * d_dim1];
1602 z__[33] = d__[is + isp1 * d_dim1];
1603 z__[36] = -e[js + js * e_dim1];
1605 z__[41] = d__[isp1 + isp1 * d_dim1];
1606 z__[45] = -e[js + js * e_dim1];
1608 z__[50] = d__[is + is * d_dim1];
1609 z__[51] = d__[is + isp1 * d_dim1];
1610 z__[52] = -e[js + jsp1 * e_dim1];
1611 z__[54] = -e[jsp1 + jsp1 * e_dim1];
1613 z__[59] = d__[isp1 + isp1 * d_dim1];
1614 z__[61] = -e[js + jsp1 * e_dim1];
1615 z__[63] = -e[jsp1 + jsp1 * e_dim1];
1617 /* Set up right hand side(s) */
1622 for (jj = 0; jj <= i__3; ++jj) {
1623 scopy_(&mb, &c__[is + (js + jj) * c_dim1], &c__1, &
1625 scopy_(&mb, &f[is + (js + jj) * f_dim1], &c__1, &rhs[
1633 /* Solve Z**T * x = RHS */
1635 sgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
1640 sgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
1641 if (scaloc != 1.f) {
1643 for (k = 1; k <= i__3; ++k) {
1644 sscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
1645 sscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
1651 /* Unpack solution vector(s) */
1656 for (jj = 0; jj <= i__3; ++jj) {
1657 scopy_(&mb, &rhs[k - 1], &c__1, &c__[is + (js + jj) *
1659 scopy_(&mb, &rhs[ii - 1], &c__1, &f[is + (js + jj) *
1666 /* Substitute R(I, J) and L(I, J) into remaining */
1671 sgemm_("N", "T", &mb, &i__3, &nb, &c_b42, &c__[is +
1672 js * c_dim1], ldc, &b[js * b_dim1 + 1], ldb, &
1673 c_b42, &f[is + f_dim1], ldf);
1675 sgemm_("N", "T", &mb, &i__3, &nb, &c_b42, &f[is + js *
1676 f_dim1], ldf, &e[js * e_dim1 + 1], lde, &
1677 c_b42, &f[is + f_dim1], ldf);
1681 sgemm_("T", "N", &i__3, &nb, &mb, &c_b27, &a[is + (ie
1682 + 1) * a_dim1], lda, &c__[is + js * c_dim1],
1683 ldc, &c_b42, &c__[ie + 1 + js * c_dim1], ldc);
1685 sgemm_("T", "N", &i__3, &nb, &mb, &c_b27, &d__[is + (
1686 ie + 1) * d_dim1], ldd, &f[is + js * f_dim1],
1687 ldf, &c_b42, &c__[ie + 1 + js * c_dim1], ldc);