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


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