/* Subroutine */ int zlatdf_(integer *ijob, integer *n, doublecomplex *z__, integer *ldz, doublecomplex *rhs, doublereal *rdsum, doublereal * rdscal, integer *ipiv, integer *jpiv) { /* System generated locals */ integer z_dim1, z_offset, i__1, i__2, i__3, i__4, i__5; doublecomplex z__1, z__2, z__3; /* Builtin functions */ void z_div(doublecomplex *, doublecomplex *, doublecomplex *); double z_abs(doublecomplex *); void z_sqrt(doublecomplex *, doublecomplex *); /* Local variables */ integer i__, j, k; doublecomplex bm, bp, xm[2], xp[2]; integer info; doublecomplex temp, work[8]; doublereal scale; extern /* Subroutine */ int zscal_(integer *, doublecomplex *, doublecomplex *, integer *); doublecomplex pmone; extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, doublecomplex *, integer *, doublecomplex *, integer *); doublereal rtemp, sminu, rwork[2]; extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, doublecomplex *, integer *); doublereal splus; extern /* Subroutine */ int zaxpy_(integer *, doublecomplex *, doublecomplex *, integer *, doublecomplex *, integer *), zgesc2_( integer *, doublecomplex *, integer *, doublecomplex *, integer *, integer *, doublereal *), zgecon_(char *, integer *, doublecomplex *, integer *, doublereal *, doublereal *, doublecomplex *, doublereal *, integer *); extern doublereal dzasum_(integer *, doublecomplex *, integer *); extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, doublereal *, doublereal *), zlaswp_(integer *, doublecomplex *, integer *, integer *, integer *, integer *, integer *); /* -- LAPACK auxiliary routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* ZLATDF computes the contribution to the reciprocal Dif-estimate */ /* by solving for x in Z * x = b, where b is chosen such that the norm */ /* of x is as large as possible. It is assumed that LU decomposition */ /* of Z has been computed by ZGETC2. On entry RHS = f holds the */ /* contribution from earlier solved sub-systems, and on return RHS = x. */ /* The factorization of Z returned by ZGETC2 has the form */ /* Z = P * L * U * Q, where P and Q are permutation matrices. L is lower */ /* triangular with unit diagonal elements and U is upper triangular. */ /* Arguments */ /* ========= */ /* IJOB (input) INTEGER */ /* IJOB = 2: First compute an approximative null-vector e */ /* of Z using ZGECON, e is normalized and solve for */ /* Zx = +-e - f with the sign giving the greater value of */ /* 2-norm(x). About 5 times as expensive as Default. */ /* IJOB .ne. 2: Local look ahead strategy where */ /* all entries of the r.h.s. b is choosen as either +1 or */ /* -1. Default. */ /* N (input) INTEGER */ /* The number of columns of the matrix Z. */ /* Z (input) DOUBLE PRECISION array, dimension (LDZ, N) */ /* On entry, the LU part of the factorization of the n-by-n */ /* matrix Z computed by ZGETC2: Z = P * L * U * Q */ /* LDZ (input) INTEGER */ /* The leading dimension of the array Z. LDA >= max(1, N). */ /* RHS (input/output) DOUBLE PRECISION array, dimension (N). */ /* On entry, RHS contains contributions from other subsystems. */ /* On exit, RHS contains the solution of the subsystem with */ /* entries according to the value of IJOB (see above). */ /* RDSUM (input/output) DOUBLE PRECISION */ /* On entry, the sum of squares of computed contributions to */ /* the Dif-estimate under computation by ZTGSYL, where the */ /* scaling factor RDSCAL (see below) has been factored out. */ /* On exit, the corresponding sum of squares updated with the */ /* contributions from the current sub-system. */ /* If TRANS = 'T' RDSUM is not touched. */ /* NOTE: RDSUM only makes sense when ZTGSY2 is called by CTGSYL. */ /* RDSCAL (input/output) DOUBLE PRECISION */ /* On entry, scaling factor used to prevent overflow in RDSUM. */ /* On exit, RDSCAL is updated w.r.t. the current contributions */ /* in RDSUM. */ /* If TRANS = 'T', RDSCAL is not touched. */ /* NOTE: RDSCAL only makes sense when ZTGSY2 is called by */ /* ZTGSYL. */ /* IPIV (input) INTEGER array, dimension (N). */ /* The pivot indices; for 1 <= i <= N, row i of the */ /* matrix has been interchanged with row IPIV(i). */ /* JPIV (input) INTEGER array, dimension (N). */ /* The pivot indices; for 1 <= j <= N, column j of the */ /* matrix has been interchanged with column JPIV(j). */ /* Further Details */ /* =============== */ /* Based on contributions by */ /* Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ /* Umea University, S-901 87 Umea, Sweden. */ /* This routine is a further developed implementation of algorithm */ /* BSOLVE in [1] using complete pivoting in the LU factorization. */ /* [1] Bo Kagstrom and Lars Westin, */ /* Generalized Schur Methods with Condition Estimators for */ /* Solving the Generalized Sylvester Equation, IEEE Transactions */ /* on Automatic Control, Vol. 34, No. 7, July 1989, pp 745-751. */ /* [2] Peter Poromaa, */ /* On Efficient and Robust Estimators for the Separation */ /* between two Regular Matrix Pairs with Applications in */ /* Condition Estimation. Report UMINF-95.05, Department of */ /* Computing Science, Umea University, S-901 87 Umea, Sweden, */ /* 1995. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ z_dim1 = *ldz; z_offset = 1 + z_dim1; z__ -= z_offset; --rhs; --ipiv; --jpiv; /* Function Body */ if (*ijob != 2) { /* Apply permutations IPIV to RHS */ i__1 = *n - 1; zlaswp_(&c__1, &rhs[1], ldz, &c__1, &i__1, &ipiv[1], &c__1); /* Solve for L-part choosing RHS either to +1 or -1. */ z__1.r = -1., z__1.i = -0.; pmone.r = z__1.r, pmone.i = z__1.i; i__1 = *n - 1; for (j = 1; j <= i__1; ++j) { i__2 = j; z__1.r = rhs[i__2].r + 1., z__1.i = rhs[i__2].i + 0.; bp.r = z__1.r, bp.i = z__1.i; i__2 = j; z__1.r = rhs[i__2].r - 1., z__1.i = rhs[i__2].i - 0.; bm.r = z__1.r, bm.i = z__1.i; splus = 1.; /* Lockahead for L- part RHS(1:N-1) = +-1 */ /* SPLUS and SMIN computed more efficiently than in BSOLVE[1]. */ i__2 = *n - j; zdotc_(&z__1, &i__2, &z__[j + 1 + j * z_dim1], &c__1, &z__[j + 1 + j * z_dim1], &c__1); splus += z__1.r; i__2 = *n - j; zdotc_(&z__1, &i__2, &z__[j + 1 + j * z_dim1], &c__1, &rhs[j + 1], &c__1); sminu = z__1.r; i__2 = j; splus *= rhs[i__2].r; if (splus > sminu) { i__2 = j; rhs[i__2].r = bp.r, rhs[i__2].i = bp.i; } else if (sminu > splus) { i__2 = j; rhs[i__2].r = bm.r, rhs[i__2].i = bm.i; } else { /* In this case the updating sums are equal and we can */ /* choose RHS(J) +1 or -1. The first time this happens we */ /* choose -1, thereafter +1. This is a simple way to get */ /* good estimates of matrices like Byers well-known example */ /* (see [1]). (Not done in BSOLVE.) */ i__2 = j; i__3 = j; z__1.r = rhs[i__3].r + pmone.r, z__1.i = rhs[i__3].i + pmone.i; rhs[i__2].r = z__1.r, rhs[i__2].i = z__1.i; pmone.r = 1., pmone.i = 0.; } /* Compute the remaining r.h.s. */ i__2 = j; z__1.r = -rhs[i__2].r, z__1.i = -rhs[i__2].i; temp.r = z__1.r, temp.i = z__1.i; i__2 = *n - j; zaxpy_(&i__2, &temp, &z__[j + 1 + j * z_dim1], &c__1, &rhs[j + 1], &c__1); /* L10: */ } /* Solve for U- part, lockahead for RHS(N) = +-1. This is not done */ /* In BSOLVE and will hopefully give us a better estimate because */ /* any ill-conditioning of the original matrix is transfered to U */ /* and not to L. U(N, N) is an approximation to sigma_min(LU). */ i__1 = *n - 1; zcopy_(&i__1, &rhs[1], &c__1, work, &c__1); i__1 = *n - 1; i__2 = *n; z__1.r = rhs[i__2].r + 1., z__1.i = rhs[i__2].i + 0.; work[i__1].r = z__1.r, work[i__1].i = z__1.i; i__1 = *n; i__2 = *n; z__1.r = rhs[i__2].r - 1., z__1.i = rhs[i__2].i - 0.; rhs[i__1].r = z__1.r, rhs[i__1].i = z__1.i; splus = 0.; sminu = 0.; for (i__ = *n; i__ >= 1; --i__) { z_div(&z__1, &c_b1, &z__[i__ + i__ * z_dim1]); temp.r = z__1.r, temp.i = z__1.i; i__1 = i__ - 1; i__2 = i__ - 1; z__1.r = work[i__2].r * temp.r - work[i__2].i * temp.i, z__1.i = work[i__2].r * temp.i + work[i__2].i * temp.r; work[i__1].r = z__1.r, work[i__1].i = z__1.i; i__1 = i__; i__2 = i__; z__1.r = rhs[i__2].r * temp.r - rhs[i__2].i * temp.i, z__1.i = rhs[i__2].r * temp.i + rhs[i__2].i * temp.r; rhs[i__1].r = z__1.r, rhs[i__1].i = z__1.i; i__1 = *n; for (k = i__ + 1; k <= i__1; ++k) { i__2 = i__ - 1; i__3 = i__ - 1; i__4 = k - 1; i__5 = i__ + k * z_dim1; z__3.r = z__[i__5].r * temp.r - z__[i__5].i * temp.i, z__3.i = z__[i__5].r * temp.i + z__[i__5].i * temp.r; z__2.r = work[i__4].r * z__3.r - work[i__4].i * z__3.i, z__2.i = work[i__4].r * z__3.i + work[i__4].i * z__3.r; z__1.r = work[i__3].r - z__2.r, z__1.i = work[i__3].i - z__2.i; work[i__2].r = z__1.r, work[i__2].i = z__1.i; i__2 = i__; i__3 = i__; i__4 = k; i__5 = i__ + k * z_dim1; z__3.r = z__[i__5].r * temp.r - z__[i__5].i * temp.i, z__3.i = z__[i__5].r * temp.i + z__[i__5].i * temp.r; z__2.r = rhs[i__4].r * z__3.r - rhs[i__4].i * z__3.i, z__2.i = rhs[i__4].r * z__3.i + rhs[i__4].i * z__3.r; z__1.r = rhs[i__3].r - z__2.r, z__1.i = rhs[i__3].i - z__2.i; rhs[i__2].r = z__1.r, rhs[i__2].i = z__1.i; /* L20: */ } splus += z_abs(&work[i__ - 1]); sminu += z_abs(&rhs[i__]); /* L30: */ } if (splus > sminu) { zcopy_(n, work, &c__1, &rhs[1], &c__1); } /* Apply the permutations JPIV to the computed solution (RHS) */ i__1 = *n - 1; zlaswp_(&c__1, &rhs[1], ldz, &c__1, &i__1, &jpiv[1], &c_n1); /* Compute the sum of squares */ zlassq_(n, &rhs[1], &c__1, rdscal, rdsum); return 0; } /* ENTRY IJOB = 2 */ /* Compute approximate nullvector XM of Z */ zgecon_("I", n, &z__[z_offset], ldz, &c_b24, &rtemp, work, rwork, &info); zcopy_(n, &work[*n], &c__1, xm, &c__1); /* Compute RHS */ i__1 = *n - 1; zlaswp_(&c__1, xm, ldz, &c__1, &i__1, &ipiv[1], &c_n1); zdotc_(&z__3, n, xm, &c__1, xm, &c__1); z_sqrt(&z__2, &z__3); z_div(&z__1, &c_b1, &z__2); temp.r = z__1.r, temp.i = z__1.i; zscal_(n, &temp, xm, &c__1); zcopy_(n, xm, &c__1, xp, &c__1); zaxpy_(n, &c_b1, &rhs[1], &c__1, xp, &c__1); z__1.r = -1., z__1.i = -0.; zaxpy_(n, &z__1, xm, &c__1, &rhs[1], &c__1); zgesc2_(n, &z__[z_offset], ldz, &rhs[1], &ipiv[1], &jpiv[1], &scale); zgesc2_(n, &z__[z_offset], ldz, xp, &ipiv[1], &jpiv[1], &scale); if (dzasum_(n, xp, &c__1) > dzasum_(n, &rhs[1], &c__1)) { zcopy_(n, xp, &c__1, &rhs[1], &c__1); } /* Compute the sum of squares */ zlassq_(n, &rhs[1], &c__1, rdscal, rdsum); return 0; /* End of ZLATDF */ } /* zlatdf_ */
int ztgsy2_(char *trans, int *ijob, int *m, int * n, doublecomplex *a, int *lda, doublecomplex *b, int *ldb, doublecomplex *c__, int *ldc, doublecomplex *d__, int *ldd, doublecomplex *e, int *lde, doublecomplex *f, int *ldf, double *scale, double *rdsum, double *rdscal, int * info) { /* System generated locals */ int a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1, d_offset, e_dim1, e_offset, f_dim1, f_offset, i__1, i__2, i__3, i__4; doublecomplex z__1, z__2, z__3, z__4, z__5, z__6; /* Builtin functions */ void d_cnjg(doublecomplex *, doublecomplex *); /* Local variables */ int i__, j, k; doublecomplex z__[4] /* was [2][2] */, rhs[2]; int ierr, ipiv[2], jpiv[2]; doublecomplex alpha; extern int lsame_(char *, char *); extern int zscal_(int *, doublecomplex *, doublecomplex *, int *), zaxpy_(int *, doublecomplex *, doublecomplex *, int *, doublecomplex *, int *), zgesc2_( int *, doublecomplex *, int *, doublecomplex *, int *, int *, double *), zgetc2_(int *, doublecomplex *, int *, int *, int *, int *); double scaloc; extern int xerbla_(char *, int *), zlatdf_( int *, int *, doublecomplex *, int *, doublecomplex *, double *, double *, int *, int *); int notran; /* -- LAPACK auxiliary routine (version 3.2) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* ZTGSY2 solves the generalized Sylvester equation */ /* A * R - L * B = scale * C (1) */ /* D * R - L * E = scale * F */ /* using Level 1 and 2 BLAS, where R and L are unknown M-by-N matrices, */ /* (A, D), (B, E) and (C, F) are given matrix pairs of size M-by-M, */ /* N-by-N and M-by-N, respectively. A, B, D and E are upper triangular */ /* (i.e., (A,D) and (B,E) in generalized Schur form). */ /* The solution (R, L) overwrites (C, F). 0 <= SCALE <= 1 is an output */ /* scaling factor chosen to avoid overflow. */ /* In matrix notation solving equation (1) corresponds to solve */ /* Zx = scale * b, where Z is defined as */ /* Z = [ kron(In, A) -kron(B', Im) ] (2) */ /* [ kron(In, D) -kron(E', Im) ], */ /* Ik is the identity matrix of size k and X' is the transpose of X. */ /* kron(X, Y) is the Kronecker product between the matrices X and Y. */ /* If TRANS = 'C', y in the conjugate transposed system Z'y = scale*b */ /* is solved for, which is equivalent to solve for R and L in */ /* A' * R + D' * L = scale * C (3) */ /* R * B' + L * E' = scale * -F */ /* This case is used to compute an estimate of Dif[(A, D), (B, E)] = */ /* = sigma_MIN(Z) using reverse communicaton with ZLACON. */ /* ZTGSY2 also (IJOB >= 1) contributes to the computation in ZTGSYL */ /* of an upper bound on the separation between to matrix pairs. Then */ /* the input (A, D), (B, E) are sub-pencils of two matrix pairs in */ /* ZTGSYL. */ /* Arguments */ /* ========= */ /* TRANS (input) CHARACTER*1 */ /* = 'N', solve the generalized Sylvester equation (1). */ /* = 'T': solve the 'transposed' system (3). */ /* IJOB (input) INTEGER */ /* Specifies what kind of functionality to be performed. */ /* =0: solve (1) only. */ /* =1: A contribution from this subsystem to a Frobenius */ /* norm-based estimate of the separation between two matrix */ /* pairs is computed. (look ahead strategy is used). */ /* =2: A contribution from this subsystem to a Frobenius */ /* norm-based estimate of the separation between two matrix */ /* pairs is computed. (DGECON on sub-systems is used.) */ /* Not referenced if TRANS = 'T'. */ /* M (input) INTEGER */ /* On entry, M specifies the order of A and D, and the row */ /* dimension of C, F, R and L. */ /* N (input) INTEGER */ /* On entry, N specifies the order of B and E, and the column */ /* dimension of C, F, R and L. */ /* A (input) COMPLEX*16 array, dimension (LDA, M) */ /* On entry, A contains an upper triangular matrix. */ /* LDA (input) INTEGER */ /* The leading dimension of the matrix A. LDA >= MAX(1, M). */ /* B (input) COMPLEX*16 array, dimension (LDB, N) */ /* On entry, B contains an upper triangular matrix. */ /* LDB (input) INTEGER */ /* The leading dimension of the matrix B. LDB >= MAX(1, N). */ /* C (input/output) COMPLEX*16 array, dimension (LDC, N) */ /* On entry, C contains the right-hand-side of the first matrix */ /* equation in (1). */ /* On exit, if IJOB = 0, C has been overwritten by the solution */ /* R. */ /* LDC (input) INTEGER */ /* The leading dimension of the matrix C. LDC >= MAX(1, M). */ /* D (input) COMPLEX*16 array, dimension (LDD, M) */ /* On entry, D contains an upper triangular matrix. */ /* LDD (input) INTEGER */ /* The leading dimension of the matrix D. LDD >= MAX(1, M). */ /* E (input) COMPLEX*16 array, dimension (LDE, N) */ /* On entry, E contains an upper triangular matrix. */ /* LDE (input) INTEGER */ /* The leading dimension of the matrix E. LDE >= MAX(1, N). */ /* F (input/output) COMPLEX*16 array, dimension (LDF, N) */ /* On entry, F contains the right-hand-side of the second matrix */ /* equation in (1). */ /* On exit, if IJOB = 0, F has been overwritten by the solution */ /* L. */ /* LDF (input) INTEGER */ /* The leading dimension of the matrix F. LDF >= MAX(1, M). */ /* SCALE (output) DOUBLE PRECISION */ /* On exit, 0 <= SCALE <= 1. If 0 < SCALE < 1, the solutions */ /* R and L (C and F on entry) will hold the solutions to a */ /* slightly perturbed system but the input matrices A, B, D and */ /* E have not been changed. If SCALE = 0, R and L will hold the */ /* solutions to the homogeneous system with C = F = 0. */ /* Normally, SCALE = 1. */ /* RDSUM (input/output) DOUBLE PRECISION */ /* On entry, the sum of squares of computed contributions to */ /* the Dif-estimate under computation by ZTGSYL, where the */ /* scaling factor RDSCAL (see below) has been factored out. */ /* On exit, the corresponding sum of squares updated with the */ /* contributions from the current sub-system. */ /* If TRANS = 'T' RDSUM is not touched. */ /* NOTE: RDSUM only makes sense when ZTGSY2 is called by */ /* ZTGSYL. */ /* RDSCAL (input/output) DOUBLE PRECISION */ /* On entry, scaling factor used to prevent overflow in RDSUM. */ /* On exit, RDSCAL is updated w.r.t. the current contributions */ /* in RDSUM. */ /* If TRANS = 'T', RDSCAL is not touched. */ /* NOTE: RDSCAL only makes sense when ZTGSY2 is called by */ /* ZTGSYL. */ /* INFO (output) INTEGER */ /* On exit, if INFO is set to */ /* =0: Successful exit */ /* <0: If INFO = -i, input argument number i is illegal. */ /* >0: The matrix pairs (A, D) and (B, E) have common or very */ /* close eigenvalues. */ /* Further Details */ /* =============== */ /* Based on contributions by */ /* Bo Kagstrom and Peter Poromaa, Department of Computing Science, */ /* Umea University, S-901 87 Umea, Sweden. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Decode and test input parameters */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1; b -= b_offset; c_dim1 = *ldc; c_offset = 1 + c_dim1; c__ -= c_offset; d_dim1 = *ldd; d_offset = 1 + d_dim1; d__ -= d_offset; e_dim1 = *lde; e_offset = 1 + e_dim1; e -= e_offset; f_dim1 = *ldf; f_offset = 1 + f_dim1; f -= f_offset; /* Function Body */ *info = 0; ierr = 0; notran = lsame_(trans, "N"); if (! notran && ! lsame_(trans, "C")) { *info = -1; } else if (notran) { if (*ijob < 0 || *ijob > 2) { *info = -2; } } if (*info == 0) { if (*m <= 0) { *info = -3; } else if (*n <= 0) { *info = -4; } else if (*lda < MAX(1,*m)) { *info = -5; } else if (*ldb < MAX(1,*n)) { *info = -8; } else if (*ldc < MAX(1,*m)) { *info = -10; } else if (*ldd < MAX(1,*m)) { *info = -12; } else if (*lde < MAX(1,*n)) { *info = -14; } else if (*ldf < MAX(1,*m)) { *info = -16; } } if (*info != 0) { i__1 = -(*info); xerbla_("ZTGSY2", &i__1); return 0; } if (notran) { /* Solve (I, J) - system */ /* A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J) */ /* D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J) */ /* for I = M, M - 1, ..., 1; J = 1, 2, ..., N */ *scale = 1.; scaloc = 1.; i__1 = *n; for (j = 1; j <= i__1; ++j) { for (i__ = *m; i__ >= 1; --i__) { /* Build 2 by 2 system */ i__2 = i__ + i__ * a_dim1; z__[0].r = a[i__2].r, z__[0].i = a[i__2].i; i__2 = i__ + i__ * d_dim1; z__[1].r = d__[i__2].r, z__[1].i = d__[i__2].i; i__2 = j + j * b_dim1; z__1.r = -b[i__2].r, z__1.i = -b[i__2].i; z__[2].r = z__1.r, z__[2].i = z__1.i; i__2 = j + j * e_dim1; z__1.r = -e[i__2].r, z__1.i = -e[i__2].i; z__[3].r = z__1.r, z__[3].i = z__1.i; /* Set up right hand side(s) */ i__2 = i__ + j * c_dim1; rhs[0].r = c__[i__2].r, rhs[0].i = c__[i__2].i; i__2 = i__ + j * f_dim1; rhs[1].r = f[i__2].r, rhs[1].i = f[i__2].i; /* Solve Z * x = RHS */ zgetc2_(&c__2, z__, &c__2, ipiv, jpiv, &ierr); if (ierr > 0) { *info = ierr; } if (*ijob == 0) { zgesc2_(&c__2, z__, &c__2, rhs, ipiv, jpiv, &scaloc); if (scaloc != 1.) { i__2 = *n; for (k = 1; k <= i__2; ++k) { z__1.r = scaloc, z__1.i = 0.; zscal_(m, &z__1, &c__[k * c_dim1 + 1], &c__1); z__1.r = scaloc, z__1.i = 0.; zscal_(m, &z__1, &f[k * f_dim1 + 1], &c__1); /* L10: */ } *scale *= scaloc; } } else { zlatdf_(ijob, &c__2, z__, &c__2, rhs, rdsum, rdscal, ipiv, jpiv); } /* Unpack solution vector(s) */ i__2 = i__ + j * c_dim1; c__[i__2].r = rhs[0].r, c__[i__2].i = rhs[0].i; i__2 = i__ + j * f_dim1; f[i__2].r = rhs[1].r, f[i__2].i = rhs[1].i; /* Substitute R(I, J) and L(I, J) into remaining equation. */ if (i__ > 1) { z__1.r = -rhs[0].r, z__1.i = -rhs[0].i; alpha.r = z__1.r, alpha.i = z__1.i; i__2 = i__ - 1; zaxpy_(&i__2, &alpha, &a[i__ * a_dim1 + 1], &c__1, &c__[j * c_dim1 + 1], &c__1); i__2 = i__ - 1; zaxpy_(&i__2, &alpha, &d__[i__ * d_dim1 + 1], &c__1, &f[j * f_dim1 + 1], &c__1); } if (j < *n) { i__2 = *n - j; zaxpy_(&i__2, &rhs[1], &b[j + (j + 1) * b_dim1], ldb, & c__[i__ + (j + 1) * c_dim1], ldc); i__2 = *n - j; zaxpy_(&i__2, &rhs[1], &e[j + (j + 1) * e_dim1], lde, &f[ i__ + (j + 1) * f_dim1], ldf); } /* L20: */ } /* L30: */ } } else { /* Solve transposed (I, J) - system: */ /* A(I, I)' * R(I, J) + D(I, I)' * L(J, J) = C(I, J) */ /* R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J) */ /* for I = 1, 2, ..., M, J = N, N - 1, ..., 1 */ *scale = 1.; scaloc = 1.; i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { for (j = *n; j >= 1; --j) { /* Build 2 by 2 system Z' */ d_cnjg(&z__1, &a[i__ + i__ * a_dim1]); z__[0].r = z__1.r, z__[0].i = z__1.i; d_cnjg(&z__2, &b[j + j * b_dim1]); z__1.r = -z__2.r, z__1.i = -z__2.i; z__[1].r = z__1.r, z__[1].i = z__1.i; d_cnjg(&z__1, &d__[i__ + i__ * d_dim1]); z__[2].r = z__1.r, z__[2].i = z__1.i; d_cnjg(&z__2, &e[j + j * e_dim1]); z__1.r = -z__2.r, z__1.i = -z__2.i; z__[3].r = z__1.r, z__[3].i = z__1.i; /* Set up right hand side(s) */ i__2 = i__ + j * c_dim1; rhs[0].r = c__[i__2].r, rhs[0].i = c__[i__2].i; i__2 = i__ + j * f_dim1; rhs[1].r = f[i__2].r, rhs[1].i = f[i__2].i; /* Solve Z' * x = RHS */ zgetc2_(&c__2, z__, &c__2, ipiv, jpiv, &ierr); if (ierr > 0) { *info = ierr; } zgesc2_(&c__2, z__, &c__2, rhs, ipiv, jpiv, &scaloc); if (scaloc != 1.) { i__2 = *n; for (k = 1; k <= i__2; ++k) { z__1.r = scaloc, z__1.i = 0.; zscal_(m, &z__1, &c__[k * c_dim1 + 1], &c__1); z__1.r = scaloc, z__1.i = 0.; zscal_(m, &z__1, &f[k * f_dim1 + 1], &c__1); /* L40: */ } *scale *= scaloc; } /* Unpack solution vector(s) */ i__2 = i__ + j * c_dim1; c__[i__2].r = rhs[0].r, c__[i__2].i = rhs[0].i; i__2 = i__ + j * f_dim1; f[i__2].r = rhs[1].r, f[i__2].i = rhs[1].i; /* Substitute R(I, J) and L(I, J) into remaining equation. */ i__2 = j - 1; for (k = 1; k <= i__2; ++k) { i__3 = i__ + k * f_dim1; i__4 = i__ + k * f_dim1; d_cnjg(&z__4, &b[k + j * b_dim1]); z__3.r = rhs[0].r * z__4.r - rhs[0].i * z__4.i, z__3.i = rhs[0].r * z__4.i + rhs[0].i * z__4.r; z__2.r = f[i__4].r + z__3.r, z__2.i = f[i__4].i + z__3.i; d_cnjg(&z__6, &e[k + j * e_dim1]); z__5.r = rhs[1].r * z__6.r - rhs[1].i * z__6.i, z__5.i = rhs[1].r * z__6.i + rhs[1].i * z__6.r; z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i; f[i__3].r = z__1.r, f[i__3].i = z__1.i; /* L50: */ } i__2 = *m; for (k = i__ + 1; k <= i__2; ++k) { i__3 = k + j * c_dim1; i__4 = k + j * c_dim1; d_cnjg(&z__4, &a[i__ + k * a_dim1]); z__3.r = z__4.r * rhs[0].r - z__4.i * rhs[0].i, z__3.i = z__4.r * rhs[0].i + z__4.i * rhs[0].r; z__2.r = c__[i__4].r - z__3.r, z__2.i = c__[i__4].i - z__3.i; d_cnjg(&z__6, &d__[i__ + k * d_dim1]); z__5.r = z__6.r * rhs[1].r - z__6.i * rhs[1].i, z__5.i = z__6.r * rhs[1].i + z__6.i * rhs[1].r; z__1.r = z__2.r - z__5.r, z__1.i = z__2.i - z__5.i; c__[i__3].r = z__1.r, c__[i__3].i = z__1.i; /* L60: */ } /* L70: */ } /* L80: */ } } return 0; /* End of ZTGSY2 */ } /* ztgsy2_ */