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


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