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


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