sptt01.c
Go to the documentation of this file.
00001 /* sptt01.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 sptt01_(integer *n, real *d__, real *e, real *df, real *
00017         ef, real *work, real *resid)
00018 {
00019     /* System generated locals */
00020     integer i__1;
00021     real r__1, r__2, r__3, r__4, r__5;
00022 
00023     /* Local variables */
00024     integer i__;
00025     real de, eps, anorm;
00026     extern doublereal slamch_(char *);
00027 
00028 
00029 /*  -- LAPACK test routine (version 3.1) -- */
00030 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00031 /*     November 2006 */
00032 
00033 /*     .. Scalar Arguments .. */
00034 /*     .. */
00035 /*     .. Array Arguments .. */
00036 /*     .. */
00037 
00038 /*  Purpose */
00039 /*  ======= */
00040 
00041 /*  SPTT01 reconstructs a tridiagonal matrix A from its L*D*L' */
00042 /*  factorization and computes the residual */
00043 /*     norm(L*D*L' - A) / ( n * norm(A) * EPS ), */
00044 /*  where EPS is the machine epsilon. */
00045 
00046 /*  Arguments */
00047 /*  ========= */
00048 
00049 /*  N       (input) INTEGTER */
00050 /*          The order of the matrix A. */
00051 
00052 /*  D       (input) REAL array, dimension (N) */
00053 /*          The n diagonal elements of the tridiagonal matrix A. */
00054 
00055 /*  E       (input) REAL array, dimension (N-1) */
00056 /*          The (n-1) subdiagonal elements of the tridiagonal matrix A. */
00057 
00058 /*  DF      (input) REAL array, dimension (N) */
00059 /*          The n diagonal elements of the factor L from the L*D*L' */
00060 /*          factorization of A. */
00061 
00062 /*  EF      (input) REAL array, dimension (N-1) */
00063 /*          The (n-1) subdiagonal elements of the factor L from the */
00064 /*          L*D*L' factorization of A. */
00065 
00066 /*  WORK    (workspace) REAL array, dimension (2*N) */
00067 
00068 /*  RESID   (output) REAL */
00069 /*          norm(L*D*L' - A) / (n * norm(A) * EPS) */
00070 
00071 /*  ===================================================================== */
00072 
00073 /*     .. Parameters .. */
00074 /*     .. */
00075 /*     .. Local Scalars .. */
00076 /*     .. */
00077 /*     .. External Functions .. */
00078 /*     .. */
00079 /*     .. Intrinsic Functions .. */
00080 /*     .. */
00081 /*     .. Executable Statements .. */
00082 
00083 /*     Quick return if possible */
00084 
00085     /* Parameter adjustments */
00086     --work;
00087     --ef;
00088     --df;
00089     --e;
00090     --d__;
00091 
00092     /* Function Body */
00093     if (*n <= 0) {
00094         *resid = 0.f;
00095         return 0;
00096     }
00097 
00098     eps = slamch_("Epsilon");
00099 
00100 /*     Construct the difference L*D*L' - A. */
00101 
00102     work[1] = df[1] - d__[1];
00103     i__1 = *n - 1;
00104     for (i__ = 1; i__ <= i__1; ++i__) {
00105         de = df[i__] * ef[i__];
00106         work[*n + i__] = de - e[i__];
00107         work[i__ + 1] = de * ef[i__] + df[i__ + 1] - d__[i__ + 1];
00108 /* L10: */
00109     }
00110 
00111 /*     Compute the 1-norms of the tridiagonal matrices A and WORK. */
00112 
00113     if (*n == 1) {
00114         anorm = d__[1];
00115         *resid = dabs(work[1]);
00116     } else {
00117 /* Computing MAX */
00118         r__2 = d__[1] + dabs(e[1]), r__3 = d__[*n] + (r__1 = e[*n - 1], dabs(
00119                 r__1));
00120         anorm = dmax(r__2,r__3);
00121 /* Computing MAX */
00122         r__4 = dabs(work[1]) + (r__1 = work[*n + 1], dabs(r__1)), r__5 = (
00123                 r__2 = work[*n], dabs(r__2)) + (r__3 = work[(*n << 1) - 1], 
00124                 dabs(r__3));
00125         *resid = dmax(r__4,r__5);
00126         i__1 = *n - 1;
00127         for (i__ = 2; i__ <= i__1; ++i__) {
00128 /* Computing MAX */
00129             r__3 = anorm, r__4 = d__[i__] + (r__1 = e[i__], dabs(r__1)) + (
00130                     r__2 = e[i__ - 1], dabs(r__2));
00131             anorm = dmax(r__3,r__4);
00132 /* Computing MAX */
00133             r__4 = *resid, r__5 = (r__1 = work[i__], dabs(r__1)) + (r__2 = 
00134                     work[*n + i__ - 1], dabs(r__2)) + (r__3 = work[*n + i__], 
00135                     dabs(r__3));
00136             *resid = dmax(r__4,r__5);
00137 /* L20: */
00138         }
00139     }
00140 
00141 /*     Compute norm(L*D*L' - A) / (n * norm(A) * EPS) */
00142 
00143     if (anorm <= 0.f) {
00144         if (*resid != 0.f) {
00145             *resid = 1.f / eps;
00146         }
00147     } else {
00148         *resid = *resid / (real) (*n) / anorm / eps;
00149     }
00150 
00151     return 0;
00152 
00153 /*     End of SPTT01 */
00154 
00155 } /* sptt01_ */


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