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


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