dtgsyl.c
Go to the documentation of this file.
00001 /* dtgsyl.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__2 = 2;
00019 static integer c_n1 = -1;
00020 static integer c__5 = 5;
00021 static doublereal c_b14 = 0.;
00022 static integer c__1 = 1;
00023 static doublereal c_b51 = -1.;
00024 static doublereal c_b52 = 1.;
00025 
00026 /* Subroutine */ int dtgsyl_(char *trans, integer *ijob, integer *m, integer *
00027         n, doublereal *a, integer *lda, doublereal *b, integer *ldb, 
00028         doublereal *c__, integer *ldc, doublereal *d__, integer *ldd, 
00029         doublereal *e, integer *lde, doublereal *f, integer *ldf, doublereal *
00030         scale, doublereal *dif, doublereal *work, integer *lwork, integer *
00031         iwork, integer *info)
00032 {
00033     /* System generated locals */
00034     integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1, 
00035             d_offset, e_dim1, e_offset, f_dim1, f_offset, i__1, i__2, i__3, 
00036             i__4;
00037 
00038     /* Builtin functions */
00039     double sqrt(doublereal);
00040 
00041     /* Local variables */
00042     integer i__, j, k, p, q, ie, je, mb, nb, is, js, pq;
00043     doublereal dsum;
00044     integer ppqq;
00045     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
00046             integer *), dgemm_(char *, char *, integer *, integer *, integer *
00047 , doublereal *, doublereal *, integer *, doublereal *, integer *, 
00048             doublereal *, doublereal *, integer *);
00049     extern logical lsame_(char *, char *);
00050     integer ifunc, linfo, lwmin;
00051     doublereal scale2;
00052     extern /* Subroutine */ int dtgsy2_(char *, integer *, integer *, integer 
00053             *, doublereal *, integer *, doublereal *, integer *, doublereal *, 
00054              integer *, doublereal *, integer *, doublereal *, integer *, 
00055             doublereal *, integer *, doublereal *, doublereal *, doublereal *, 
00056              integer *, integer *, integer *);
00057     doublereal dscale, scaloc;
00058     extern /* Subroutine */ int dlacpy_(char *, integer *, integer *, 
00059             doublereal *, integer *, doublereal *, integer *), 
00060             dlaset_(char *, integer *, integer *, doublereal *, doublereal *, 
00061             doublereal *, integer *);
00062     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00063             integer *, integer *);
00064     extern /* Subroutine */ int xerbla_(char *, integer *);
00065     integer iround;
00066     logical notran;
00067     integer isolve;
00068     logical lquery;
00069 
00070 
00071 /*  -- LAPACK routine (version 3.2) -- */
00072 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00073 /*     November 2006 */
00074 
00075 /*     .. Scalar Arguments .. */
00076 /*     .. */
00077 /*     .. Array Arguments .. */
00078 /*     .. */
00079 
00080 /*  Purpose */
00081 /*  ======= */
00082 
00083 /*  DTGSYL solves the generalized Sylvester equation: */
00084 
00085 /*              A * R - L * B = scale * C                 (1) */
00086 /*              D * R - L * E = scale * F */
00087 
00088 /*  where R and L are unknown m-by-n matrices, (A, D), (B, E) and */
00089 /*  (C, F) are given matrix pairs of size m-by-m, n-by-n and m-by-n, */
00090 /*  respectively, with real entries. (A, D) and (B, E) must be in */
00091 /*  generalized (real) Schur canonical form, i.e. A, B are upper quasi */
00092 /*  triangular and D, E are upper triangular. */
00093 
00094 /*  The solution (R, L) overwrites (C, F). 0 <= SCALE <= 1 is an output */
00095 /*  scaling factor chosen to avoid overflow. */
00096 
00097 /*  In matrix notation (1) is equivalent to solve  Zx = scale b, where */
00098 /*  Z is defined as */
00099 
00100 /*             Z = [ kron(In, A)  -kron(B', Im) ]         (2) */
00101 /*                 [ kron(In, D)  -kron(E', Im) ]. */
00102 
00103 /*  Here Ik is the identity matrix of size k and X' is the transpose of */
00104 /*  X. kron(X, Y) is the Kronecker product between the matrices X and Y. */
00105 
00106 /*  If TRANS = 'T', DTGSYL solves the transposed system Z'*y = scale*b, */
00107 /*  which is equivalent to solve for R and L in */
00108 
00109 /*              A' * R  + D' * L   = scale *  C           (3) */
00110 /*              R  * B' + L  * E'  = scale * (-F) */
00111 
00112 /*  This case (TRANS = 'T') is used to compute an one-norm-based estimate */
00113 /*  of Dif[(A,D), (B,E)], the separation between the matrix pairs (A,D) */
00114 /*  and (B,E), using DLACON. */
00115 
00116 /*  If IJOB >= 1, DTGSYL computes a Frobenius norm-based estimate */
00117 /*  of Dif[(A,D),(B,E)]. That is, the reciprocal of a lower bound on the */
00118 /*  reciprocal of the smallest singular value of Z. See [1-2] for more */
00119 /*  information. */
00120 
00121 /*  This is a level 3 BLAS algorithm. */
00122 
00123 /*  Arguments */
00124 /*  ========= */
00125 
00126 /*  TRANS   (input) CHARACTER*1 */
00127 /*          = 'N', solve the generalized Sylvester equation (1). */
00128 /*          = 'T', solve the 'transposed' system (3). */
00129 
00130 /*  IJOB    (input) INTEGER */
00131 /*          Specifies what kind of functionality to be performed. */
00132 /*           =0: solve (1) only. */
00133 /*           =1: The functionality of 0 and 3. */
00134 /*           =2: The functionality of 0 and 4. */
00135 /*           =3: Only an estimate of Dif[(A,D), (B,E)] is computed. */
00136 /*               (look ahead strategy IJOB  = 1 is used). */
00137 /*           =4: Only an estimate of Dif[(A,D), (B,E)] is computed. */
00138 /*               ( DGECON on sub-systems is used ). */
00139 /*          Not referenced if TRANS = 'T'. */
00140 
00141 /*  M       (input) INTEGER */
00142 /*          The order of the matrices A and D, and the row dimension of */
00143 /*          the matrices C, F, R and L. */
00144 
00145 /*  N       (input) INTEGER */
00146 /*          The order of the matrices B and E, and the column dimension */
00147 /*          of the matrices C, F, R and L. */
00148 
00149 /*  A       (input) DOUBLE PRECISION array, dimension (LDA, M) */
00150 /*          The upper quasi triangular matrix A. */
00151 
00152 /*  LDA     (input) INTEGER */
00153 /*          The leading dimension of the array A. LDA >= max(1, M). */
00154 
00155 /*  B       (input) DOUBLE PRECISION array, dimension (LDB, N) */
00156 /*          The upper quasi triangular matrix B. */
00157 
00158 /*  LDB     (input) INTEGER */
00159 /*          The leading dimension of the array B. LDB >= max(1, N). */
00160 
00161 /*  C       (input/output) DOUBLE PRECISION array, dimension (LDC, N) */
00162 /*          On entry, C contains the right-hand-side of the first matrix */
00163 /*          equation in (1) or (3). */
00164 /*          On exit, if IJOB = 0, 1 or 2, C has been overwritten by */
00165 /*          the solution R. If IJOB = 3 or 4 and TRANS = 'N', C holds R, */
00166 /*          the solution achieved during the computation of the */
00167 /*          Dif-estimate. */
00168 
00169 /*  LDC     (input) INTEGER */
00170 /*          The leading dimension of the array C. LDC >= max(1, M). */
00171 
00172 /*  D       (input) DOUBLE PRECISION array, dimension (LDD, M) */
00173 /*          The upper triangular matrix D. */
00174 
00175 /*  LDD     (input) INTEGER */
00176 /*          The leading dimension of the array D. LDD >= max(1, M). */
00177 
00178 /*  E       (input) DOUBLE PRECISION array, dimension (LDE, N) */
00179 /*          The upper triangular matrix E. */
00180 
00181 /*  LDE     (input) INTEGER */
00182 /*          The leading dimension of the array E. LDE >= max(1, N). */
00183 
00184 /*  F       (input/output) DOUBLE PRECISION array, dimension (LDF, N) */
00185 /*          On entry, F contains the right-hand-side of the second matrix */
00186 /*          equation in (1) or (3). */
00187 /*          On exit, if IJOB = 0, 1 or 2, F has been overwritten by */
00188 /*          the solution L. If IJOB = 3 or 4 and TRANS = 'N', F holds L, */
00189 /*          the solution achieved during the computation of the */
00190 /*          Dif-estimate. */
00191 
00192 /*  LDF     (input) INTEGER */
00193 /*          The leading dimension of the array F. LDF >= max(1, M). */
00194 
00195 /*  DIF     (output) DOUBLE PRECISION */
00196 /*          On exit DIF is the reciprocal of a lower bound of the */
00197 /*          reciprocal of the Dif-function, i.e. DIF is an upper bound of */
00198 /*          Dif[(A,D), (B,E)] = sigma_min(Z), where Z as in (2). */
00199 /*          IF IJOB = 0 or TRANS = 'T', DIF is not touched. */
00200 
00201 /*  SCALE   (output) DOUBLE PRECISION */
00202 /*          On exit SCALE is the scaling factor in (1) or (3). */
00203 /*          If 0 < SCALE < 1, C and F hold the solutions R and L, resp., */
00204 /*          to a slightly perturbed system but the input matrices A, B, D */
00205 /*          and E have not been changed. If SCALE = 0, C and F hold the */
00206 /*          solutions R and L, respectively, to the homogeneous system */
00207 /*          with C = F = 0. Normally, SCALE = 1. */
00208 
00209 /*  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
00210 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00211 
00212 /*  LWORK   (input) INTEGER */
00213 /*          The dimension of the array WORK. LWORK > = 1. */
00214 /*          If IJOB = 1 or 2 and TRANS = 'N', LWORK >= max(1,2*M*N). */
00215 
00216 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00217 /*          only calculates the optimal size of the WORK array, returns */
00218 /*          this value as the first entry of the WORK array, and no error */
00219 /*          message related to LWORK is issued by XERBLA. */
00220 
00221 /*  IWORK   (workspace) INTEGER array, dimension (M+N+6) */
00222 
00223 /*  INFO    (output) INTEGER */
00224 /*            =0: successful exit */
00225 /*            <0: If INFO = -i, the i-th argument had an illegal value. */
00226 /*            >0: (A, D) and (B, E) have common or close eigenvalues. */
00227 
00228 /*  Further Details */
00229 /*  =============== */
00230 
00231 /*  Based on contributions by */
00232 /*     Bo Kagstrom and Peter Poromaa, Department of Computing Science, */
00233 /*     Umea University, S-901 87 Umea, Sweden. */
00234 
00235 /*  [1] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software */
00236 /*      for Solving the Generalized Sylvester Equation and Estimating the */
00237 /*      Separation between Regular Matrix Pairs, Report UMINF - 93.23, */
00238 /*      Department of Computing Science, Umea University, S-901 87 Umea, */
00239 /*      Sweden, December 1993, Revised April 1994, Also as LAPACK Working */
00240 /*      Note 75.  To appear in ACM Trans. on Math. Software, Vol 22, */
00241 /*      No 1, 1996. */
00242 
00243 /*  [2] B. Kagstrom, A Perturbation Analysis of the Generalized Sylvester */
00244 /*      Equation (AR - LB, DR - LE ) = (C, F), SIAM J. Matrix Anal. */
00245 /*      Appl., 15(4):1045-1060, 1994 */
00246 
00247 /*  [3] B. Kagstrom and L. Westin, Generalized Schur Methods with */
00248 /*      Condition Estimators for Solving the Generalized Sylvester */
00249 /*      Equation, IEEE Transactions on Automatic Control, Vol. 34, No. 7, */
00250 /*      July 1989, pp 745-751. */
00251 
00252 /*  ===================================================================== */
00253 /*  Replaced various illegal calls to DCOPY by calls to DLASET. */
00254 /*  Sven Hammarling, 1/5/02. */
00255 
00256 /*     .. Parameters .. */
00257 /*     .. */
00258 /*     .. Local Scalars .. */
00259 /*     .. */
00260 /*     .. External Functions .. */
00261 /*     .. */
00262 /*     .. External Subroutines .. */
00263 /*     .. */
00264 /*     .. Intrinsic Functions .. */
00265 /*     .. */
00266 /*     .. Executable Statements .. */
00267 
00268 /*     Decode and test input parameters */
00269 
00270     /* Parameter adjustments */
00271     a_dim1 = *lda;
00272     a_offset = 1 + a_dim1;
00273     a -= a_offset;
00274     b_dim1 = *ldb;
00275     b_offset = 1 + b_dim1;
00276     b -= b_offset;
00277     c_dim1 = *ldc;
00278     c_offset = 1 + c_dim1;
00279     c__ -= c_offset;
00280     d_dim1 = *ldd;
00281     d_offset = 1 + d_dim1;
00282     d__ -= d_offset;
00283     e_dim1 = *lde;
00284     e_offset = 1 + e_dim1;
00285     e -= e_offset;
00286     f_dim1 = *ldf;
00287     f_offset = 1 + f_dim1;
00288     f -= f_offset;
00289     --work;
00290     --iwork;
00291 
00292     /* Function Body */
00293     *info = 0;
00294     notran = lsame_(trans, "N");
00295     lquery = *lwork == -1;
00296 
00297     if (! notran && ! lsame_(trans, "T")) {
00298         *info = -1;
00299     } else if (notran) {
00300         if (*ijob < 0 || *ijob > 4) {
00301             *info = -2;
00302         }
00303     }
00304     if (*info == 0) {
00305         if (*m <= 0) {
00306             *info = -3;
00307         } else if (*n <= 0) {
00308             *info = -4;
00309         } else if (*lda < max(1,*m)) {
00310             *info = -6;
00311         } else if (*ldb < max(1,*n)) {
00312             *info = -8;
00313         } else if (*ldc < max(1,*m)) {
00314             *info = -10;
00315         } else if (*ldd < max(1,*m)) {
00316             *info = -12;
00317         } else if (*lde < max(1,*n)) {
00318             *info = -14;
00319         } else if (*ldf < max(1,*m)) {
00320             *info = -16;
00321         }
00322     }
00323 
00324     if (*info == 0) {
00325         if (notran) {
00326             if (*ijob == 1 || *ijob == 2) {
00327 /* Computing MAX */
00328                 i__1 = 1, i__2 = (*m << 1) * *n;
00329                 lwmin = max(i__1,i__2);
00330             } else {
00331                 lwmin = 1;
00332             }
00333         } else {
00334             lwmin = 1;
00335         }
00336         work[1] = (doublereal) lwmin;
00337 
00338         if (*lwork < lwmin && ! lquery) {
00339             *info = -20;
00340         }
00341     }
00342 
00343     if (*info != 0) {
00344         i__1 = -(*info);
00345         xerbla_("DTGSYL", &i__1);
00346         return 0;
00347     } else if (lquery) {
00348         return 0;
00349     }
00350 
00351 /*     Quick return if possible */
00352 
00353     if (*m == 0 || *n == 0) {
00354         *scale = 1.;
00355         if (notran) {
00356             if (*ijob != 0) {
00357                 *dif = 0.;
00358             }
00359         }
00360         return 0;
00361     }
00362 
00363 /*     Determine optimal block sizes MB and NB */
00364 
00365     mb = ilaenv_(&c__2, "DTGSYL", trans, m, n, &c_n1, &c_n1);
00366     nb = ilaenv_(&c__5, "DTGSYL", trans, m, n, &c_n1, &c_n1);
00367 
00368     isolve = 1;
00369     ifunc = 0;
00370     if (notran) {
00371         if (*ijob >= 3) {
00372             ifunc = *ijob - 2;
00373             dlaset_("F", m, n, &c_b14, &c_b14, &c__[c_offset], ldc)
00374                     ;
00375             dlaset_("F", m, n, &c_b14, &c_b14, &f[f_offset], ldf);
00376         } else if (*ijob >= 1) {
00377             isolve = 2;
00378         }
00379     }
00380 
00381     if (mb <= 1 && nb <= 1 || mb >= *m && nb >= *n) {
00382 
00383         i__1 = isolve;
00384         for (iround = 1; iround <= i__1; ++iround) {
00385 
00386 /*           Use unblocked Level 2 solver */
00387 
00388             dscale = 0.;
00389             dsum = 1.;
00390             pq = 0;
00391             dtgsy2_(trans, &ifunc, m, n, &a[a_offset], lda, &b[b_offset], ldb, 
00392                      &c__[c_offset], ldc, &d__[d_offset], ldd, &e[e_offset], 
00393                     lde, &f[f_offset], ldf, scale, &dsum, &dscale, &iwork[1], 
00394                     &pq, info);
00395             if (dscale != 0.) {
00396                 if (*ijob == 1 || *ijob == 3) {
00397                     *dif = sqrt((doublereal) ((*m << 1) * *n)) / (dscale * 
00398                             sqrt(dsum));
00399                 } else {
00400                     *dif = sqrt((doublereal) pq) / (dscale * sqrt(dsum));
00401                 }
00402             }
00403 
00404             if (isolve == 2 && iround == 1) {
00405                 if (notran) {
00406                     ifunc = *ijob;
00407                 }
00408                 scale2 = *scale;
00409                 dlacpy_("F", m, n, &c__[c_offset], ldc, &work[1], m);
00410                 dlacpy_("F", m, n, &f[f_offset], ldf, &work[*m * *n + 1], m);
00411                 dlaset_("F", m, n, &c_b14, &c_b14, &c__[c_offset], ldc);
00412                 dlaset_("F", m, n, &c_b14, &c_b14, &f[f_offset], ldf);
00413             } else if (isolve == 2 && iround == 2) {
00414                 dlacpy_("F", m, n, &work[1], m, &c__[c_offset], ldc);
00415                 dlacpy_("F", m, n, &work[*m * *n + 1], m, &f[f_offset], ldf);
00416                 *scale = scale2;
00417             }
00418 /* L30: */
00419         }
00420 
00421         return 0;
00422     }
00423 
00424 /*     Determine block structure of A */
00425 
00426     p = 0;
00427     i__ = 1;
00428 L40:
00429     if (i__ > *m) {
00430         goto L50;
00431     }
00432     ++p;
00433     iwork[p] = i__;
00434     i__ += mb;
00435     if (i__ >= *m) {
00436         goto L50;
00437     }
00438     if (a[i__ + (i__ - 1) * a_dim1] != 0.) {
00439         ++i__;
00440     }
00441     goto L40;
00442 L50:
00443 
00444     iwork[p + 1] = *m + 1;
00445     if (iwork[p] == iwork[p + 1]) {
00446         --p;
00447     }
00448 
00449 /*     Determine block structure of B */
00450 
00451     q = p + 1;
00452     j = 1;
00453 L60:
00454     if (j > *n) {
00455         goto L70;
00456     }
00457     ++q;
00458     iwork[q] = j;
00459     j += nb;
00460     if (j >= *n) {
00461         goto L70;
00462     }
00463     if (b[j + (j - 1) * b_dim1] != 0.) {
00464         ++j;
00465     }
00466     goto L60;
00467 L70:
00468 
00469     iwork[q + 1] = *n + 1;
00470     if (iwork[q] == iwork[q + 1]) {
00471         --q;
00472     }
00473 
00474     if (notran) {
00475 
00476         i__1 = isolve;
00477         for (iround = 1; iround <= i__1; ++iround) {
00478 
00479 /*           Solve (I, J)-subsystem */
00480 /*               A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J) */
00481 /*               D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J) */
00482 /*           for I = P, P - 1,..., 1; J = 1, 2,..., Q */
00483 
00484             dscale = 0.;
00485             dsum = 1.;
00486             pq = 0;
00487             *scale = 1.;
00488             i__2 = q;
00489             for (j = p + 2; j <= i__2; ++j) {
00490                 js = iwork[j];
00491                 je = iwork[j + 1] - 1;
00492                 nb = je - js + 1;
00493                 for (i__ = p; i__ >= 1; --i__) {
00494                     is = iwork[i__];
00495                     ie = iwork[i__ + 1] - 1;
00496                     mb = ie - is + 1;
00497                     ppqq = 0;
00498                     dtgsy2_(trans, &ifunc, &mb, &nb, &a[is + is * a_dim1], 
00499                             lda, &b[js + js * b_dim1], ldb, &c__[is + js * 
00500                             c_dim1], ldc, &d__[is + is * d_dim1], ldd, &e[js 
00501                             + js * e_dim1], lde, &f[is + js * f_dim1], ldf, &
00502                             scaloc, &dsum, &dscale, &iwork[q + 2], &ppqq, &
00503                             linfo);
00504                     if (linfo > 0) {
00505                         *info = linfo;
00506                     }
00507 
00508                     pq += ppqq;
00509                     if (scaloc != 1.) {
00510                         i__3 = js - 1;
00511                         for (k = 1; k <= i__3; ++k) {
00512                             dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
00513                             dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
00514 /* L80: */
00515                         }
00516                         i__3 = je;
00517                         for (k = js; k <= i__3; ++k) {
00518                             i__4 = is - 1;
00519                             dscal_(&i__4, &scaloc, &c__[k * c_dim1 + 1], &
00520                                     c__1);
00521                             i__4 = is - 1;
00522                             dscal_(&i__4, &scaloc, &f[k * f_dim1 + 1], &c__1);
00523 /* L90: */
00524                         }
00525                         i__3 = je;
00526                         for (k = js; k <= i__3; ++k) {
00527                             i__4 = *m - ie;
00528                             dscal_(&i__4, &scaloc, &c__[ie + 1 + k * c_dim1], 
00529                                     &c__1);
00530                             i__4 = *m - ie;
00531                             dscal_(&i__4, &scaloc, &f[ie + 1 + k * f_dim1], &
00532                                     c__1);
00533 /* L100: */
00534                         }
00535                         i__3 = *n;
00536                         for (k = je + 1; k <= i__3; ++k) {
00537                             dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
00538                             dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
00539 /* L110: */
00540                         }
00541                         *scale *= scaloc;
00542                     }
00543 
00544 /*                 Substitute R(I, J) and L(I, J) into remaining */
00545 /*                 equation. */
00546 
00547                     if (i__ > 1) {
00548                         i__3 = is - 1;
00549                         dgemm_("N", "N", &i__3, &nb, &mb, &c_b51, &a[is * 
00550                                 a_dim1 + 1], lda, &c__[is + js * c_dim1], ldc, 
00551                                  &c_b52, &c__[js * c_dim1 + 1], ldc);
00552                         i__3 = is - 1;
00553                         dgemm_("N", "N", &i__3, &nb, &mb, &c_b51, &d__[is * 
00554                                 d_dim1 + 1], ldd, &c__[is + js * c_dim1], ldc, 
00555                                  &c_b52, &f[js * f_dim1 + 1], ldf);
00556                     }
00557                     if (j < q) {
00558                         i__3 = *n - je;
00559                         dgemm_("N", "N", &mb, &i__3, &nb, &c_b52, &f[is + js *
00560                                  f_dim1], ldf, &b[js + (je + 1) * b_dim1], 
00561                                 ldb, &c_b52, &c__[is + (je + 1) * c_dim1], 
00562                                 ldc);
00563                         i__3 = *n - je;
00564                         dgemm_("N", "N", &mb, &i__3, &nb, &c_b52, &f[is + js *
00565                                  f_dim1], ldf, &e[js + (je + 1) * e_dim1], 
00566                                 lde, &c_b52, &f[is + (je + 1) * f_dim1], ldf);
00567                     }
00568 /* L120: */
00569                 }
00570 /* L130: */
00571             }
00572             if (dscale != 0.) {
00573                 if (*ijob == 1 || *ijob == 3) {
00574                     *dif = sqrt((doublereal) ((*m << 1) * *n)) / (dscale * 
00575                             sqrt(dsum));
00576                 } else {
00577                     *dif = sqrt((doublereal) pq) / (dscale * sqrt(dsum));
00578                 }
00579             }
00580             if (isolve == 2 && iround == 1) {
00581                 if (notran) {
00582                     ifunc = *ijob;
00583                 }
00584                 scale2 = *scale;
00585                 dlacpy_("F", m, n, &c__[c_offset], ldc, &work[1], m);
00586                 dlacpy_("F", m, n, &f[f_offset], ldf, &work[*m * *n + 1], m);
00587                 dlaset_("F", m, n, &c_b14, &c_b14, &c__[c_offset], ldc);
00588                 dlaset_("F", m, n, &c_b14, &c_b14, &f[f_offset], ldf);
00589             } else if (isolve == 2 && iround == 2) {
00590                 dlacpy_("F", m, n, &work[1], m, &c__[c_offset], ldc);
00591                 dlacpy_("F", m, n, &work[*m * *n + 1], m, &f[f_offset], ldf);
00592                 *scale = scale2;
00593             }
00594 /* L150: */
00595         }
00596 
00597     } else {
00598 
00599 /*        Solve transposed (I, J)-subsystem */
00600 /*             A(I, I)' * R(I, J)  + D(I, I)' * L(I, J)  =  C(I, J) */
00601 /*             R(I, J)  * B(J, J)' + L(I, J)  * E(J, J)' = -F(I, J) */
00602 /*        for I = 1,2,..., P; J = Q, Q-1,..., 1 */
00603 
00604         *scale = 1.;
00605         i__1 = p;
00606         for (i__ = 1; i__ <= i__1; ++i__) {
00607             is = iwork[i__];
00608             ie = iwork[i__ + 1] - 1;
00609             mb = ie - is + 1;
00610             i__2 = p + 2;
00611             for (j = q; j >= i__2; --j) {
00612                 js = iwork[j];
00613                 je = iwork[j + 1] - 1;
00614                 nb = je - js + 1;
00615                 dtgsy2_(trans, &ifunc, &mb, &nb, &a[is + is * a_dim1], lda, &
00616                         b[js + js * b_dim1], ldb, &c__[is + js * c_dim1], ldc, 
00617                          &d__[is + is * d_dim1], ldd, &e[js + js * e_dim1], 
00618                         lde, &f[is + js * f_dim1], ldf, &scaloc, &dsum, &
00619                         dscale, &iwork[q + 2], &ppqq, &linfo);
00620                 if (linfo > 0) {
00621                     *info = linfo;
00622                 }
00623                 if (scaloc != 1.) {
00624                     i__3 = js - 1;
00625                     for (k = 1; k <= i__3; ++k) {
00626                         dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
00627                         dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
00628 /* L160: */
00629                     }
00630                     i__3 = je;
00631                     for (k = js; k <= i__3; ++k) {
00632                         i__4 = is - 1;
00633                         dscal_(&i__4, &scaloc, &c__[k * c_dim1 + 1], &c__1);
00634                         i__4 = is - 1;
00635                         dscal_(&i__4, &scaloc, &f[k * f_dim1 + 1], &c__1);
00636 /* L170: */
00637                     }
00638                     i__3 = je;
00639                     for (k = js; k <= i__3; ++k) {
00640                         i__4 = *m - ie;
00641                         dscal_(&i__4, &scaloc, &c__[ie + 1 + k * c_dim1], &
00642                                 c__1);
00643                         i__4 = *m - ie;
00644                         dscal_(&i__4, &scaloc, &f[ie + 1 + k * f_dim1], &c__1)
00645                                 ;
00646 /* L180: */
00647                     }
00648                     i__3 = *n;
00649                     for (k = je + 1; k <= i__3; ++k) {
00650                         dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
00651                         dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
00652 /* L190: */
00653                     }
00654                     *scale *= scaloc;
00655                 }
00656 
00657 /*              Substitute R(I, J) and L(I, J) into remaining equation. */
00658 
00659                 if (j > p + 2) {
00660                     i__3 = js - 1;
00661                     dgemm_("N", "T", &mb, &i__3, &nb, &c_b52, &c__[is + js * 
00662                             c_dim1], ldc, &b[js * b_dim1 + 1], ldb, &c_b52, &
00663                             f[is + f_dim1], ldf);
00664                     i__3 = js - 1;
00665                     dgemm_("N", "T", &mb, &i__3, &nb, &c_b52, &f[is + js * 
00666                             f_dim1], ldf, &e[js * e_dim1 + 1], lde, &c_b52, &
00667                             f[is + f_dim1], ldf);
00668                 }
00669                 if (i__ < p) {
00670                     i__3 = *m - ie;
00671                     dgemm_("T", "N", &i__3, &nb, &mb, &c_b51, &a[is + (ie + 1)
00672                              * a_dim1], lda, &c__[is + js * c_dim1], ldc, &
00673                             c_b52, &c__[ie + 1 + js * c_dim1], ldc);
00674                     i__3 = *m - ie;
00675                     dgemm_("T", "N", &i__3, &nb, &mb, &c_b51, &d__[is + (ie + 
00676                             1) * d_dim1], ldd, &f[is + js * f_dim1], ldf, &
00677                             c_b52, &c__[ie + 1 + js * c_dim1], ldc);
00678                 }
00679 /* L200: */
00680             }
00681 /* L210: */
00682         }
00683 
00684     }
00685 
00686     work[1] = (doublereal) lwmin;
00687 
00688     return 0;
00689 
00690 /*     End of DTGSYL */
00691 
00692 } /* dtgsyl_ */


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