dptt01.c
Go to the documentation of this file.
00001 /* dptt01.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 dptt01_(integer *n, doublereal *d__, doublereal *e, 
00017         doublereal *df, doublereal *ef, doublereal *work, doublereal *resid)
00018 {
00019     /* System generated locals */
00020     integer i__1;
00021     doublereal d__1, d__2, d__3, d__4, d__5;
00022 
00023     /* Local variables */
00024     integer i__;
00025     doublereal de, eps, anorm;
00026     extern doublereal dlamch_(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 /*  DPTT01 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) DOUBLE PRECISION array, dimension (N) */
00053 /*          The n diagonal elements of the tridiagonal matrix A. */
00054 
00055 /*  E       (input) DOUBLE PRECISION array, dimension (N-1) */
00056 /*          The (n-1) subdiagonal elements of the tridiagonal matrix A. */
00057 
00058 /*  DF      (input) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION array, dimension (2*N) */
00067 
00068 /*  RESID   (output) DOUBLE PRECISION */
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.;
00095         return 0;
00096     }
00097 
00098     eps = dlamch_("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 = abs(work[1]);
00116     } else {
00117 /* Computing MAX */
00118         d__2 = d__[1] + abs(e[1]), d__3 = d__[*n] + (d__1 = e[*n - 1], abs(
00119                 d__1));
00120         anorm = max(d__2,d__3);
00121 /* Computing MAX */
00122         d__4 = abs(work[1]) + (d__1 = work[*n + 1], abs(d__1)), d__5 = (d__2 =
00123                  work[*n], abs(d__2)) + (d__3 = work[(*n << 1) - 1], abs(d__3)
00124                 );
00125         *resid = max(d__4,d__5);
00126         i__1 = *n - 1;
00127         for (i__ = 2; i__ <= i__1; ++i__) {
00128 /* Computing MAX */
00129             d__3 = anorm, d__4 = d__[i__] + (d__1 = e[i__], abs(d__1)) + (
00130                     d__2 = e[i__ - 1], abs(d__2));
00131             anorm = max(d__3,d__4);
00132 /* Computing MAX */
00133             d__4 = *resid, d__5 = (d__1 = work[i__], abs(d__1)) + (d__2 = 
00134                     work[*n + i__ - 1], abs(d__2)) + (d__3 = work[*n + i__], 
00135                     abs(d__3));
00136             *resid = max(d__4,d__5);
00137 /* L20: */
00138         }
00139     }
00140 
00141 /*     Compute norm(L*D*L' - A) / (n * norm(A) * EPS) */
00142 
00143     if (anorm <= 0.) {
00144         if (*resid != 0.) {
00145             *resid = 1. / eps;
00146         }
00147     } else {
00148         *resid = *resid / (doublereal) (*n) / anorm / eps;
00149     }
00150 
00151     return 0;
00152 
00153 /*     End of DPTT01 */
00154 
00155 } /* dptt01_ */


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