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


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