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__1 = 1;
517 /* > \brief \b CTRSYL */
519 /* =========== DOCUMENTATION =========== */
521 /* Online html documentation available at */
522 /* http://www.netlib.org/lapack/explore-html/ */
525 /* > Download CTRSYL + dependencies */
526 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctrsyl.
529 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctrsyl.
532 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctrsyl.
540 /* SUBROUTINE CTRSYL( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C, */
541 /* LDC, SCALE, INFO ) */
543 /* CHARACTER TRANA, TRANB */
544 /* INTEGER INFO, ISGN, LDA, LDB, LDC, M, N */
546 /* COMPLEX A( LDA, * ), B( LDB, * ), C( LDC, * ) */
549 /* > \par Purpose: */
554 /* > CTRSYL solves the complex Sylvester matrix equation: */
556 /* > op(A)*X + X*op(B) = scale*C or */
557 /* > op(A)*X - X*op(B) = scale*C, */
559 /* > where op(A) = A or A**H, and A and B are both upper triangular. A is */
560 /* > M-by-M and B is N-by-N; the right hand side C and the solution X are */
561 /* > M-by-N; and scale is an output scale factor, set <= 1 to avoid */
562 /* > overflow in X. */
568 /* > \param[in] TRANA */
570 /* > TRANA is CHARACTER*1 */
571 /* > Specifies the option op(A): */
572 /* > = 'N': op(A) = A (No transpose) */
573 /* > = 'C': op(A) = A**H (Conjugate transpose) */
576 /* > \param[in] TRANB */
578 /* > TRANB is CHARACTER*1 */
579 /* > Specifies the option op(B): */
580 /* > = 'N': op(B) = B (No transpose) */
581 /* > = 'C': op(B) = B**H (Conjugate transpose) */
584 /* > \param[in] ISGN */
586 /* > ISGN is INTEGER */
587 /* > Specifies the sign in the equation: */
588 /* > = +1: solve op(A)*X + X*op(B) = scale*C */
589 /* > = -1: solve op(A)*X - X*op(B) = scale*C */
595 /* > The order of the matrix A, and the number of rows in the */
596 /* > matrices X and C. M >= 0. */
602 /* > The order of the matrix B, and the number of columns in the */
603 /* > matrices X and C. N >= 0. */
608 /* > A is COMPLEX array, dimension (LDA,M) */
609 /* > The upper triangular matrix A. */
612 /* > \param[in] LDA */
614 /* > LDA is INTEGER */
615 /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */
620 /* > B is COMPLEX array, dimension (LDB,N) */
621 /* > The upper triangular matrix B. */
624 /* > \param[in] LDB */
626 /* > LDB is INTEGER */
627 /* > The leading dimension of the array B. LDB >= f2cmax(1,N). */
630 /* > \param[in,out] C */
632 /* > C is COMPLEX array, dimension (LDC,N) */
633 /* > On entry, the M-by-N right hand side matrix C. */
634 /* > On exit, C is overwritten by the solution matrix X. */
637 /* > \param[in] LDC */
639 /* > LDC is INTEGER */
640 /* > The leading dimension of the array C. LDC >= f2cmax(1,M) */
643 /* > \param[out] SCALE */
645 /* > SCALE is REAL */
646 /* > The scale factor, scale, set <= 1 to avoid overflow in X. */
649 /* > \param[out] INFO */
651 /* > INFO is INTEGER */
652 /* > = 0: successful exit */
653 /* > < 0: if INFO = -i, the i-th argument had an illegal value */
654 /* > = 1: A and B have common or very close eigenvalues; perturbed */
655 /* > values were used to solve the equation (but the matrices */
656 /* > A and B are unchanged). */
662 /* > \author Univ. of Tennessee */
663 /* > \author Univ. of California Berkeley */
664 /* > \author Univ. of Colorado Denver */
665 /* > \author NAG Ltd. */
667 /* > \date December 2016 */
669 /* > \ingroup complexSYcomputational */
671 /* ===================================================================== */
672 /* Subroutine */ int ctrsyl_(char *trana, char *tranb, integer *isgn, integer
673 *m, integer *n, complex *a, integer *lda, complex *b, integer *ldb,
674 complex *c__, integer *ldc, real *scale, integer *info)
676 /* System generated locals */
677 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, i__1, i__2,
680 complex q__1, q__2, q__3, q__4;
682 /* Local variables */
686 extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer
687 *, complex *, integer *);
688 extern logical lsame_(char *, char *);
689 extern /* Complex */ VOID cdotu_(complex *, integer *, complex *, integer
690 *, complex *, integer *);
693 extern /* Subroutine */ int slabad_(real *, real *);
694 extern real clange_(char *, integer *, integer *, complex *, integer *,
697 extern /* Complex */ VOID cladiv_(complex *, complex *, complex *);
699 extern real slamch_(char *);
700 extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer
701 *), xerbla_(char *, integer *, ftnlen);
703 logical notrna, notrnb;
706 real dum[1], eps, sgn;
709 /* -- LAPACK computational routine (version 3.7.0) -- */
710 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
711 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
715 /* ===================================================================== */
718 /* Decode and Test input parameters */
720 /* Parameter adjustments */
722 a_offset = 1 + a_dim1 * 1;
725 b_offset = 1 + b_dim1 * 1;
728 c_offset = 1 + c_dim1 * 1;
732 notrna = lsame_(trana, "N");
733 notrnb = lsame_(tranb, "N");
736 if (! notrna && ! lsame_(trana, "C")) {
738 } else if (! notrnb && ! lsame_(tranb, "C")) {
740 } else if (*isgn != 1 && *isgn != -1) {
746 } else if (*lda < f2cmax(1,*m)) {
748 } else if (*ldb < f2cmax(1,*n)) {
750 } else if (*ldc < f2cmax(1,*m)) {
755 xerbla_("CTRSYL", &i__1, (ftnlen)6);
759 /* Quick return if possible */
762 if (*m == 0 || *n == 0) {
766 /* Set constants to control overflow */
769 smlnum = slamch_("S");
770 bignum = 1.f / smlnum;
771 slabad_(&smlnum, &bignum);
772 smlnum = smlnum * (real) (*m * *n) / eps;
773 bignum = 1.f / smlnum;
775 r__1 = smlnum, r__2 = eps * clange_("M", m, m, &a[a_offset], lda, dum), r__1 = f2cmax(r__1,r__2), r__2 = eps * clange_("M", n, n,
776 &b[b_offset], ldb, dum);
777 smin = f2cmax(r__1,r__2);
778 sgn = (real) (*isgn);
780 if (notrna && notrnb) {
782 /* Solve A*X + ISGN*X*B = scale*C. */
784 /* The (K,L)th block of X is determined starting from */
785 /* bottom-left corner column by column by */
787 /* A(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L) */
791 /* R(K,L) = SUM [A(K,I)*X(I,L)] +ISGN*SUM [X(K,J)*B(J,L)]. */
795 for (l = 1; l <= i__1; ++l) {
796 for (k = *m; k >= 1; --k) {
803 cdotu_(&q__1, &i__2, &a[k + f2cmin(i__3,*m) * a_dim1], lda, &c__[
804 f2cmin(i__4,*m) + l * c_dim1], &c__1);
805 suml.r = q__1.r, suml.i = q__1.i;
807 cdotu_(&q__1, &i__2, &c__[k + c_dim1], ldc, &b[l * b_dim1 + 1]
809 sumr.r = q__1.r, sumr.i = q__1.i;
810 i__2 = k + l * c_dim1;
811 q__3.r = sgn * sumr.r, q__3.i = sgn * sumr.i;
812 q__2.r = suml.r + q__3.r, q__2.i = suml.i + q__3.i;
813 q__1.r = c__[i__2].r - q__2.r, q__1.i = c__[i__2].i - q__2.i;
814 vec.r = q__1.r, vec.i = q__1.i;
817 i__2 = k + k * a_dim1;
818 i__3 = l + l * b_dim1;
819 q__2.r = sgn * b[i__3].r, q__2.i = sgn * b[i__3].i;
820 q__1.r = a[i__2].r + q__2.r, q__1.i = a[i__2].i + q__2.i;
821 a11.r = q__1.r, a11.i = q__1.i;
822 da11 = (r__1 = a11.r, abs(r__1)) + (r__2 = r_imag(&a11), abs(
825 a11.r = smin, a11.i = 0.f;
829 db = (r__1 = vec.r, abs(r__1)) + (r__2 = r_imag(&vec), abs(
831 if (da11 < 1.f && db > 1.f) {
832 if (db > bignum * da11) {
836 q__3.r = scaloc, q__3.i = 0.f;
837 q__2.r = vec.r * q__3.r - vec.i * q__3.i, q__2.i = vec.r *
838 q__3.i + vec.i * q__3.r;
839 cladiv_(&q__1, &q__2, &a11);
840 x11.r = q__1.r, x11.i = q__1.i;
844 for (j = 1; j <= i__2; ++j) {
845 csscal_(m, &scaloc, &c__[j * c_dim1 + 1], &c__1);
850 i__2 = k + l * c_dim1;
851 c__[i__2].r = x11.r, c__[i__2].i = x11.i;
858 } else if (! notrna && notrnb) {
860 /* Solve A**H *X + ISGN*X*B = scale*C. */
862 /* The (K,L)th block of X is determined starting from */
863 /* upper-left corner column by column by */
865 /* A**H(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L) */
869 /* R(K,L) = SUM [A**H(I,K)*X(I,L)] + ISGN*SUM [X(K,J)*B(J,L)] */
873 for (l = 1; l <= i__1; ++l) {
875 for (k = 1; k <= i__2; ++k) {
878 cdotc_(&q__1, &i__3, &a[k * a_dim1 + 1], &c__1, &c__[l *
880 suml.r = q__1.r, suml.i = q__1.i;
882 cdotu_(&q__1, &i__3, &c__[k + c_dim1], ldc, &b[l * b_dim1 + 1]
884 sumr.r = q__1.r, sumr.i = q__1.i;
885 i__3 = k + l * c_dim1;
886 q__3.r = sgn * sumr.r, q__3.i = sgn * sumr.i;
887 q__2.r = suml.r + q__3.r, q__2.i = suml.i + q__3.i;
888 q__1.r = c__[i__3].r - q__2.r, q__1.i = c__[i__3].i - q__2.i;
889 vec.r = q__1.r, vec.i = q__1.i;
892 r_cnjg(&q__2, &a[k + k * a_dim1]);
893 i__3 = l + l * b_dim1;
894 q__3.r = sgn * b[i__3].r, q__3.i = sgn * b[i__3].i;
895 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
896 a11.r = q__1.r, a11.i = q__1.i;
897 da11 = (r__1 = a11.r, abs(r__1)) + (r__2 = r_imag(&a11), abs(
900 a11.r = smin, a11.i = 0.f;
904 db = (r__1 = vec.r, abs(r__1)) + (r__2 = r_imag(&vec), abs(
906 if (da11 < 1.f && db > 1.f) {
907 if (db > bignum * da11) {
912 q__3.r = scaloc, q__3.i = 0.f;
913 q__2.r = vec.r * q__3.r - vec.i * q__3.i, q__2.i = vec.r *
914 q__3.i + vec.i * q__3.r;
915 cladiv_(&q__1, &q__2, &a11);
916 x11.r = q__1.r, x11.i = q__1.i;
920 for (j = 1; j <= i__3; ++j) {
921 csscal_(m, &scaloc, &c__[j * c_dim1 + 1], &c__1);
926 i__3 = k + l * c_dim1;
927 c__[i__3].r = x11.r, c__[i__3].i = x11.i;
934 } else if (! notrna && ! notrnb) {
936 /* Solve A**H*X + ISGN*X*B**H = C. */
938 /* The (K,L)th block of X is determined starting from */
939 /* upper-right corner column by column by */
941 /* A**H(K,K)*X(K,L) + ISGN*X(K,L)*B**H(L,L) = C(K,L) - R(K,L) */
945 /* R(K,L) = SUM [A**H(I,K)*X(I,L)] + */
948 /* ISGN*SUM [X(K,J)*B**H(L,J)]. */
951 for (l = *n; l >= 1; --l) {
953 for (k = 1; k <= i__1; ++k) {
956 cdotc_(&q__1, &i__2, &a[k * a_dim1 + 1], &c__1, &c__[l *
958 suml.r = q__1.r, suml.i = q__1.i;
964 cdotc_(&q__1, &i__2, &c__[k + f2cmin(i__3,*n) * c_dim1], ldc, &b[
965 l + f2cmin(i__4,*n) * b_dim1], ldb);
966 sumr.r = q__1.r, sumr.i = q__1.i;
967 i__2 = k + l * c_dim1;
968 r_cnjg(&q__4, &sumr);
969 q__3.r = sgn * q__4.r, q__3.i = sgn * q__4.i;
970 q__2.r = suml.r + q__3.r, q__2.i = suml.i + q__3.i;
971 q__1.r = c__[i__2].r - q__2.r, q__1.i = c__[i__2].i - q__2.i;
972 vec.r = q__1.r, vec.i = q__1.i;
975 i__2 = k + k * a_dim1;
976 i__3 = l + l * b_dim1;
977 q__3.r = sgn * b[i__3].r, q__3.i = sgn * b[i__3].i;
978 q__2.r = a[i__2].r + q__3.r, q__2.i = a[i__2].i + q__3.i;
979 r_cnjg(&q__1, &q__2);
980 a11.r = q__1.r, a11.i = q__1.i;
981 da11 = (r__1 = a11.r, abs(r__1)) + (r__2 = r_imag(&a11), abs(
984 a11.r = smin, a11.i = 0.f;
988 db = (r__1 = vec.r, abs(r__1)) + (r__2 = r_imag(&vec), abs(
990 if (da11 < 1.f && db > 1.f) {
991 if (db > bignum * da11) {
996 q__3.r = scaloc, q__3.i = 0.f;
997 q__2.r = vec.r * q__3.r - vec.i * q__3.i, q__2.i = vec.r *
998 q__3.i + vec.i * q__3.r;
999 cladiv_(&q__1, &q__2, &a11);
1000 x11.r = q__1.r, x11.i = q__1.i;
1002 if (scaloc != 1.f) {
1004 for (j = 1; j <= i__2; ++j) {
1005 csscal_(m, &scaloc, &c__[j * c_dim1 + 1], &c__1);
1010 i__2 = k + l * c_dim1;
1011 c__[i__2].r = x11.r, c__[i__2].i = x11.i;
1018 } else if (notrna && ! notrnb) {
1020 /* Solve A*X + ISGN*X*B**H = C. */
1022 /* The (K,L)th block of X is determined starting from */
1023 /* bottom-left corner column by column by */
1025 /* A(K,K)*X(K,L) + ISGN*X(K,L)*B**H(L,L) = C(K,L) - R(K,L) */
1029 /* R(K,L) = SUM [A(K,I)*X(I,L)] + ISGN*SUM [X(K,J)*B**H(L,J)] */
1032 for (l = *n; l >= 1; --l) {
1033 for (k = *m; k >= 1; --k) {
1040 cdotu_(&q__1, &i__1, &a[k + f2cmin(i__2,*m) * a_dim1], lda, &c__[
1041 f2cmin(i__3,*m) + l * c_dim1], &c__1);
1042 suml.r = q__1.r, suml.i = q__1.i;
1048 cdotc_(&q__1, &i__1, &c__[k + f2cmin(i__2,*n) * c_dim1], ldc, &b[
1049 l + f2cmin(i__3,*n) * b_dim1], ldb);
1050 sumr.r = q__1.r, sumr.i = q__1.i;
1051 i__1 = k + l * c_dim1;
1052 r_cnjg(&q__4, &sumr);
1053 q__3.r = sgn * q__4.r, q__3.i = sgn * q__4.i;
1054 q__2.r = suml.r + q__3.r, q__2.i = suml.i + q__3.i;
1055 q__1.r = c__[i__1].r - q__2.r, q__1.i = c__[i__1].i - q__2.i;
1056 vec.r = q__1.r, vec.i = q__1.i;
1059 i__1 = k + k * a_dim1;
1060 r_cnjg(&q__3, &b[l + l * b_dim1]);
1061 q__2.r = sgn * q__3.r, q__2.i = sgn * q__3.i;
1062 q__1.r = a[i__1].r + q__2.r, q__1.i = a[i__1].i + q__2.i;
1063 a11.r = q__1.r, a11.i = q__1.i;
1064 da11 = (r__1 = a11.r, abs(r__1)) + (r__2 = r_imag(&a11), abs(
1067 a11.r = smin, a11.i = 0.f;
1071 db = (r__1 = vec.r, abs(r__1)) + (r__2 = r_imag(&vec), abs(
1073 if (da11 < 1.f && db > 1.f) {
1074 if (db > bignum * da11) {
1079 q__3.r = scaloc, q__3.i = 0.f;
1080 q__2.r = vec.r * q__3.r - vec.i * q__3.i, q__2.i = vec.r *
1081 q__3.i + vec.i * q__3.r;
1082 cladiv_(&q__1, &q__2, &a11);
1083 x11.r = q__1.r, x11.i = q__1.i;
1085 if (scaloc != 1.f) {
1087 for (j = 1; j <= i__1; ++j) {
1088 csscal_(m, &scaloc, &c__[j * c_dim1 + 1], &c__1);
1093 i__1 = k + l * c_dim1;
1094 c__[i__1].r = x11.r, c__[i__1].i = x11.i;