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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:46