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;
516 static logical c_false = FALSE_;
517 static integer c__2 = 2;
518 static doublereal c_b21 = 1.;
519 static doublereal c_b25 = 0.;
520 static logical c_true = TRUE_;
522 /* > \brief \b DLAQTR solves a real quasi-triangular system of equations, or a complex quasi-triangular system
523 of special form, in real arithmetic. */
525 /* =========== DOCUMENTATION =========== */
527 /* Online html documentation available at */
528 /* http://www.netlib.org/lapack/explore-html/ */
531 /* > Download DLAQTR + dependencies */
532 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaqtr.
535 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaqtr.
538 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaqtr.
546 /* SUBROUTINE DLAQTR( LTRAN, LREAL, N, T, LDT, B, W, SCALE, X, WORK, */
549 /* LOGICAL LREAL, LTRAN */
550 /* INTEGER INFO, LDT, N */
551 /* DOUBLE PRECISION SCALE, W */
552 /* DOUBLE PRECISION B( * ), T( LDT, * ), WORK( * ), X( * ) */
555 /* > \par Purpose: */
560 /* > DLAQTR solves the real quasi-triangular system */
562 /* > op(T)*p = scale*c, if LREAL = .TRUE. */
564 /* > or the complex quasi-triangular systems */
566 /* > op(T + iB)*(p+iq) = scale*(c+id), if LREAL = .FALSE. */
568 /* > in real arithmetic, where T is upper quasi-triangular. */
569 /* > If LREAL = .FALSE., then the first diagonal block of T must be */
570 /* > 1 by 1, B is the specially structured matrix */
572 /* > B = [ b(1) b(2) ... b(n) ] */
578 /* > op(A) = A or A**T, A**T denotes the transpose of */
581 /* > On input, X = [ c ]. On output, X = [ p ]. */
584 /* > This subroutine is designed for the condition number estimation */
585 /* > in routine DTRSNA. */
591 /* > \param[in] LTRAN */
593 /* > LTRAN is LOGICAL */
594 /* > On entry, LTRAN specifies the option of conjugate transpose: */
595 /* > = .FALSE., op(T+i*B) = T+i*B, */
596 /* > = .TRUE., op(T+i*B) = (T+i*B)**T. */
599 /* > \param[in] LREAL */
601 /* > LREAL is LOGICAL */
602 /* > On entry, LREAL specifies the input matrix structure: */
603 /* > = .FALSE., the input is complex */
604 /* > = .TRUE., the input is real */
610 /* > On entry, N specifies the order of T+i*B. N >= 0. */
615 /* > T is DOUBLE PRECISION array, dimension (LDT,N) */
616 /* > On entry, T contains a matrix in Schur canonical form. */
617 /* > If LREAL = .FALSE., then the first diagonal block of T mu */
621 /* > \param[in] LDT */
623 /* > LDT is INTEGER */
624 /* > The leading dimension of the matrix T. LDT >= f2cmax(1,N). */
629 /* > B is DOUBLE PRECISION array, dimension (N) */
630 /* > On entry, B contains the elements to form the matrix */
631 /* > B as described above. */
632 /* > If LREAL = .TRUE., B is not referenced. */
637 /* > W is DOUBLE PRECISION */
638 /* > On entry, W is the diagonal element of the matrix B. */
639 /* > If LREAL = .TRUE., W is not referenced. */
642 /* > \param[out] SCALE */
644 /* > SCALE is DOUBLE PRECISION */
645 /* > On exit, SCALE is the scale factor. */
648 /* > \param[in,out] X */
650 /* > X is DOUBLE PRECISION array, dimension (2*N) */
651 /* > On entry, X contains the right hand side of the system. */
652 /* > On exit, X is overwritten by the solution. */
655 /* > \param[out] WORK */
657 /* > WORK is DOUBLE PRECISION array, dimension (N) */
660 /* > \param[out] INFO */
662 /* > INFO is INTEGER */
663 /* > On exit, INFO is set to */
664 /* > 0: successful exit. */
665 /* > 1: the some diagonal 1 by 1 block has been perturbed by */
666 /* > a small number SMIN to keep nonsingularity. */
667 /* > 2: the some diagonal 2 by 2 block has been perturbed by */
668 /* > a small number in DLALN2 to keep nonsingularity. */
669 /* > NOTE: In the interests of speed, this routine does not */
670 /* > check the inputs for errors. */
676 /* > \author Univ. of Tennessee */
677 /* > \author Univ. of California Berkeley */
678 /* > \author Univ. of Colorado Denver */
679 /* > \author NAG Ltd. */
681 /* > \date December 2016 */
683 /* > \ingroup doubleOTHERauxiliary */
685 /* ===================================================================== */
686 /* Subroutine */ int dlaqtr_(logical *ltran, logical *lreal, integer *n,
687 doublereal *t, integer *ldt, doublereal *b, doublereal *w, doublereal
688 *scale, doublereal *x, doublereal *work, integer *info)
690 /* System generated locals */
691 integer t_dim1, t_offset, i__1, i__2;
692 doublereal d__1, d__2, d__3, d__4, d__5, d__6;
694 /* Local variables */
695 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
698 doublereal smin, xmax, d__[4] /* was [2][2] */;
700 doublereal v[4] /* was [2][2] */, z__;
701 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
703 extern doublereal dasum_(integer *, doublereal *, integer *);
704 extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *,
705 integer *, doublereal *, integer *);
706 integer jnext, j1, j2;
710 extern /* Subroutine */ int dlaln2_(logical *, integer *, integer *,
711 doublereal *, doublereal *, doublereal *, integer *, doublereal *,
712 doublereal *, doublereal *, integer *, doublereal *, doublereal *
713 , doublereal *, integer *, doublereal *, doublereal *, integer *);
714 extern doublereal dlamch_(char *), dlange_(char *, integer *,
715 integer *, doublereal *, integer *, doublereal *);
717 extern integer idamax_(integer *, doublereal *, integer *);
718 doublereal scaloc, sr;
719 extern /* Subroutine */ int dladiv_(doublereal *, doublereal *,
720 doublereal *, doublereal *, doublereal *, doublereal *);
723 doublereal smlnum, rec, eps, tjj, tmp;
726 /* -- LAPACK auxiliary routine (version 3.7.0) -- */
727 /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
728 /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
732 /* ===================================================================== */
735 /* Do not test the input parameters for errors */
737 /* Parameter adjustments */
739 t_offset = 1 + t_dim1 * 1;
749 /* Quick return if possible */
755 /* Set constants to control overflow */
758 smlnum = dlamch_("S") / eps;
759 bignum = 1. / smlnum;
761 xnorm = dlange_("M", n, n, &t[t_offset], ldt, d__);
764 d__1 = xnorm, d__2 = abs(*w), d__1 = f2cmax(d__1,d__2), d__2 = dlange_(
765 "M", n, &c__1, &b[1], n, d__);
766 xnorm = f2cmax(d__1,d__2);
769 d__1 = smlnum, d__2 = eps * xnorm;
770 smin = f2cmax(d__1,d__2);
772 /* Compute 1-norm of each column of strictly upper triangular */
773 /* part of T to control overflow in triangular solver. */
777 for (j = 2; j <= i__1; ++j) {
779 work[j] = dasum_(&i__2, &t[j * t_dim1 + 1], &c__1);
785 for (i__ = 2; i__ <= i__1; ++i__) {
786 work[i__] += (d__1 = b[i__], abs(d__1));
796 k = idamax_(&n1, &x[1], &c__1);
797 xmax = (d__1 = x[k], abs(d__1));
801 *scale = bignum / xmax;
802 dscal_(&n1, scale, &x[1], &c__1);
810 /* Solve T*p = scale*c */
813 for (j = *n; j >= 1; --j) {
821 if (t[j + (j - 1) * t_dim1] != 0.) {
829 /* Meet 1 by 1 diagonal block */
831 /* Scale to avoid overflow when computing */
832 /* x(j) = b(j)/T(j,j) */
834 xj = (d__1 = x[j1], abs(d__1));
835 tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1));
836 tmp = t[j1 + j1 * t_dim1];
848 if (xj > bignum * tjj) {
850 dscal_(n, &rec, &x[1], &c__1);
856 xj = (d__1 = x[j1], abs(d__1));
858 /* Scale x if necessary to avoid overflow when adding a */
859 /* multiple of column j1 of T. */
863 if (work[j1] > (bignum - xmax) * rec) {
864 dscal_(n, &rec, &x[1], &c__1);
871 daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
874 k = idamax_(&i__1, &x[1], &c__1);
875 xmax = (d__1 = x[k], abs(d__1));
880 /* Meet 2 by 2 diagonal block */
882 /* Call 2 by 2 linear system solve, to take */
883 /* care of possible overflow by scaling factor. */
887 dlaln2_(&c_false, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1
888 * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
889 c_b25, &c_b25, v, &c__2, &scaloc, &xnorm, &ierr);
895 dscal_(n, &scaloc, &x[1], &c__1);
901 /* Scale V(1,1) (= X(J1)) and/or V(2,1) (=X(J2)) */
902 /* to avoid overflow in updating right-hand side. */
905 d__1 = abs(v[0]), d__2 = abs(v[1]);
906 xj = f2cmax(d__1,d__2);
910 d__1 = work[j1], d__2 = work[j2];
911 if (f2cmax(d__1,d__2) > (bignum - xmax) * rec) {
912 dscal_(n, &rec, &x[1], &c__1);
917 /* Update right-hand side */
922 daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
926 daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[1]
929 k = idamax_(&i__1, &x[1], &c__1);
930 xmax = (d__1 = x[k], abs(d__1));
941 /* Solve T**T*p = scale*c */
945 for (j = 1; j <= i__1; ++j) {
953 if (t[j + 1 + j * t_dim1] != 0.) {
961 /* 1 by 1 diagonal block */
963 /* Scale if necessary to avoid overflow in forming the */
964 /* right-hand side element by inner product. */
966 xj = (d__1 = x[j1], abs(d__1));
969 if (work[j1] > (bignum - xj) * rec) {
970 dscal_(n, &rec, &x[1], &c__1);
977 x[j1] -= ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], &
980 xj = (d__1 = x[j1], abs(d__1));
981 tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1));
982 tmp = t[j1 + j1 * t_dim1];
990 if (xj > bignum * tjj) {
992 dscal_(n, &rec, &x[1], &c__1);
999 d__2 = xmax, d__3 = (d__1 = x[j1], abs(d__1));
1000 xmax = f2cmax(d__2,d__3);
1004 /* 2 by 2 diagonal block */
1006 /* Scale if necessary to avoid overflow in forming the */
1007 /* right-hand side elements by inner product. */
1010 d__3 = (d__1 = x[j1], abs(d__1)), d__4 = (d__2 = x[j2],
1012 xj = f2cmax(d__3,d__4);
1016 d__1 = work[j2], d__2 = work[j1];
1017 if (f2cmax(d__1,d__2) > (bignum - xj) * rec) {
1018 dscal_(n, &rec, &x[1], &c__1);
1025 d__[0] = x[j1] - ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1,
1028 d__[1] = x[j2] - ddot_(&i__2, &t[j2 * t_dim1 + 1], &c__1,
1031 dlaln2_(&c_true, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1 *
1032 t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &c_b25,
1033 &c_b25, v, &c__2, &scaloc, &xnorm, &ierr);
1039 dscal_(n, &scaloc, &x[1], &c__1);
1045 d__3 = (d__1 = x[j1], abs(d__1)), d__4 = (d__2 = x[j2],
1046 abs(d__2)), d__3 = f2cmax(d__3,d__4);
1047 xmax = f2cmax(d__3,xmax);
1058 d__1 = eps * abs(*w);
1059 sminw = f2cmax(d__1,smin);
1062 /* Solve (T + iB)*(p+iq) = c+id */
1065 for (j = *n; j >= 1; --j) {
1073 if (t[j + (j - 1) * t_dim1] != 0.) {
1081 /* 1 by 1 diagonal block */
1083 /* Scale if necessary to avoid overflow in division */
1089 xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], abs(
1091 tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)) + abs(z__);
1092 tmp = t[j1 + j1 * t_dim1];
1104 if (xj > bignum * tjj) {
1106 dscal_(&n2, &rec, &x[1], &c__1);
1111 dladiv_(&x[j1], &x[*n + j1], &tmp, &z__, &sr, &si);
1114 xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1], abs(
1117 /* Scale x if necessary to avoid overflow when adding a */
1118 /* multiple of column j1 of T. */
1122 if (work[j1] > (bignum - xmax) * rec) {
1123 dscal_(&n2, &rec, &x[1], &c__1);
1131 daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
1135 daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[*
1138 x[1] += b[j1] * x[*n + j1];
1139 x[*n + 1] -= b[j1] * x[j1];
1143 for (k = 1; k <= i__1; ++k) {
1145 d__3 = xmax, d__4 = (d__1 = x[k], abs(d__1)) + (
1146 d__2 = x[k + *n], abs(d__2));
1147 xmax = f2cmax(d__3,d__4);
1154 /* Meet 2 by 2 diagonal block */
1158 d__[2] = x[*n + j1];
1159 d__[3] = x[*n + j2];
1161 dlaln2_(&c_false, &c__2, &c__2, &sminw, &c_b21, &t[j1 +
1162 j1 * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
1163 c_b25, &d__1, v, &c__2, &scaloc, &xnorm, &ierr);
1170 dscal_(&i__1, &scaloc, &x[1], &c__1);
1171 *scale = scaloc * *scale;
1178 /* Scale X(J1), .... to avoid overflow in */
1179 /* updating right hand side. */
1182 d__1 = abs(v[0]) + abs(v[2]), d__2 = abs(v[1]) + abs(v[3])
1184 xj = f2cmax(d__1,d__2);
1188 d__1 = work[j1], d__2 = work[j2];
1189 if (f2cmax(d__1,d__2) > (bignum - xmax) * rec) {
1190 dscal_(&n2, &rec, &x[1], &c__1);
1195 /* Update the right-hand side. */
1200 daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
1204 daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[1]
1209 daxpy_(&i__1, &d__1, &t[j1 * t_dim1 + 1], &c__1, &x[*
1213 daxpy_(&i__1, &d__1, &t[j2 * t_dim1 + 1], &c__1, &x[*
1216 x[1] = x[1] + b[j1] * x[*n + j1] + b[j2] * x[*n + j2];
1217 x[*n + 1] = x[*n + 1] - b[j1] * x[j1] - b[j2] * x[j2];
1221 for (k = 1; k <= i__1; ++k) {
1223 d__3 = (d__1 = x[k], abs(d__1)) + (d__2 = x[k + *
1225 xmax = f2cmax(d__3,xmax);
1237 /* Solve (T + iB)**T*(p+iq) = c+id */
1241 for (j = 1; j <= i__1; ++j) {
1249 if (t[j + 1 + j * t_dim1] != 0.) {
1257 /* 1 by 1 diagonal block */
1259 /* Scale if necessary to avoid overflow in forming the */
1260 /* right-hand side element by inner product. */
1262 xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n], abs(
1266 if (work[j1] > (bignum - xj) * rec) {
1267 dscal_(&n2, &rec, &x[1], &c__1);
1274 x[j1] -= ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], &
1277 x[*n + j1] -= ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[
1280 x[j1] -= b[j1] * x[*n + 1];
1281 x[*n + j1] += b[j1] * x[1];
1283 xj = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n], abs(
1291 /* Scale if necessary to avoid overflow in */
1292 /* complex division */
1294 tjj = (d__1 = t[j1 + j1 * t_dim1], abs(d__1)) + abs(z__);
1295 tmp = t[j1 + j1 * t_dim1];
1303 if (xj > bignum * tjj) {
1305 dscal_(&n2, &rec, &x[1], &c__1);
1311 dladiv_(&x[j1], &x[*n + j1], &tmp, &d__1, &sr, &si);
1315 d__3 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[j1 + *n],
1317 xmax = f2cmax(d__3,xmax);
1321 /* 2 by 2 diagonal block */
1323 /* Scale if necessary to avoid overflow in forming the */
1324 /* right-hand side element by inner product. */
1327 d__5 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1],
1328 abs(d__2)), d__6 = (d__3 = x[j2], abs(d__3)) + (
1329 d__4 = x[*n + j2], abs(d__4));
1330 xj = f2cmax(d__5,d__6);
1334 d__1 = work[j1], d__2 = work[j2];
1335 if (f2cmax(d__1,d__2) > (bignum - xj) / xmax) {
1336 dscal_(&n2, &rec, &x[1], &c__1);
1343 d__[0] = x[j1] - ddot_(&i__2, &t[j1 * t_dim1 + 1], &c__1,
1346 d__[1] = x[j2] - ddot_(&i__2, &t[j2 * t_dim1 + 1], &c__1,
1349 d__[2] = x[*n + j1] - ddot_(&i__2, &t[j1 * t_dim1 + 1], &
1350 c__1, &x[*n + 1], &c__1);
1352 d__[3] = x[*n + j2] - ddot_(&i__2, &t[j2 * t_dim1 + 1], &
1353 c__1, &x[*n + 1], &c__1);
1354 d__[0] -= b[j1] * x[*n + 1];
1355 d__[1] -= b[j2] * x[*n + 1];
1356 d__[2] += b[j1] * x[1];
1357 d__[3] += b[j2] * x[1];
1359 dlaln2_(&c_true, &c__2, &c__2, &sminw, &c_b21, &t[j1 + j1
1360 * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
1361 c_b25, w, v, &c__2, &scaloc, &xnorm, &ierr);
1367 dscal_(&n2, &scaloc, &x[1], &c__1);
1368 *scale = scaloc * *scale;
1375 d__5 = (d__1 = x[j1], abs(d__1)) + (d__2 = x[*n + j1],
1376 abs(d__2)), d__6 = (d__3 = x[j2], abs(d__3)) + (
1377 d__4 = x[*n + j2], abs(d__4)), d__5 = f2cmax(d__5,
1379 xmax = f2cmax(d__5,xmax);