slaqtr.c
Go to the documentation of this file.
00001 /* slaqtr.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 static logical c_false = FALSE_;
00020 static integer c__2 = 2;
00021 static real c_b21 = 1.f;
00022 static real c_b25 = 0.f;
00023 static logical c_true = TRUE_;
00024 
00025 /* Subroutine */ int slaqtr_(logical *ltran, logical *lreal, integer *n, real 
00026         *t, integer *ldt, real *b, real *w, real *scale, real *x, real *work, 
00027         integer *info)
00028 {
00029     /* System generated locals */
00030     integer t_dim1, t_offset, i__1, i__2;
00031     real r__1, r__2, r__3, r__4, r__5, r__6;
00032 
00033     /* Local variables */
00034     real d__[4] /* was [2][2] */;
00035     integer i__, j, k;
00036     real v[4]   /* was [2][2] */, z__;
00037     integer j1, j2, n1, n2;
00038     real si, xj, sr, rec, eps, tjj, tmp;
00039     integer ierr;
00040     real smin;
00041     extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
00042     real xmax;
00043     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
00044     integer jnext;
00045     extern doublereal sasum_(integer *, real *, integer *);
00046     real sminw, xnorm;
00047     extern /* Subroutine */ int saxpy_(integer *, real *, real *, integer *, 
00048             real *, integer *), slaln2_(logical *, integer *, integer *, real 
00049             *, real *, real *, integer *, real *, real *, real *, integer *, 
00050             real *, real *, real *, integer *, real *, real *, integer *);
00051     real scaloc;
00052     extern doublereal slamch_(char *), slange_(char *, integer *, 
00053             integer *, real *, integer *, real *);
00054     real bignum;
00055     extern integer isamax_(integer *, real *, integer *);
00056     extern /* Subroutine */ int sladiv_(real *, real *, real *, real *, real *
00057 , real *);
00058     logical notran;
00059     real smlnum;
00060 
00061 
00062 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00063 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00064 /*     November 2006 */
00065 
00066 /*     .. Scalar Arguments .. */
00067 /*     .. */
00068 /*     .. Array Arguments .. */
00069 /*     .. */
00070 
00071 /*  Purpose */
00072 /*  ======= */
00073 
00074 /*  SLAQTR solves the real quasi-triangular system */
00075 
00076 /*               op(T)*p = scale*c,               if LREAL = .TRUE. */
00077 
00078 /*  or the complex quasi-triangular systems */
00079 
00080 /*             op(T + iB)*(p+iq) = scale*(c+id),  if LREAL = .FALSE. */
00081 
00082 /*  in real arithmetic, where T is upper quasi-triangular. */
00083 /*  If LREAL = .FALSE., then the first diagonal block of T must be */
00084 /*  1 by 1, B is the specially structured matrix */
00085 
00086 /*                 B = [ b(1) b(2) ... b(n) ] */
00087 /*                     [       w            ] */
00088 /*                     [           w        ] */
00089 /*                     [              .     ] */
00090 /*                     [                 w  ] */
00091 
00092 /*  op(A) = A or A', A' denotes the conjugate transpose of */
00093 /*  matrix A. */
00094 
00095 /*  On input, X = [ c ].  On output, X = [ p ]. */
00096 /*                [ d ]                  [ q ] */
00097 
00098 /*  This subroutine is designed for the condition number estimation */
00099 /*  in routine STRSNA. */
00100 
00101 /*  Arguments */
00102 /*  ========= */
00103 
00104 /*  LTRAN   (input) LOGICAL */
00105 /*          On entry, LTRAN specifies the option of conjugate transpose: */
00106 /*             = .FALSE.,    op(T+i*B) = T+i*B, */
00107 /*             = .TRUE.,     op(T+i*B) = (T+i*B)'. */
00108 
00109 /*  LREAL   (input) LOGICAL */
00110 /*          On entry, LREAL specifies the input matrix structure: */
00111 /*             = .FALSE.,    the input is complex */
00112 /*             = .TRUE.,     the input is real */
00113 
00114 /*  N       (input) INTEGER */
00115 /*          On entry, N specifies the order of T+i*B. N >= 0. */
00116 
00117 /*  T       (input) REAL array, dimension (LDT,N) */
00118 /*          On entry, T contains a matrix in Schur canonical form. */
00119 /*          If LREAL = .FALSE., then the first diagonal block of T must */
00120 /*          be 1 by 1. */
00121 
00122 /*  LDT     (input) INTEGER */
00123 /*          The leading dimension of the matrix T. LDT >= max(1,N). */
00124 
00125 /*  B       (input) REAL array, dimension (N) */
00126 /*          On entry, B contains the elements to form the matrix */
00127 /*          B as described above. */
00128 /*          If LREAL = .TRUE., B is not referenced. */
00129 
00130 /*  W       (input) REAL */
00131 /*          On entry, W is the diagonal element of the matrix B. */
00132 /*          If LREAL = .TRUE., W is not referenced. */
00133 
00134 /*  SCALE   (output) REAL */
00135 /*          On exit, SCALE is the scale factor. */
00136 
00137 /*  X       (input/output) REAL array, dimension (2*N) */
00138 /*          On entry, X contains the right hand side of the system. */
00139 /*          On exit, X is overwritten by the solution. */
00140 
00141 /*  WORK    (workspace) REAL array, dimension (N) */
00142 
00143 /*  INFO    (output) INTEGER */
00144 /*          On exit, INFO is set to */
00145 /*             0: successful exit. */
00146 /*               1: the some diagonal 1 by 1 block has been perturbed by */
00147 /*                  a small number SMIN to keep nonsingularity. */
00148 /*               2: the some diagonal 2 by 2 block has been perturbed by */
00149 /*                  a small number in SLALN2 to keep nonsingularity. */
00150 /*          NOTE: In the interests of speed, this routine does not */
00151 /*                check the inputs for errors. */
00152 
00153 /* ===================================================================== */
00154 
00155 /*     .. Parameters .. */
00156 /*     .. */
00157 /*     .. Local Scalars .. */
00158 /*     .. */
00159 /*     .. Local Arrays .. */
00160 /*     .. */
00161 /*     .. External Functions .. */
00162 /*     .. */
00163 /*     .. External Subroutines .. */
00164 /*     .. */
00165 /*     .. Intrinsic Functions .. */
00166 /*     .. */
00167 /*     .. Executable Statements .. */
00168 
00169 /*     Do not test the input parameters for errors */
00170 
00171     /* Parameter adjustments */
00172     t_dim1 = *ldt;
00173     t_offset = 1 + t_dim1;
00174     t -= t_offset;
00175     --b;
00176     --x;
00177     --work;
00178 
00179     /* Function Body */
00180     notran = ! (*ltran);
00181     *info = 0;
00182 
00183 /*     Quick return if possible */
00184 
00185     if (*n == 0) {
00186         return 0;
00187     }
00188 
00189 /*     Set constants to control overflow */
00190 
00191     eps = slamch_("P");
00192     smlnum = slamch_("S") / eps;
00193     bignum = 1.f / smlnum;
00194 
00195     xnorm = slange_("M", n, n, &t[t_offset], ldt, d__);
00196     if (! (*lreal)) {
00197 /* Computing MAX */
00198         r__1 = xnorm, r__2 = dabs(*w), r__1 = max(r__1,r__2), r__2 = slange_(
00199                 "M", n, &c__1, &b[1], n, d__);
00200         xnorm = dmax(r__1,r__2);
00201     }
00202 /* Computing MAX */
00203     r__1 = smlnum, r__2 = eps * xnorm;
00204     smin = dmax(r__1,r__2);
00205 
00206 /*     Compute 1-norm of each column of strictly upper triangular */
00207 /*     part of T to control overflow in triangular solver. */
00208 
00209     work[1] = 0.f;
00210     i__1 = *n;
00211     for (j = 2; j <= i__1; ++j) {
00212         i__2 = j - 1;
00213         work[j] = sasum_(&i__2, &t[j * t_dim1 + 1], &c__1);
00214 /* L10: */
00215     }
00216 
00217     if (! (*lreal)) {
00218         i__1 = *n;
00219         for (i__ = 2; i__ <= i__1; ++i__) {
00220             work[i__] += (r__1 = b[i__], dabs(r__1));
00221 /* L20: */
00222         }
00223     }
00224 
00225     n2 = *n << 1;
00226     n1 = *n;
00227     if (! (*lreal)) {
00228         n1 = n2;
00229     }
00230     k = isamax_(&n1, &x[1], &c__1);
00231     xmax = (r__1 = x[k], dabs(r__1));
00232     *scale = 1.f;
00233 
00234     if (xmax > bignum) {
00235         *scale = bignum / xmax;
00236         sscal_(&n1, scale, &x[1], &c__1);
00237         xmax = bignum;
00238     }
00239 
00240     if (*lreal) {
00241 
00242         if (notran) {
00243 
00244 /*           Solve T*p = scale*c */
00245 
00246             jnext = *n;
00247             for (j = *n; j >= 1; --j) {
00248                 if (j > jnext) {
00249                     goto L30;
00250                 }
00251                 j1 = j;
00252                 j2 = j;
00253                 jnext = j - 1;
00254                 if (j > 1) {
00255                     if (t[j + (j - 1) * t_dim1] != 0.f) {
00256                         j1 = j - 1;
00257                         jnext = j - 2;
00258                     }
00259                 }
00260 
00261                 if (j1 == j2) {
00262 
00263 /*                 Meet 1 by 1 diagonal block */
00264 
00265 /*                 Scale to avoid overflow when computing */
00266 /*                     x(j) = b(j)/T(j,j) */
00267 
00268                     xj = (r__1 = x[j1], dabs(r__1));
00269                     tjj = (r__1 = t[j1 + j1 * t_dim1], dabs(r__1));
00270                     tmp = t[j1 + j1 * t_dim1];
00271                     if (tjj < smin) {
00272                         tmp = smin;
00273                         tjj = smin;
00274                         *info = 1;
00275                     }
00276 
00277                     if (xj == 0.f) {
00278                         goto L30;
00279                     }
00280 
00281                     if (tjj < 1.f) {
00282                         if (xj > bignum * tjj) {
00283                             rec = 1.f / xj;
00284                             sscal_(n, &rec, &x[1], &c__1);
00285                             *scale *= rec;
00286                             xmax *= rec;
00287                         }
00288                     }
00289                     x[j1] /= tmp;
00290                     xj = (r__1 = x[j1], dabs(r__1));
00291 
00292 /*                 Scale x if necessary to avoid overflow when adding a */
00293 /*                 multiple of column j1 of T. */
00294 
00295                     if (xj > 1.f) {
00296                         rec = 1.f / xj;
00297                         if (work[j1] > (bignum - xmax) * rec) {
00298                             sscal_(n, &rec, &x[1], &c__1);
00299                             *scale *= rec;
00300                         }
00301                     }
00302                     if (j1 > 1) {
00303                         i__1 = j1 - 1;
00304                         r__1 = -x[j1];
00305                         saxpy_(&i__1, &r__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
00306 , &c__1);
00307                         i__1 = j1 - 1;
00308                         k = isamax_(&i__1, &x[1], &c__1);
00309                         xmax = (r__1 = x[k], dabs(r__1));
00310                     }
00311 
00312                 } else {
00313 
00314 /*                 Meet 2 by 2 diagonal block */
00315 
00316 /*                 Call 2 by 2 linear system solve, to take */
00317 /*                 care of possible overflow by scaling factor. */
00318 
00319                     d__[0] = x[j1];
00320                     d__[1] = x[j2];
00321                     slaln2_(&c_false, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1 
00322                             * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
00323                             c_b25, &c_b25, v, &c__2, &scaloc, &xnorm, &ierr);
00324                     if (ierr != 0) {
00325                         *info = 2;
00326                     }
00327 
00328                     if (scaloc != 1.f) {
00329                         sscal_(n, &scaloc, &x[1], &c__1);
00330                         *scale *= scaloc;
00331                     }
00332                     x[j1] = v[0];
00333                     x[j2] = v[1];
00334 
00335 /*                 Scale V(1,1) (= X(J1)) and/or V(2,1) (=X(J2)) */
00336 /*                 to avoid overflow in updating right-hand side. */
00337 
00338 /* Computing MAX */
00339                     r__1 = dabs(v[0]), r__2 = dabs(v[1]);
00340                     xj = dmax(r__1,r__2);
00341                     if (xj > 1.f) {
00342                         rec = 1.f / xj;
00343 /* Computing MAX */
00344                         r__1 = work[j1], r__2 = work[j2];
00345                         if (dmax(r__1,r__2) > (bignum - xmax) * rec) {
00346                             sscal_(n, &rec, &x[1], &c__1);
00347                             *scale *= rec;
00348                         }
00349                     }
00350 
00351 /*                 Update right-hand side */
00352 
00353                     if (j1 > 1) {
00354                         i__1 = j1 - 1;
00355                         r__1 = -x[j1];
00356                         saxpy_(&i__1, &r__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
00357 , &c__1);
00358                         i__1 = j1 - 1;
00359                         r__1 = -x[j2];
00360                         saxpy_(&i__1, &r__1, &t[j2 * t_dim1 + 1], &c__1, &x[1]
00361 , &c__1);
00362                         i__1 = j1 - 1;
00363                         k = isamax_(&i__1, &x[1], &c__1);
00364                         xmax = (r__1 = x[k], dabs(r__1));
00365                     }
00366 
00367                 }
00368 
00369 L30:
00370                 ;
00371             }
00372 
00373         } else {
00374 
00375 /*           Solve T'*p = scale*c */
00376 
00377             jnext = 1;
00378             i__1 = *n;
00379             for (j = 1; j <= i__1; ++j) {
00380                 if (j < jnext) {
00381                     goto L40;
00382                 }
00383                 j1 = j;
00384                 j2 = j;
00385                 jnext = j + 1;
00386                 if (j < *n) {
00387                     if (t[j + 1 + j * t_dim1] != 0.f) {
00388                         j2 = j + 1;
00389                         jnext = j + 2;
00390                     }
00391                 }
00392 
00393                 if (j1 == j2) {
00394 
00395 /*                 1 by 1 diagonal block */
00396 
00397 /*                 Scale if necessary to avoid overflow in forming the */
00398 /*                 right-hand side element by inner product. */
00399 
00400                     xj = (r__1 = x[j1], dabs(r__1));
00401                     if (xmax > 1.f) {
00402                         rec = 1.f / xmax;
00403                         if (work[j1] > (bignum - xj) * rec) {
00404                             sscal_(n, &rec, &x[1], &c__1);
00405                             *scale *= rec;
00406                             xmax *= rec;
00407                         }
00408                     }
00409 
00410                     i__2 = j1 - 1;
00411                     x[j1] -= sdot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], &
00412                             c__1);
00413 
00414                     xj = (r__1 = x[j1], dabs(r__1));
00415                     tjj = (r__1 = t[j1 + j1 * t_dim1], dabs(r__1));
00416                     tmp = t[j1 + j1 * t_dim1];
00417                     if (tjj < smin) {
00418                         tmp = smin;
00419                         tjj = smin;
00420                         *info = 1;
00421                     }
00422 
00423                     if (tjj < 1.f) {
00424                         if (xj > bignum * tjj) {
00425                             rec = 1.f / xj;
00426                             sscal_(n, &rec, &x[1], &c__1);
00427                             *scale *= rec;
00428                             xmax *= rec;
00429                         }
00430                     }
00431                     x[j1] /= tmp;
00432 /* Computing MAX */
00433                     r__2 = xmax, r__3 = (r__1 = x[j1], dabs(r__1));
00434                     xmax = dmax(r__2,r__3);
00435 
00436                 } else {
00437 
00438 /*                 2 by 2 diagonal block */
00439 
00440 /*                 Scale if necessary to avoid overflow in forming the */
00441 /*                 right-hand side elements by inner product. */
00442 
00443 /* Computing MAX */
00444                     r__3 = (r__1 = x[j1], dabs(r__1)), r__4 = (r__2 = x[j2], 
00445                             dabs(r__2));
00446                     xj = dmax(r__3,r__4);
00447                     if (xmax > 1.f) {
00448                         rec = 1.f / xmax;
00449 /* Computing MAX */
00450                         r__1 = work[j2], r__2 = work[j1];
00451                         if (dmax(r__1,r__2) > (bignum - xj) * rec) {
00452                             sscal_(n, &rec, &x[1], &c__1);
00453                             *scale *= rec;
00454                             xmax *= rec;
00455                         }
00456                     }
00457 
00458                     i__2 = j1 - 1;
00459                     d__[0] = x[j1] - sdot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, 
00460                             &x[1], &c__1);
00461                     i__2 = j1 - 1;
00462                     d__[1] = x[j2] - sdot_(&i__2, &t[j2 * t_dim1 + 1], &c__1, 
00463                             &x[1], &c__1);
00464 
00465                     slaln2_(&c_true, &c__2, &c__1, &smin, &c_b21, &t[j1 + j1 *
00466                              t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &c_b25, 
00467                              &c_b25, v, &c__2, &scaloc, &xnorm, &ierr);
00468                     if (ierr != 0) {
00469                         *info = 2;
00470                     }
00471 
00472                     if (scaloc != 1.f) {
00473                         sscal_(n, &scaloc, &x[1], &c__1);
00474                         *scale *= scaloc;
00475                     }
00476                     x[j1] = v[0];
00477                     x[j2] = v[1];
00478 /* Computing MAX */
00479                     r__3 = (r__1 = x[j1], dabs(r__1)), r__4 = (r__2 = x[j2], 
00480                             dabs(r__2)), r__3 = max(r__3,r__4);
00481                     xmax = dmax(r__3,xmax);
00482 
00483                 }
00484 L40:
00485                 ;
00486             }
00487         }
00488 
00489     } else {
00490 
00491 /* Computing MAX */
00492         r__1 = eps * dabs(*w);
00493         sminw = dmax(r__1,smin);
00494         if (notran) {
00495 
00496 /*           Solve (T + iB)*(p+iq) = c+id */
00497 
00498             jnext = *n;
00499             for (j = *n; j >= 1; --j) {
00500                 if (j > jnext) {
00501                     goto L70;
00502                 }
00503                 j1 = j;
00504                 j2 = j;
00505                 jnext = j - 1;
00506                 if (j > 1) {
00507                     if (t[j + (j - 1) * t_dim1] != 0.f) {
00508                         j1 = j - 1;
00509                         jnext = j - 2;
00510                     }
00511                 }
00512 
00513                 if (j1 == j2) {
00514 
00515 /*                 1 by 1 diagonal block */
00516 
00517 /*                 Scale if necessary to avoid overflow in division */
00518 
00519                     z__ = *w;
00520                     if (j1 == 1) {
00521                         z__ = b[1];
00522                     }
00523                     xj = (r__1 = x[j1], dabs(r__1)) + (r__2 = x[*n + j1], 
00524                             dabs(r__2));
00525                     tjj = (r__1 = t[j1 + j1 * t_dim1], dabs(r__1)) + dabs(z__)
00526                             ;
00527                     tmp = t[j1 + j1 * t_dim1];
00528                     if (tjj < sminw) {
00529                         tmp = sminw;
00530                         tjj = sminw;
00531                         *info = 1;
00532                     }
00533 
00534                     if (xj == 0.f) {
00535                         goto L70;
00536                     }
00537 
00538                     if (tjj < 1.f) {
00539                         if (xj > bignum * tjj) {
00540                             rec = 1.f / xj;
00541                             sscal_(&n2, &rec, &x[1], &c__1);
00542                             *scale *= rec;
00543                             xmax *= rec;
00544                         }
00545                     }
00546                     sladiv_(&x[j1], &x[*n + j1], &tmp, &z__, &sr, &si);
00547                     x[j1] = sr;
00548                     x[*n + j1] = si;
00549                     xj = (r__1 = x[j1], dabs(r__1)) + (r__2 = x[*n + j1], 
00550                             dabs(r__2));
00551 
00552 /*                 Scale x if necessary to avoid overflow when adding a */
00553 /*                 multiple of column j1 of T. */
00554 
00555                     if (xj > 1.f) {
00556                         rec = 1.f / xj;
00557                         if (work[j1] > (bignum - xmax) * rec) {
00558                             sscal_(&n2, &rec, &x[1], &c__1);
00559                             *scale *= rec;
00560                         }
00561                     }
00562 
00563                     if (j1 > 1) {
00564                         i__1 = j1 - 1;
00565                         r__1 = -x[j1];
00566                         saxpy_(&i__1, &r__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
00567 , &c__1);
00568                         i__1 = j1 - 1;
00569                         r__1 = -x[*n + j1];
00570                         saxpy_(&i__1, &r__1, &t[j1 * t_dim1 + 1], &c__1, &x[*
00571                                 n + 1], &c__1);
00572 
00573                         x[1] += b[j1] * x[*n + j1];
00574                         x[*n + 1] -= b[j1] * x[j1];
00575 
00576                         xmax = 0.f;
00577                         i__1 = j1 - 1;
00578                         for (k = 1; k <= i__1; ++k) {
00579 /* Computing MAX */
00580                             r__3 = xmax, r__4 = (r__1 = x[k], dabs(r__1)) + (
00581                                     r__2 = x[k + *n], dabs(r__2));
00582                             xmax = dmax(r__3,r__4);
00583 /* L50: */
00584                         }
00585                     }
00586 
00587                 } else {
00588 
00589 /*                 Meet 2 by 2 diagonal block */
00590 
00591                     d__[0] = x[j1];
00592                     d__[1] = x[j2];
00593                     d__[2] = x[*n + j1];
00594                     d__[3] = x[*n + j2];
00595                     r__1 = -(*w);
00596                     slaln2_(&c_false, &c__2, &c__2, &sminw, &c_b21, &t[j1 + 
00597                             j1 * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
00598                             c_b25, &r__1, v, &c__2, &scaloc, &xnorm, &ierr);
00599                     if (ierr != 0) {
00600                         *info = 2;
00601                     }
00602 
00603                     if (scaloc != 1.f) {
00604                         i__1 = *n << 1;
00605                         sscal_(&i__1, &scaloc, &x[1], &c__1);
00606                         *scale = scaloc * *scale;
00607                     }
00608                     x[j1] = v[0];
00609                     x[j2] = v[1];
00610                     x[*n + j1] = v[2];
00611                     x[*n + j2] = v[3];
00612 
00613 /*                 Scale X(J1), .... to avoid overflow in */
00614 /*                 updating right hand side. */
00615 
00616 /* Computing MAX */
00617                     r__1 = dabs(v[0]) + dabs(v[2]), r__2 = dabs(v[1]) + dabs(
00618                             v[3]);
00619                     xj = dmax(r__1,r__2);
00620                     if (xj > 1.f) {
00621                         rec = 1.f / xj;
00622 /* Computing MAX */
00623                         r__1 = work[j1], r__2 = work[j2];
00624                         if (dmax(r__1,r__2) > (bignum - xmax) * rec) {
00625                             sscal_(&n2, &rec, &x[1], &c__1);
00626                             *scale *= rec;
00627                         }
00628                     }
00629 
00630 /*                 Update the right-hand side. */
00631 
00632                     if (j1 > 1) {
00633                         i__1 = j1 - 1;
00634                         r__1 = -x[j1];
00635                         saxpy_(&i__1, &r__1, &t[j1 * t_dim1 + 1], &c__1, &x[1]
00636 , &c__1);
00637                         i__1 = j1 - 1;
00638                         r__1 = -x[j2];
00639                         saxpy_(&i__1, &r__1, &t[j2 * t_dim1 + 1], &c__1, &x[1]
00640 , &c__1);
00641 
00642                         i__1 = j1 - 1;
00643                         r__1 = -x[*n + j1];
00644                         saxpy_(&i__1, &r__1, &t[j1 * t_dim1 + 1], &c__1, &x[*
00645                                 n + 1], &c__1);
00646                         i__1 = j1 - 1;
00647                         r__1 = -x[*n + j2];
00648                         saxpy_(&i__1, &r__1, &t[j2 * t_dim1 + 1], &c__1, &x[*
00649                                 n + 1], &c__1);
00650 
00651                         x[1] = x[1] + b[j1] * x[*n + j1] + b[j2] * x[*n + j2];
00652                         x[*n + 1] = x[*n + 1] - b[j1] * x[j1] - b[j2] * x[j2];
00653 
00654                         xmax = 0.f;
00655                         i__1 = j1 - 1;
00656                         for (k = 1; k <= i__1; ++k) {
00657 /* Computing MAX */
00658                             r__3 = (r__1 = x[k], dabs(r__1)) + (r__2 = x[k + *
00659                                     n], dabs(r__2));
00660                             xmax = dmax(r__3,xmax);
00661 /* L60: */
00662                         }
00663                     }
00664 
00665                 }
00666 L70:
00667                 ;
00668             }
00669 
00670         } else {
00671 
00672 /*           Solve (T + iB)'*(p+iq) = c+id */
00673 
00674             jnext = 1;
00675             i__1 = *n;
00676             for (j = 1; j <= i__1; ++j) {
00677                 if (j < jnext) {
00678                     goto L80;
00679                 }
00680                 j1 = j;
00681                 j2 = j;
00682                 jnext = j + 1;
00683                 if (j < *n) {
00684                     if (t[j + 1 + j * t_dim1] != 0.f) {
00685                         j2 = j + 1;
00686                         jnext = j + 2;
00687                     }
00688                 }
00689 
00690                 if (j1 == j2) {
00691 
00692 /*                 1 by 1 diagonal block */
00693 
00694 /*                 Scale if necessary to avoid overflow in forming the */
00695 /*                 right-hand side element by inner product. */
00696 
00697                     xj = (r__1 = x[j1], dabs(r__1)) + (r__2 = x[j1 + *n], 
00698                             dabs(r__2));
00699                     if (xmax > 1.f) {
00700                         rec = 1.f / xmax;
00701                         if (work[j1] > (bignum - xj) * rec) {
00702                             sscal_(&n2, &rec, &x[1], &c__1);
00703                             *scale *= rec;
00704                             xmax *= rec;
00705                         }
00706                     }
00707 
00708                     i__2 = j1 - 1;
00709                     x[j1] -= sdot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[1], &
00710                             c__1);
00711                     i__2 = j1 - 1;
00712                     x[*n + j1] -= sdot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, &x[
00713                             *n + 1], &c__1);
00714                     if (j1 > 1) {
00715                         x[j1] -= b[j1] * x[*n + 1];
00716                         x[*n + j1] += b[j1] * x[1];
00717                     }
00718                     xj = (r__1 = x[j1], dabs(r__1)) + (r__2 = x[j1 + *n], 
00719                             dabs(r__2));
00720 
00721                     z__ = *w;
00722                     if (j1 == 1) {
00723                         z__ = b[1];
00724                     }
00725 
00726 /*                 Scale if necessary to avoid overflow in */
00727 /*                 complex division */
00728 
00729                     tjj = (r__1 = t[j1 + j1 * t_dim1], dabs(r__1)) + dabs(z__)
00730                             ;
00731                     tmp = t[j1 + j1 * t_dim1];
00732                     if (tjj < sminw) {
00733                         tmp = sminw;
00734                         tjj = sminw;
00735                         *info = 1;
00736                     }
00737 
00738                     if (tjj < 1.f) {
00739                         if (xj > bignum * tjj) {
00740                             rec = 1.f / xj;
00741                             sscal_(&n2, &rec, &x[1], &c__1);
00742                             *scale *= rec;
00743                             xmax *= rec;
00744                         }
00745                     }
00746                     r__1 = -z__;
00747                     sladiv_(&x[j1], &x[*n + j1], &tmp, &r__1, &sr, &si);
00748                     x[j1] = sr;
00749                     x[j1 + *n] = si;
00750 /* Computing MAX */
00751                     r__3 = (r__1 = x[j1], dabs(r__1)) + (r__2 = x[j1 + *n], 
00752                             dabs(r__2));
00753                     xmax = dmax(r__3,xmax);
00754 
00755                 } else {
00756 
00757 /*                 2 by 2 diagonal block */
00758 
00759 /*                 Scale if necessary to avoid overflow in forming the */
00760 /*                 right-hand side element by inner product. */
00761 
00762 /* Computing MAX */
00763                     r__5 = (r__1 = x[j1], dabs(r__1)) + (r__2 = x[*n + j1], 
00764                             dabs(r__2)), r__6 = (r__3 = x[j2], dabs(r__3)) + (
00765                             r__4 = x[*n + j2], dabs(r__4));
00766                     xj = dmax(r__5,r__6);
00767                     if (xmax > 1.f) {
00768                         rec = 1.f / xmax;
00769 /* Computing MAX */
00770                         r__1 = work[j1], r__2 = work[j2];
00771                         if (dmax(r__1,r__2) > (bignum - xj) / xmax) {
00772                             sscal_(&n2, &rec, &x[1], &c__1);
00773                             *scale *= rec;
00774                             xmax *= rec;
00775                         }
00776                     }
00777 
00778                     i__2 = j1 - 1;
00779                     d__[0] = x[j1] - sdot_(&i__2, &t[j1 * t_dim1 + 1], &c__1, 
00780                             &x[1], &c__1);
00781                     i__2 = j1 - 1;
00782                     d__[1] = x[j2] - sdot_(&i__2, &t[j2 * t_dim1 + 1], &c__1, 
00783                             &x[1], &c__1);
00784                     i__2 = j1 - 1;
00785                     d__[2] = x[*n + j1] - sdot_(&i__2, &t[j1 * t_dim1 + 1], &
00786                             c__1, &x[*n + 1], &c__1);
00787                     i__2 = j1 - 1;
00788                     d__[3] = x[*n + j2] - sdot_(&i__2, &t[j2 * t_dim1 + 1], &
00789                             c__1, &x[*n + 1], &c__1);
00790                     d__[0] -= b[j1] * x[*n + 1];
00791                     d__[1] -= b[j2] * x[*n + 1];
00792                     d__[2] += b[j1] * x[1];
00793                     d__[3] += b[j2] * x[1];
00794 
00795                     slaln2_(&c_true, &c__2, &c__2, &sminw, &c_b21, &t[j1 + j1 
00796                             * t_dim1], ldt, &c_b21, &c_b21, d__, &c__2, &
00797                             c_b25, w, v, &c__2, &scaloc, &xnorm, &ierr);
00798                     if (ierr != 0) {
00799                         *info = 2;
00800                     }
00801 
00802                     if (scaloc != 1.f) {
00803                         sscal_(&n2, &scaloc, &x[1], &c__1);
00804                         *scale = scaloc * *scale;
00805                     }
00806                     x[j1] = v[0];
00807                     x[j2] = v[1];
00808                     x[*n + j1] = v[2];
00809                     x[*n + j2] = v[3];
00810 /* Computing MAX */
00811                     r__5 = (r__1 = x[j1], dabs(r__1)) + (r__2 = x[*n + j1], 
00812                             dabs(r__2)), r__6 = (r__3 = x[j2], dabs(r__3)) + (
00813                             r__4 = x[*n + j2], dabs(r__4)), r__5 = max(r__5,
00814                             r__6);
00815                     xmax = dmax(r__5,xmax);
00816 
00817                 }
00818 
00819 L80:
00820                 ;
00821             }
00822 
00823         }
00824 
00825     }
00826 
00827     return 0;
00828 
00829 /*     End of SLAQTR */
00830 
00831 } /* slaqtr_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:11