zgttrf.c
Go to the documentation of this file.
00001 /* zgttrf.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 zgttrf_(integer *n, doublecomplex *dl, doublecomplex *
00017         d__, doublecomplex *du, doublecomplex *du2, integer *ipiv, integer *
00018         info)
00019 {
00020     /* System generated locals */
00021     integer i__1, i__2, i__3, i__4;
00022     doublereal d__1, d__2, d__3, d__4;
00023     doublecomplex z__1, z__2;
00024 
00025     /* Builtin functions */
00026     double d_imag(doublecomplex *);
00027     void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00028 
00029     /* Local variables */
00030     integer i__;
00031     doublecomplex fact, temp;
00032     extern /* Subroutine */ int xerbla_(char *, integer *);
00033 
00034 
00035 /*  -- LAPACK routine (version 3.2) -- */
00036 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00037 /*     November 2006 */
00038 
00039 /*     .. Scalar Arguments .. */
00040 /*     .. */
00041 /*     .. Array Arguments .. */
00042 /*     .. */
00043 
00044 /*  Purpose */
00045 /*  ======= */
00046 
00047 /*  ZGTTRF computes an LU factorization of a complex tridiagonal matrix A */
00048 /*  using elimination with partial pivoting and row interchanges. */
00049 
00050 /*  The factorization has the form */
00051 /*     A = L * U */
00052 /*  where L is a product of permutation and unit lower bidiagonal */
00053 /*  matrices and U is upper triangular with nonzeros in only the main */
00054 /*  diagonal and first two superdiagonals. */
00055 
00056 /*  Arguments */
00057 /*  ========= */
00058 
00059 /*  N       (input) INTEGER */
00060 /*          The order of the matrix A. */
00061 
00062 /*  DL      (input/output) COMPLEX*16 array, dimension (N-1) */
00063 /*          On entry, DL must contain the (n-1) sub-diagonal elements of */
00064 /*          A. */
00065 
00066 /*          On exit, DL is overwritten by the (n-1) multipliers that */
00067 /*          define the matrix L from the LU factorization of A. */
00068 
00069 /*  D       (input/output) COMPLEX*16 array, dimension (N) */
00070 /*          On entry, D must contain the diagonal elements of A. */
00071 
00072 /*          On exit, D is overwritten by the n diagonal elements of the */
00073 /*          upper triangular matrix U from the LU factorization of A. */
00074 
00075 /*  DU      (input/output) COMPLEX*16 array, dimension (N-1) */
00076 /*          On entry, DU must contain the (n-1) super-diagonal elements */
00077 /*          of A. */
00078 
00079 /*          On exit, DU is overwritten by the (n-1) elements of the first */
00080 /*          super-diagonal of U. */
00081 
00082 /*  DU2     (output) COMPLEX*16 array, dimension (N-2) */
00083 /*          On exit, DU2 is overwritten by the (n-2) elements of the */
00084 /*          second super-diagonal of U. */
00085 
00086 /*  IPIV    (output) INTEGER array, dimension (N) */
00087 /*          The pivot indices; for 1 <= i <= n, row i of the matrix was */
00088 /*          interchanged with row IPIV(i).  IPIV(i) will always be either */
00089 /*          i or i+1; IPIV(i) = i indicates a row interchange was not */
00090 /*          required. */
00091 
00092 /*  INFO    (output) INTEGER */
00093 /*          = 0:  successful exit */
00094 /*          < 0:  if INFO = -k, the k-th argument had an illegal value */
00095 /*          > 0:  if INFO = k, U(k,k) is exactly zero. The factorization */
00096 /*                has been completed, but the factor U is exactly */
00097 /*                singular, and division by zero will occur if it is used */
00098 /*                to solve a system of equations. */
00099 
00100 /*  ===================================================================== */
00101 
00102 /*     .. Parameters .. */
00103 /*     .. */
00104 /*     .. Local Scalars .. */
00105 /*     .. */
00106 /*     .. External Subroutines .. */
00107 /*     .. */
00108 /*     .. Intrinsic Functions .. */
00109 /*     .. */
00110 /*     .. Statement Functions .. */
00111 /*     .. */
00112 /*     .. Statement Function definitions .. */
00113 /*     .. */
00114 /*     .. Executable Statements .. */
00115 
00116     /* Parameter adjustments */
00117     --ipiv;
00118     --du2;
00119     --du;
00120     --d__;
00121     --dl;
00122 
00123     /* Function Body */
00124     *info = 0;
00125     if (*n < 0) {
00126         *info = -1;
00127         i__1 = -(*info);
00128         xerbla_("ZGTTRF", &i__1);
00129         return 0;
00130     }
00131 
00132 /*     Quick return if possible */
00133 
00134     if (*n == 0) {
00135         return 0;
00136     }
00137 
00138 /*     Initialize IPIV(i) = i and DU2(i) = 0 */
00139 
00140     i__1 = *n;
00141     for (i__ = 1; i__ <= i__1; ++i__) {
00142         ipiv[i__] = i__;
00143 /* L10: */
00144     }
00145     i__1 = *n - 2;
00146     for (i__ = 1; i__ <= i__1; ++i__) {
00147         i__2 = i__;
00148         du2[i__2].r = 0., du2[i__2].i = 0.;
00149 /* L20: */
00150     }
00151 
00152     i__1 = *n - 2;
00153     for (i__ = 1; i__ <= i__1; ++i__) {
00154         i__2 = i__;
00155         i__3 = i__;
00156         if ((d__1 = d__[i__2].r, abs(d__1)) + (d__2 = d_imag(&d__[i__]), abs(
00157                 d__2)) >= (d__3 = dl[i__3].r, abs(d__3)) + (d__4 = d_imag(&dl[
00158                 i__]), abs(d__4))) {
00159 
00160 /*           No row interchange required, eliminate DL(I) */
00161 
00162             i__2 = i__;
00163             if ((d__1 = d__[i__2].r, abs(d__1)) + (d__2 = d_imag(&d__[i__]), 
00164                     abs(d__2)) != 0.) {
00165                 z_div(&z__1, &dl[i__], &d__[i__]);
00166                 fact.r = z__1.r, fact.i = z__1.i;
00167                 i__2 = i__;
00168                 dl[i__2].r = fact.r, dl[i__2].i = fact.i;
00169                 i__2 = i__ + 1;
00170                 i__3 = i__ + 1;
00171                 i__4 = i__;
00172                 z__2.r = fact.r * du[i__4].r - fact.i * du[i__4].i, z__2.i = 
00173                         fact.r * du[i__4].i + fact.i * du[i__4].r;
00174                 z__1.r = d__[i__3].r - z__2.r, z__1.i = d__[i__3].i - z__2.i;
00175                 d__[i__2].r = z__1.r, d__[i__2].i = z__1.i;
00176             }
00177         } else {
00178 
00179 /*           Interchange rows I and I+1, eliminate DL(I) */
00180 
00181             z_div(&z__1, &d__[i__], &dl[i__]);
00182             fact.r = z__1.r, fact.i = z__1.i;
00183             i__2 = i__;
00184             i__3 = i__;
00185             d__[i__2].r = dl[i__3].r, d__[i__2].i = dl[i__3].i;
00186             i__2 = i__;
00187             dl[i__2].r = fact.r, dl[i__2].i = fact.i;
00188             i__2 = i__;
00189             temp.r = du[i__2].r, temp.i = du[i__2].i;
00190             i__2 = i__;
00191             i__3 = i__ + 1;
00192             du[i__2].r = d__[i__3].r, du[i__2].i = d__[i__3].i;
00193             i__2 = i__ + 1;
00194             i__3 = i__ + 1;
00195             z__2.r = fact.r * d__[i__3].r - fact.i * d__[i__3].i, z__2.i = 
00196                     fact.r * d__[i__3].i + fact.i * d__[i__3].r;
00197             z__1.r = temp.r - z__2.r, z__1.i = temp.i - z__2.i;
00198             d__[i__2].r = z__1.r, d__[i__2].i = z__1.i;
00199             i__2 = i__;
00200             i__3 = i__ + 1;
00201             du2[i__2].r = du[i__3].r, du2[i__2].i = du[i__3].i;
00202             i__2 = i__ + 1;
00203             z__2.r = -fact.r, z__2.i = -fact.i;
00204             i__3 = i__ + 1;
00205             z__1.r = z__2.r * du[i__3].r - z__2.i * du[i__3].i, z__1.i = 
00206                     z__2.r * du[i__3].i + z__2.i * du[i__3].r;
00207             du[i__2].r = z__1.r, du[i__2].i = z__1.i;
00208             ipiv[i__] = i__ + 1;
00209         }
00210 /* L30: */
00211     }
00212     if (*n > 1) {
00213         i__ = *n - 1;
00214         i__1 = i__;
00215         i__2 = i__;
00216         if ((d__1 = d__[i__1].r, abs(d__1)) + (d__2 = d_imag(&d__[i__]), abs(
00217                 d__2)) >= (d__3 = dl[i__2].r, abs(d__3)) + (d__4 = d_imag(&dl[
00218                 i__]), abs(d__4))) {
00219             i__1 = i__;
00220             if ((d__1 = d__[i__1].r, abs(d__1)) + (d__2 = d_imag(&d__[i__]), 
00221                     abs(d__2)) != 0.) {
00222                 z_div(&z__1, &dl[i__], &d__[i__]);
00223                 fact.r = z__1.r, fact.i = z__1.i;
00224                 i__1 = i__;
00225                 dl[i__1].r = fact.r, dl[i__1].i = fact.i;
00226                 i__1 = i__ + 1;
00227                 i__2 = i__ + 1;
00228                 i__3 = i__;
00229                 z__2.r = fact.r * du[i__3].r - fact.i * du[i__3].i, z__2.i = 
00230                         fact.r * du[i__3].i + fact.i * du[i__3].r;
00231                 z__1.r = d__[i__2].r - z__2.r, z__1.i = d__[i__2].i - z__2.i;
00232                 d__[i__1].r = z__1.r, d__[i__1].i = z__1.i;
00233             }
00234         } else {
00235             z_div(&z__1, &d__[i__], &dl[i__]);
00236             fact.r = z__1.r, fact.i = z__1.i;
00237             i__1 = i__;
00238             i__2 = i__;
00239             d__[i__1].r = dl[i__2].r, d__[i__1].i = dl[i__2].i;
00240             i__1 = i__;
00241             dl[i__1].r = fact.r, dl[i__1].i = fact.i;
00242             i__1 = i__;
00243             temp.r = du[i__1].r, temp.i = du[i__1].i;
00244             i__1 = i__;
00245             i__2 = i__ + 1;
00246             du[i__1].r = d__[i__2].r, du[i__1].i = d__[i__2].i;
00247             i__1 = i__ + 1;
00248             i__2 = i__ + 1;
00249             z__2.r = fact.r * d__[i__2].r - fact.i * d__[i__2].i, z__2.i = 
00250                     fact.r * d__[i__2].i + fact.i * d__[i__2].r;
00251             z__1.r = temp.r - z__2.r, z__1.i = temp.i - z__2.i;
00252             d__[i__1].r = z__1.r, d__[i__1].i = z__1.i;
00253             ipiv[i__] = i__ + 1;
00254         }
00255     }
00256 
00257 /*     Check for a zero on the diagonal of U. */
00258 
00259     i__1 = *n;
00260     for (i__ = 1; i__ <= i__1; ++i__) {
00261         i__2 = i__;
00262         if ((d__1 = d__[i__2].r, abs(d__1)) + (d__2 = d_imag(&d__[i__]), abs(
00263                 d__2)) == 0.) {
00264             *info = i__;
00265             goto L50;
00266         }
00267 /* L40: */
00268     }
00269 L50:
00270 
00271     return 0;
00272 
00273 /*     End of ZGTTRF */
00274 
00275 } /* zgttrf_ */


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