cgesvx.c
Go to the documentation of this file.
00001 /* cgesvx.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 /* Subroutine */ int cgesvx_(char *fact, char *trans, integer *n, integer *
00017         nrhs, complex *a, integer *lda, complex *af, integer *ldaf, integer *
00018         ipiv, char *equed, real *r__, real *c__, complex *b, integer *ldb, 
00019         complex *x, integer *ldx, real *rcond, real *ferr, real *berr, 
00020         complex *work, real *rwork, integer *info)
00021 {
00022     /* System generated locals */
00023     integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, 
00024             x_offset, i__1, i__2, i__3, i__4, i__5;
00025     real r__1, r__2;
00026     complex q__1;
00027 
00028     /* Local variables */
00029     integer i__, j;
00030     real amax;
00031     char norm[1];
00032     extern logical lsame_(char *, char *);
00033     real rcmin, rcmax, anorm;
00034     logical equil;
00035     extern doublereal clange_(char *, integer *, integer *, complex *, 
00036             integer *, real *);
00037     extern /* Subroutine */ int claqge_(integer *, integer *, complex *, 
00038             integer *, real *, real *, real *, real *, real *, char *)
00039             , cgecon_(char *, integer *, complex *, integer *, real *, real *, 
00040              complex *, real *, integer *);
00041     real colcnd;
00042     extern doublereal slamch_(char *);
00043     extern /* Subroutine */ int cgeequ_(integer *, integer *, complex *, 
00044             integer *, real *, real *, real *, real *, real *, integer *);
00045     logical nofact;
00046     extern /* Subroutine */ int cgerfs_(char *, integer *, integer *, complex 
00047             *, integer *, complex *, integer *, integer *, complex *, integer 
00048             *, complex *, integer *, real *, real *, complex *, real *, 
00049             integer *), cgetrf_(integer *, integer *, complex *, 
00050             integer *, integer *, integer *), clacpy_(char *, integer *, 
00051             integer *, complex *, integer *, complex *, integer *), 
00052             xerbla_(char *, integer *);
00053     real bignum;
00054     extern doublereal clantr_(char *, char *, char *, integer *, integer *, 
00055             complex *, integer *, real *);
00056     integer infequ;
00057     logical colequ;
00058     extern /* Subroutine */ int cgetrs_(char *, integer *, integer *, complex 
00059             *, integer *, integer *, complex *, integer *, integer *);
00060     real rowcnd;
00061     logical notran;
00062     real smlnum;
00063     logical rowequ;
00064     real rpvgrw;
00065 
00066 
00067 /*  -- LAPACK driver routine (version 3.2) -- */
00068 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00069 /*     November 2006 */
00070 
00071 /*     .. Scalar Arguments .. */
00072 /*     .. */
00073 /*     .. Array Arguments .. */
00074 /*     .. */
00075 
00076 /*  Purpose */
00077 /*  ======= */
00078 
00079 /*  CGESVX uses the LU factorization to compute the solution to a complex */
00080 /*  system of linear equations */
00081 /*     A * X = B, */
00082 /*  where A is an N-by-N matrix and X and B are N-by-NRHS matrices. */
00083 
00084 /*  Error bounds on the solution and a condition estimate are also */
00085 /*  provided. */
00086 
00087 /*  Description */
00088 /*  =========== */
00089 
00090 /*  The following steps are performed: */
00091 
00092 /*  1. If FACT = 'E', real scaling factors are computed to equilibrate */
00093 /*     the system: */
00094 /*        TRANS = 'N':  diag(R)*A*diag(C)     *inv(diag(C))*X = diag(R)*B */
00095 /*        TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B */
00096 /*        TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B */
00097 /*     Whether or not the system will be equilibrated depends on the */
00098 /*     scaling of the matrix A, but if equilibration is used, A is */
00099 /*     overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N') */
00100 /*     or diag(C)*B (if TRANS = 'T' or 'C'). */
00101 
00102 /*  2. If FACT = 'N' or 'E', the LU decomposition is used to factor the */
00103 /*     matrix A (after equilibration if FACT = 'E') as */
00104 /*        A = P * L * U, */
00105 /*     where P is a permutation matrix, L is a unit lower triangular */
00106 /*     matrix, and U is upper triangular. */
00107 
00108 /*  3. If some U(i,i)=0, so that U is exactly singular, then the routine */
00109 /*     returns with INFO = i. Otherwise, the factored form of A is used */
00110 /*     to estimate the condition number of the matrix A.  If the */
00111 /*     reciprocal of the condition number is less than machine precision, */
00112 /*     INFO = N+1 is returned as a warning, but the routine still goes on */
00113 /*     to solve for X and compute error bounds as described below. */
00114 
00115 /*  4. The system of equations is solved for X using the factored form */
00116 /*     of A. */
00117 
00118 /*  5. Iterative refinement is applied to improve the computed solution */
00119 /*     matrix and calculate error bounds and backward error estimates */
00120 /*     for it. */
00121 
00122 /*  6. If equilibration was used, the matrix X is premultiplied by */
00123 /*     diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so */
00124 /*     that it solves the original system before equilibration. */
00125 
00126 /*  Arguments */
00127 /*  ========= */
00128 
00129 /*  FACT    (input) CHARACTER*1 */
00130 /*          Specifies whether or not the factored form of the matrix A is */
00131 /*          supplied on entry, and if not, whether the matrix A should be */
00132 /*          equilibrated before it is factored. */
00133 /*          = 'F':  On entry, AF and IPIV contain the factored form of A. */
00134 /*                  If EQUED is not 'N', the matrix A has been */
00135 /*                  equilibrated with scaling factors given by R and C. */
00136 /*                  A, AF, and IPIV are not modified. */
00137 /*          = 'N':  The matrix A will be copied to AF and factored. */
00138 /*          = 'E':  The matrix A will be equilibrated if necessary, then */
00139 /*                  copied to AF and factored. */
00140 
00141 /*  TRANS   (input) CHARACTER*1 */
00142 /*          Specifies the form of the system of equations: */
00143 /*          = 'N':  A * X = B     (No transpose) */
00144 /*          = 'T':  A**T * X = B  (Transpose) */
00145 /*          = 'C':  A**H * X = B  (Conjugate transpose) */
00146 
00147 /*  N       (input) INTEGER */
00148 /*          The number of linear equations, i.e., the order of the */
00149 /*          matrix A.  N >= 0. */
00150 
00151 /*  NRHS    (input) INTEGER */
00152 /*          The number of right hand sides, i.e., the number of columns */
00153 /*          of the matrices B and X.  NRHS >= 0. */
00154 
00155 /*  A       (input/output) COMPLEX array, dimension (LDA,N) */
00156 /*          On entry, the N-by-N matrix A.  If FACT = 'F' and EQUED is */
00157 /*          not 'N', then A must have been equilibrated by the scaling */
00158 /*          factors in R and/or C.  A is not modified if FACT = 'F' or */
00159 /*          'N', or if FACT = 'E' and EQUED = 'N' on exit. */
00160 
00161 /*          On exit, if EQUED .ne. 'N', A is scaled as follows: */
00162 /*          EQUED = 'R':  A := diag(R) * A */
00163 /*          EQUED = 'C':  A := A * diag(C) */
00164 /*          EQUED = 'B':  A := diag(R) * A * diag(C). */
00165 
00166 /*  LDA     (input) INTEGER */
00167 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00168 
00169 /*  AF      (input or output) COMPLEX array, dimension (LDAF,N) */
00170 /*          If FACT = 'F', then AF is an input argument and on entry */
00171 /*          contains the factors L and U from the factorization */
00172 /*          A = P*L*U as computed by CGETRF.  If EQUED .ne. 'N', then */
00173 /*          AF is the factored form of the equilibrated matrix A. */
00174 
00175 /*          If FACT = 'N', then AF is an output argument and on exit */
00176 /*          returns the factors L and U from the factorization A = P*L*U */
00177 /*          of the original matrix A. */
00178 
00179 /*          If FACT = 'E', then AF is an output argument and on exit */
00180 /*          returns the factors L and U from the factorization A = P*L*U */
00181 /*          of the equilibrated matrix A (see the description of A for */
00182 /*          the form of the equilibrated matrix). */
00183 
00184 /*  LDAF    (input) INTEGER */
00185 /*          The leading dimension of the array AF.  LDAF >= max(1,N). */
00186 
00187 /*  IPIV    (input or output) INTEGER array, dimension (N) */
00188 /*          If FACT = 'F', then IPIV is an input argument and on entry */
00189 /*          contains the pivot indices from the factorization A = P*L*U */
00190 /*          as computed by CGETRF; row i of the matrix was interchanged */
00191 /*          with row IPIV(i). */
00192 
00193 /*          If FACT = 'N', then IPIV is an output argument and on exit */
00194 /*          contains the pivot indices from the factorization A = P*L*U */
00195 /*          of the original matrix A. */
00196 
00197 /*          If FACT = 'E', then IPIV is an output argument and on exit */
00198 /*          contains the pivot indices from the factorization A = P*L*U */
00199 /*          of the equilibrated matrix A. */
00200 
00201 /*  EQUED   (input or output) CHARACTER*1 */
00202 /*          Specifies the form of equilibration that was done. */
00203 /*          = 'N':  No equilibration (always true if FACT = 'N'). */
00204 /*          = 'R':  Row equilibration, i.e., A has been premultiplied by */
00205 /*                  diag(R). */
00206 /*          = 'C':  Column equilibration, i.e., A has been postmultiplied */
00207 /*                  by diag(C). */
00208 /*          = 'B':  Both row and column equilibration, i.e., A has been */
00209 /*                  replaced by diag(R) * A * diag(C). */
00210 /*          EQUED is an input argument if FACT = 'F'; otherwise, it is an */
00211 /*          output argument. */
00212 
00213 /*  R       (input or output) REAL array, dimension (N) */
00214 /*          The row scale factors for A.  If EQUED = 'R' or 'B', A is */
00215 /*          multiplied on the left by diag(R); if EQUED = 'N' or 'C', R */
00216 /*          is not accessed.  R is an input argument if FACT = 'F'; */
00217 /*          otherwise, R is an output argument.  If FACT = 'F' and */
00218 /*          EQUED = 'R' or 'B', each element of R must be positive. */
00219 
00220 /*  C       (input or output) REAL array, dimension (N) */
00221 /*          The column scale factors for A.  If EQUED = 'C' or 'B', A is */
00222 /*          multiplied on the right by diag(C); if EQUED = 'N' or 'R', C */
00223 /*          is not accessed.  C is an input argument if FACT = 'F'; */
00224 /*          otherwise, C is an output argument.  If FACT = 'F' and */
00225 /*          EQUED = 'C' or 'B', each element of C must be positive. */
00226 
00227 /*  B       (input/output) COMPLEX array, dimension (LDB,NRHS) */
00228 /*          On entry, the N-by-NRHS right hand side matrix B. */
00229 /*          On exit, */
00230 /*          if EQUED = 'N', B is not modified; */
00231 /*          if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by */
00232 /*          diag(R)*B; */
00233 /*          if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is */
00234 /*          overwritten by diag(C)*B. */
00235 
00236 /*  LDB     (input) INTEGER */
00237 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00238 
00239 /*  X       (output) COMPLEX array, dimension (LDX,NRHS) */
00240 /*          If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X */
00241 /*          to the original system of equations.  Note that A and B are */
00242 /*          modified on exit if EQUED .ne. 'N', and the solution to the */
00243 /*          equilibrated system is inv(diag(C))*X if TRANS = 'N' and */
00244 /*          EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C' */
00245 /*          and EQUED = 'R' or 'B'. */
00246 
00247 /*  LDX     (input) INTEGER */
00248 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00249 
00250 /*  RCOND   (output) REAL */
00251 /*          The estimate of the reciprocal condition number of the matrix */
00252 /*          A after equilibration (if done).  If RCOND is less than the */
00253 /*          machine precision (in particular, if RCOND = 0), the matrix */
00254 /*          is singular to working precision.  This condition is */
00255 /*          indicated by a return code of INFO > 0. */
00256 
00257 /*  FERR    (output) REAL array, dimension (NRHS) */
00258 /*          The estimated forward error bound for each solution vector */
00259 /*          X(j) (the j-th column of the solution matrix X). */
00260 /*          If XTRUE is the true solution corresponding to X(j), FERR(j) */
00261 /*          is an estimated upper bound for the magnitude of the largest */
00262 /*          element in (X(j) - XTRUE) divided by the magnitude of the */
00263 /*          largest element in X(j).  The estimate is as reliable as */
00264 /*          the estimate for RCOND, and is almost always a slight */
00265 /*          overestimate of the true error. */
00266 
00267 /*  BERR    (output) REAL array, dimension (NRHS) */
00268 /*          The componentwise relative backward error of each solution */
00269 /*          vector X(j) (i.e., the smallest relative change in */
00270 /*          any element of A or B that makes X(j) an exact solution). */
00271 
00272 /*  WORK    (workspace) COMPLEX array, dimension (2*N) */
00273 
00274 /*  RWORK   (workspace/output) REAL array, dimension (2*N) */
00275 /*          On exit, RWORK(1) contains the reciprocal pivot growth */
00276 /*          factor norm(A)/norm(U). The "max absolute element" norm is */
00277 /*          used. If RWORK(1) is much less than 1, then the stability */
00278 /*          of the LU factorization of the (equilibrated) matrix A */
00279 /*          could be poor. This also means that the solution X, condition */
00280 /*          estimator RCOND, and forward error bound FERR could be */
00281 /*          unreliable. If factorization fails with 0<INFO<=N, then */
00282 /*          RWORK(1) contains the reciprocal pivot growth factor for the */
00283 /*          leading INFO columns of A. */
00284 
00285 /*  INFO    (output) INTEGER */
00286 /*          = 0:  successful exit */
00287 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00288 /*          > 0:  if INFO = i, and i is */
00289 /*                <= N:  U(i,i) is exactly zero.  The factorization has */
00290 /*                       been completed, but the factor U is exactly */
00291 /*                       singular, so the solution and error bounds */
00292 /*                       could not be computed. RCOND = 0 is returned. */
00293 /*                = N+1: U is nonsingular, but RCOND is less than machine */
00294 /*                       precision, meaning that the matrix is singular */
00295 /*                       to working precision.  Nevertheless, the */
00296 /*                       solution and error bounds are computed because */
00297 /*                       there are a number of situations where the */
00298 /*                       computed solution can be more accurate than the */
00299 /*                       value of RCOND would suggest. */
00300 
00301 /*  ===================================================================== */
00302 
00303 /*     .. Parameters .. */
00304 /*     .. */
00305 /*     .. Local Scalars .. */
00306 /*     .. */
00307 /*     .. External Functions .. */
00308 /*     .. */
00309 /*     .. External Subroutines .. */
00310 /*     .. */
00311 /*     .. Intrinsic Functions .. */
00312 /*     .. */
00313 /*     .. Executable Statements .. */
00314 
00315     /* Parameter adjustments */
00316     a_dim1 = *lda;
00317     a_offset = 1 + a_dim1;
00318     a -= a_offset;
00319     af_dim1 = *ldaf;
00320     af_offset = 1 + af_dim1;
00321     af -= af_offset;
00322     --ipiv;
00323     --r__;
00324     --c__;
00325     b_dim1 = *ldb;
00326     b_offset = 1 + b_dim1;
00327     b -= b_offset;
00328     x_dim1 = *ldx;
00329     x_offset = 1 + x_dim1;
00330     x -= x_offset;
00331     --ferr;
00332     --berr;
00333     --work;
00334     --rwork;
00335 
00336     /* Function Body */
00337     *info = 0;
00338     nofact = lsame_(fact, "N");
00339     equil = lsame_(fact, "E");
00340     notran = lsame_(trans, "N");
00341     if (nofact || equil) {
00342         *(unsigned char *)equed = 'N';
00343         rowequ = FALSE_;
00344         colequ = FALSE_;
00345     } else {
00346         rowequ = lsame_(equed, "R") || lsame_(equed, 
00347                 "B");
00348         colequ = lsame_(equed, "C") || lsame_(equed, 
00349                 "B");
00350         smlnum = slamch_("Safe minimum");
00351         bignum = 1.f / smlnum;
00352     }
00353 
00354 /*     Test the input parameters. */
00355 
00356     if (! nofact && ! equil && ! lsame_(fact, "F")) {
00357         *info = -1;
00358     } else if (! notran && ! lsame_(trans, "T") && ! 
00359             lsame_(trans, "C")) {
00360         *info = -2;
00361     } else if (*n < 0) {
00362         *info = -3;
00363     } else if (*nrhs < 0) {
00364         *info = -4;
00365     } else if (*lda < max(1,*n)) {
00366         *info = -6;
00367     } else if (*ldaf < max(1,*n)) {
00368         *info = -8;
00369     } else if (lsame_(fact, "F") && ! (rowequ || colequ 
00370             || lsame_(equed, "N"))) {
00371         *info = -10;
00372     } else {
00373         if (rowequ) {
00374             rcmin = bignum;
00375             rcmax = 0.f;
00376             i__1 = *n;
00377             for (j = 1; j <= i__1; ++j) {
00378 /* Computing MIN */
00379                 r__1 = rcmin, r__2 = r__[j];
00380                 rcmin = dmin(r__1,r__2);
00381 /* Computing MAX */
00382                 r__1 = rcmax, r__2 = r__[j];
00383                 rcmax = dmax(r__1,r__2);
00384 /* L10: */
00385             }
00386             if (rcmin <= 0.f) {
00387                 *info = -11;
00388             } else if (*n > 0) {
00389                 rowcnd = dmax(rcmin,smlnum) / dmin(rcmax,bignum);
00390             } else {
00391                 rowcnd = 1.f;
00392             }
00393         }
00394         if (colequ && *info == 0) {
00395             rcmin = bignum;
00396             rcmax = 0.f;
00397             i__1 = *n;
00398             for (j = 1; j <= i__1; ++j) {
00399 /* Computing MIN */
00400                 r__1 = rcmin, r__2 = c__[j];
00401                 rcmin = dmin(r__1,r__2);
00402 /* Computing MAX */
00403                 r__1 = rcmax, r__2 = c__[j];
00404                 rcmax = dmax(r__1,r__2);
00405 /* L20: */
00406             }
00407             if (rcmin <= 0.f) {
00408                 *info = -12;
00409             } else if (*n > 0) {
00410                 colcnd = dmax(rcmin,smlnum) / dmin(rcmax,bignum);
00411             } else {
00412                 colcnd = 1.f;
00413             }
00414         }
00415         if (*info == 0) {
00416             if (*ldb < max(1,*n)) {
00417                 *info = -14;
00418             } else if (*ldx < max(1,*n)) {
00419                 *info = -16;
00420             }
00421         }
00422     }
00423 
00424     if (*info != 0) {
00425         i__1 = -(*info);
00426         xerbla_("CGESVX", &i__1);
00427         return 0;
00428     }
00429 
00430     if (equil) {
00431 
00432 /*        Compute row and column scalings to equilibrate the matrix A. */
00433 
00434         cgeequ_(n, n, &a[a_offset], lda, &r__[1], &c__[1], &rowcnd, &colcnd, &
00435                 amax, &infequ);
00436         if (infequ == 0) {
00437 
00438 /*           Equilibrate the matrix. */
00439 
00440             claqge_(n, n, &a[a_offset], lda, &r__[1], &c__[1], &rowcnd, &
00441                     colcnd, &amax, equed);
00442             rowequ = lsame_(equed, "R") || lsame_(equed, 
00443                      "B");
00444             colequ = lsame_(equed, "C") || lsame_(equed, 
00445                      "B");
00446         }
00447     }
00448 
00449 /*     Scale the right hand side. */
00450 
00451     if (notran) {
00452         if (rowequ) {
00453             i__1 = *nrhs;
00454             for (j = 1; j <= i__1; ++j) {
00455                 i__2 = *n;
00456                 for (i__ = 1; i__ <= i__2; ++i__) {
00457                     i__3 = i__ + j * b_dim1;
00458                     i__4 = i__;
00459                     i__5 = i__ + j * b_dim1;
00460                     q__1.r = r__[i__4] * b[i__5].r, q__1.i = r__[i__4] * b[
00461                             i__5].i;
00462                     b[i__3].r = q__1.r, b[i__3].i = q__1.i;
00463 /* L30: */
00464                 }
00465 /* L40: */
00466             }
00467         }
00468     } else if (colequ) {
00469         i__1 = *nrhs;
00470         for (j = 1; j <= i__1; ++j) {
00471             i__2 = *n;
00472             for (i__ = 1; i__ <= i__2; ++i__) {
00473                 i__3 = i__ + j * b_dim1;
00474                 i__4 = i__;
00475                 i__5 = i__ + j * b_dim1;
00476                 q__1.r = c__[i__4] * b[i__5].r, q__1.i = c__[i__4] * b[i__5]
00477                         .i;
00478                 b[i__3].r = q__1.r, b[i__3].i = q__1.i;
00479 /* L50: */
00480             }
00481 /* L60: */
00482         }
00483     }
00484 
00485     if (nofact || equil) {
00486 
00487 /*        Compute the LU factorization of A. */
00488 
00489         clacpy_("Full", n, n, &a[a_offset], lda, &af[af_offset], ldaf);
00490         cgetrf_(n, n, &af[af_offset], ldaf, &ipiv[1], info);
00491 
00492 /*        Return if INFO is non-zero. */
00493 
00494         if (*info > 0) {
00495 
00496 /*           Compute the reciprocal pivot growth factor of the */
00497 /*           leading rank-deficient INFO columns of A. */
00498 
00499             rpvgrw = clantr_("M", "U", "N", info, info, &af[af_offset], ldaf, 
00500                     &rwork[1]);
00501             if (rpvgrw == 0.f) {
00502                 rpvgrw = 1.f;
00503             } else {
00504                 rpvgrw = clange_("M", n, info, &a[a_offset], lda, &rwork[1]) / rpvgrw;
00505             }
00506             rwork[1] = rpvgrw;
00507             *rcond = 0.f;
00508             return 0;
00509         }
00510     }
00511 
00512 /*     Compute the norm of the matrix A and the */
00513 /*     reciprocal pivot growth factor RPVGRW. */
00514 
00515     if (notran) {
00516         *(unsigned char *)norm = '1';
00517     } else {
00518         *(unsigned char *)norm = 'I';
00519     }
00520     anorm = clange_(norm, n, n, &a[a_offset], lda, &rwork[1]);
00521     rpvgrw = clantr_("M", "U", "N", n, n, &af[af_offset], ldaf, &rwork[1]);
00522     if (rpvgrw == 0.f) {
00523         rpvgrw = 1.f;
00524     } else {
00525         rpvgrw = clange_("M", n, n, &a[a_offset], lda, &rwork[1]) /
00526                  rpvgrw;
00527     }
00528 
00529 /*     Compute the reciprocal of the condition number of A. */
00530 
00531     cgecon_(norm, n, &af[af_offset], ldaf, &anorm, rcond, &work[1], &rwork[1], 
00532              info);
00533 
00534 /*     Compute the solution matrix X. */
00535 
00536     clacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx);
00537     cgetrs_(trans, n, nrhs, &af[af_offset], ldaf, &ipiv[1], &x[x_offset], ldx, 
00538              info);
00539 
00540 /*     Use iterative refinement to improve the computed solution and */
00541 /*     compute error bounds and backward error estimates for it. */
00542 
00543     cgerfs_(trans, n, nrhs, &a[a_offset], lda, &af[af_offset], ldaf, &ipiv[1], 
00544              &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], &berr[1], &work[
00545             1], &rwork[1], info);
00546 
00547 /*     Transform the solution matrix X to a solution of the original */
00548 /*     system. */
00549 
00550     if (notran) {
00551         if (colequ) {
00552             i__1 = *nrhs;
00553             for (j = 1; j <= i__1; ++j) {
00554                 i__2 = *n;
00555                 for (i__ = 1; i__ <= i__2; ++i__) {
00556                     i__3 = i__ + j * x_dim1;
00557                     i__4 = i__;
00558                     i__5 = i__ + j * x_dim1;
00559                     q__1.r = c__[i__4] * x[i__5].r, q__1.i = c__[i__4] * x[
00560                             i__5].i;
00561                     x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00562 /* L70: */
00563                 }
00564 /* L80: */
00565             }
00566             i__1 = *nrhs;
00567             for (j = 1; j <= i__1; ++j) {
00568                 ferr[j] /= colcnd;
00569 /* L90: */
00570             }
00571         }
00572     } else if (rowequ) {
00573         i__1 = *nrhs;
00574         for (j = 1; j <= i__1; ++j) {
00575             i__2 = *n;
00576             for (i__ = 1; i__ <= i__2; ++i__) {
00577                 i__3 = i__ + j * x_dim1;
00578                 i__4 = i__;
00579                 i__5 = i__ + j * x_dim1;
00580                 q__1.r = r__[i__4] * x[i__5].r, q__1.i = r__[i__4] * x[i__5]
00581                         .i;
00582                 x[i__3].r = q__1.r, x[i__3].i = q__1.i;
00583 /* L100: */
00584             }
00585 /* L110: */
00586         }
00587         i__1 = *nrhs;
00588         for (j = 1; j <= i__1; ++j) {
00589             ferr[j] /= rowcnd;
00590 /* L120: */
00591         }
00592     }
00593 
00594 /*     Set INFO = N+1 if the matrix is singular to working precision. */
00595 
00596     if (*rcond < slamch_("Epsilon")) {
00597         *info = *n + 1;
00598     }
00599 
00600     rwork[1] = rpvgrw;
00601     return 0;
00602 
00603 /*     End of CGESVX */
00604 
00605 } /* cgesvx_ */


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