zpttrf.c
Go to the documentation of this file.
00001 /* zpttrf.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 zpttrf_(integer *n, doublereal *d__, doublecomplex *e, 
00017         integer *info)
00018 {
00019     /* System generated locals */
00020     integer i__1, i__2;
00021     doublecomplex z__1;
00022 
00023     /* Builtin functions */
00024     double d_imag(doublecomplex *);
00025 
00026     /* Local variables */
00027     doublereal f, g;
00028     integer i__, i4;
00029     doublereal eii, eir;
00030     extern /* Subroutine */ int xerbla_(char *, integer *);
00031 
00032 
00033 /*  -- LAPACK routine (version 3.2) -- */
00034 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00035 /*     November 2006 */
00036 
00037 /*     .. Scalar Arguments .. */
00038 /*     .. */
00039 /*     .. Array Arguments .. */
00040 /*     .. */
00041 
00042 /*  Purpose */
00043 /*  ======= */
00044 
00045 /*  ZPTTRF computes the L*D*L' factorization of a complex Hermitian */
00046 /*  positive definite tridiagonal matrix A.  The factorization may also */
00047 /*  be regarded as having the form A = U'*D*U. */
00048 
00049 /*  Arguments */
00050 /*  ========= */
00051 
00052 /*  N       (input) INTEGER */
00053 /*          The order of the matrix A.  N >= 0. */
00054 
00055 /*  D       (input/output) DOUBLE PRECISION array, dimension (N) */
00056 /*          On entry, the n diagonal elements of the tridiagonal matrix */
00057 /*          A.  On exit, the n diagonal elements of the diagonal matrix */
00058 /*          D from the L*D*L' factorization of A. */
00059 
00060 /*  E       (input/output) COMPLEX*16 array, dimension (N-1) */
00061 /*          On entry, the (n-1) subdiagonal elements of the tridiagonal */
00062 /*          matrix A.  On exit, the (n-1) subdiagonal elements of the */
00063 /*          unit bidiagonal factor L from the L*D*L' factorization of A. */
00064 /*          E can also be regarded as the superdiagonal of the unit */
00065 /*          bidiagonal factor U from the U'*D*U factorization of A. */
00066 
00067 /*  INFO    (output) INTEGER */
00068 /*          = 0: successful exit */
00069 /*          < 0: if INFO = -k, the k-th argument had an illegal value */
00070 /*          > 0: if INFO = k, the leading minor of order k is not */
00071 /*               positive definite; if k < N, the factorization could not */
00072 /*               be completed, while if k = N, the factorization was */
00073 /*               completed, but D(N) <= 0. */
00074 
00075 /*  ===================================================================== */
00076 
00077 /*     .. Parameters .. */
00078 /*     .. */
00079 /*     .. Local Scalars .. */
00080 /*     .. */
00081 /*     .. External Subroutines .. */
00082 /*     .. */
00083 /*     .. Intrinsic Functions .. */
00084 /*     .. */
00085 /*     .. Executable Statements .. */
00086 
00087 /*     Test the input parameters. */
00088 
00089     /* Parameter adjustments */
00090     --e;
00091     --d__;
00092 
00093     /* Function Body */
00094     *info = 0;
00095     if (*n < 0) {
00096         *info = -1;
00097         i__1 = -(*info);
00098         xerbla_("ZPTTRF", &i__1);
00099         return 0;
00100     }
00101 
00102 /*     Quick return if possible */
00103 
00104     if (*n == 0) {
00105         return 0;
00106     }
00107 
00108 /*     Compute the L*D*L' (or U'*D*U) factorization of A. */
00109 
00110     i4 = (*n - 1) % 4;
00111     i__1 = i4;
00112     for (i__ = 1; i__ <= i__1; ++i__) {
00113         if (d__[i__] <= 0.) {
00114             *info = i__;
00115             goto L30;
00116         }
00117         i__2 = i__;
00118         eir = e[i__2].r;
00119         eii = d_imag(&e[i__]);
00120         f = eir / d__[i__];
00121         g = eii / d__[i__];
00122         i__2 = i__;
00123         z__1.r = f, z__1.i = g;
00124         e[i__2].r = z__1.r, e[i__2].i = z__1.i;
00125         d__[i__ + 1] = d__[i__ + 1] - f * eir - g * eii;
00126 /* L10: */
00127     }
00128 
00129     i__1 = *n - 4;
00130     for (i__ = i4 + 1; i__ <= i__1; i__ += 4) {
00131 
00132 /*        Drop out of the loop if d(i) <= 0: the matrix is not positive */
00133 /*        definite. */
00134 
00135         if (d__[i__] <= 0.) {
00136             *info = i__;
00137             goto L30;
00138         }
00139 
00140 /*        Solve for e(i) and d(i+1). */
00141 
00142         i__2 = i__;
00143         eir = e[i__2].r;
00144         eii = d_imag(&e[i__]);
00145         f = eir / d__[i__];
00146         g = eii / d__[i__];
00147         i__2 = i__;
00148         z__1.r = f, z__1.i = g;
00149         e[i__2].r = z__1.r, e[i__2].i = z__1.i;
00150         d__[i__ + 1] = d__[i__ + 1] - f * eir - g * eii;
00151 
00152         if (d__[i__ + 1] <= 0.) {
00153             *info = i__ + 1;
00154             goto L30;
00155         }
00156 
00157 /*        Solve for e(i+1) and d(i+2). */
00158 
00159         i__2 = i__ + 1;
00160         eir = e[i__2].r;
00161         eii = d_imag(&e[i__ + 1]);
00162         f = eir / d__[i__ + 1];
00163         g = eii / d__[i__ + 1];
00164         i__2 = i__ + 1;
00165         z__1.r = f, z__1.i = g;
00166         e[i__2].r = z__1.r, e[i__2].i = z__1.i;
00167         d__[i__ + 2] = d__[i__ + 2] - f * eir - g * eii;
00168 
00169         if (d__[i__ + 2] <= 0.) {
00170             *info = i__ + 2;
00171             goto L30;
00172         }
00173 
00174 /*        Solve for e(i+2) and d(i+3). */
00175 
00176         i__2 = i__ + 2;
00177         eir = e[i__2].r;
00178         eii = d_imag(&e[i__ + 2]);
00179         f = eir / d__[i__ + 2];
00180         g = eii / d__[i__ + 2];
00181         i__2 = i__ + 2;
00182         z__1.r = f, z__1.i = g;
00183         e[i__2].r = z__1.r, e[i__2].i = z__1.i;
00184         d__[i__ + 3] = d__[i__ + 3] - f * eir - g * eii;
00185 
00186         if (d__[i__ + 3] <= 0.) {
00187             *info = i__ + 3;
00188             goto L30;
00189         }
00190 
00191 /*        Solve for e(i+3) and d(i+4). */
00192 
00193         i__2 = i__ + 3;
00194         eir = e[i__2].r;
00195         eii = d_imag(&e[i__ + 3]);
00196         f = eir / d__[i__ + 3];
00197         g = eii / d__[i__ + 3];
00198         i__2 = i__ + 3;
00199         z__1.r = f, z__1.i = g;
00200         e[i__2].r = z__1.r, e[i__2].i = z__1.i;
00201         d__[i__ + 4] = d__[i__ + 4] - f * eir - g * eii;
00202 /* L20: */
00203     }
00204 
00205 /*     Check d(n) for positive definiteness. */
00206 
00207     if (d__[*n] <= 0.) {
00208         *info = *n;
00209     }
00210 
00211 L30:
00212     return 0;
00213 
00214 /*     End of ZPTTRF */
00215 
00216 } /* zpttrf_ */


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