dgtt01.c
Go to the documentation of this file.
00001 /* dgtt01.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 dgtt01_(integer *n, doublereal *dl, doublereal *d__, 
00017         doublereal *du, doublereal *dlf, doublereal *df, doublereal *duf, 
00018         doublereal *du2, integer *ipiv, doublereal *work, integer *ldwork, 
00019         doublereal *rwork, doublereal *resid)
00020 {
00021     /* System generated locals */
00022     integer work_dim1, work_offset, i__1, i__2;
00023 
00024     /* Local variables */
00025     integer i__, j;
00026     doublereal li;
00027     integer ip;
00028     doublereal eps, anorm;
00029     integer lastj;
00030     extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *, 
00031             doublereal *, integer *), daxpy_(integer *, doublereal *, 
00032             doublereal *, integer *, doublereal *, integer *);
00033     extern doublereal dlamch_(char *), dlangt_(char *, integer *, 
00034             doublereal *, doublereal *, doublereal *), dlanhs_(char *, 
00035              integer *, doublereal *, integer *, doublereal *);
00036 
00037 
00038 /*  -- LAPACK test routine (version 3.1) -- */
00039 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00040 /*     November 2006 */
00041 
00042 /*     .. Scalar Arguments .. */
00043 /*     .. */
00044 /*     .. Array Arguments .. */
00045 /*     .. */
00046 
00047 /*  Purpose */
00048 /*  ======= */
00049 
00050 /*  DGTT01 reconstructs a tridiagonal matrix A from its LU factorization */
00051 /*  and computes the residual */
00052 /*     norm(L*U - A) / ( norm(A) * EPS ), */
00053 /*  where EPS is the machine epsilon. */
00054 
00055 /*  Arguments */
00056 /*  ========= */
00057 
00058 /*  N       (input) INTEGTER */
00059 /*          The order of the matrix A.  N >= 0. */
00060 
00061 /*  DL      (input) DOUBLE PRECISION array, dimension (N-1) */
00062 /*          The (n-1) sub-diagonal elements of A. */
00063 
00064 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
00065 /*          The diagonal elements of A. */
00066 
00067 /*  DU      (input) DOUBLE PRECISION array, dimension (N-1) */
00068 /*          The (n-1) super-diagonal elements of A. */
00069 
00070 /*  DLF     (input) DOUBLE PRECISION array, dimension (N-1) */
00071 /*          The (n-1) multipliers that define the matrix L from the */
00072 /*          LU factorization of A. */
00073 
00074 /*  DF      (input) DOUBLE PRECISION array, dimension (N) */
00075 /*          The n diagonal elements of the upper triangular matrix U from */
00076 /*          the LU factorization of A. */
00077 
00078 /*  DUF     (input) DOUBLE PRECISION array, dimension (N-1) */
00079 /*          The (n-1) elements of the first super-diagonal of U. */
00080 
00081 /*  DU2F    (input) DOUBLE PRECISION array, dimension (N-2) */
00082 /*          The (n-2) elements of the second super-diagonal of U. */
00083 
00084 /*  IPIV    (input) INTEGER array, dimension (N) */
00085 /*          The pivot indices; for 1 <= i <= n, row i of the matrix was */
00086 /*          interchanged with row IPIV(i).  IPIV(i) will always be either */
00087 /*          i or i+1; IPIV(i) = i indicates a row interchange was not */
00088 /*          required. */
00089 
00090 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LDWORK,N) */
00091 
00092 /*  LDWORK  (input) INTEGER */
00093 /*          The leading dimension of the array WORK.  LDWORK >= max(1,N). */
00094 
00095 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00096 
00097 /*  RESID   (output) DOUBLE PRECISION */
00098 /*          The scaled residual:  norm(L*U - A) / (norm(A) * EPS) */
00099 
00100 /*  ===================================================================== */
00101 
00102 /*     .. Parameters .. */
00103 /*     .. */
00104 /*     .. Local Scalars .. */
00105 /*     .. */
00106 /*     .. External Functions .. */
00107 /*     .. */
00108 /*     .. Intrinsic Functions .. */
00109 /*     .. */
00110 /*     .. External Subroutines .. */
00111 /*     .. */
00112 /*     .. Executable Statements .. */
00113 
00114 /*     Quick return if possible */
00115 
00116     /* Parameter adjustments */
00117     --dl;
00118     --d__;
00119     --du;
00120     --dlf;
00121     --df;
00122     --duf;
00123     --du2;
00124     --ipiv;
00125     work_dim1 = *ldwork;
00126     work_offset = 1 + work_dim1;
00127     work -= work_offset;
00128     --rwork;
00129 
00130     /* Function Body */
00131     if (*n <= 0) {
00132         *resid = 0.;
00133         return 0;
00134     }
00135 
00136     eps = dlamch_("Epsilon");
00137 
00138 /*     Copy the matrix U to WORK. */
00139 
00140     i__1 = *n;
00141     for (j = 1; j <= i__1; ++j) {
00142         i__2 = *n;
00143         for (i__ = 1; i__ <= i__2; ++i__) {
00144             work[i__ + j * work_dim1] = 0.;
00145 /* L10: */
00146         }
00147 /* L20: */
00148     }
00149     i__1 = *n;
00150     for (i__ = 1; i__ <= i__1; ++i__) {
00151         if (i__ == 1) {
00152             work[i__ + i__ * work_dim1] = df[i__];
00153             if (*n >= 2) {
00154                 work[i__ + (i__ + 1) * work_dim1] = duf[i__];
00155             }
00156             if (*n >= 3) {
00157                 work[i__ + (i__ + 2) * work_dim1] = du2[i__];
00158             }
00159         } else if (i__ == *n) {
00160             work[i__ + i__ * work_dim1] = df[i__];
00161         } else {
00162             work[i__ + i__ * work_dim1] = df[i__];
00163             work[i__ + (i__ + 1) * work_dim1] = duf[i__];
00164             if (i__ < *n - 1) {
00165                 work[i__ + (i__ + 2) * work_dim1] = du2[i__];
00166             }
00167         }
00168 /* L30: */
00169     }
00170 
00171 /*     Multiply on the left by L. */
00172 
00173     lastj = *n;
00174     for (i__ = *n - 1; i__ >= 1; --i__) {
00175         li = dlf[i__];
00176         i__1 = lastj - i__ + 1;
00177         daxpy_(&i__1, &li, &work[i__ + i__ * work_dim1], ldwork, &work[i__ + 
00178                 1 + i__ * work_dim1], ldwork);
00179         ip = ipiv[i__];
00180         if (ip == i__) {
00181 /* Computing MIN */
00182             i__1 = i__ + 2;
00183             lastj = min(i__1,*n);
00184         } else {
00185             i__1 = lastj - i__ + 1;
00186             dswap_(&i__1, &work[i__ + i__ * work_dim1], ldwork, &work[i__ + 1 
00187                     + i__ * work_dim1], ldwork);
00188         }
00189 /* L40: */
00190     }
00191 
00192 /*     Subtract the matrix A. */
00193 
00194     work[work_dim1 + 1] -= d__[1];
00195     if (*n > 1) {
00196         work[(work_dim1 << 1) + 1] -= du[1];
00197         work[*n + (*n - 1) * work_dim1] -= dl[*n - 1];
00198         work[*n + *n * work_dim1] -= d__[*n];
00199         i__1 = *n - 1;
00200         for (i__ = 2; i__ <= i__1; ++i__) {
00201             work[i__ + (i__ - 1) * work_dim1] -= dl[i__ - 1];
00202             work[i__ + i__ * work_dim1] -= d__[i__];
00203             work[i__ + (i__ + 1) * work_dim1] -= du[i__];
00204 /* L50: */
00205         }
00206     }
00207 
00208 /*     Compute the 1-norm of the tridiagonal matrix A. */
00209 
00210     anorm = dlangt_("1", n, &dl[1], &d__[1], &du[1]);
00211 
00212 /*     Compute the 1-norm of WORK, which is only guaranteed to be */
00213 /*     upper Hessenberg. */
00214 
00215     *resid = dlanhs_("1", n, &work[work_offset], ldwork, &rwork[1])
00216             ;
00217 
00218 /*     Compute norm(L*U - A) / (norm(A) * EPS) */
00219 
00220     if (anorm <= 0.) {
00221         if (*resid != 0.) {
00222             *resid = 1. / eps;
00223         }
00224     } else {
00225         *resid = *resid / anorm / eps;
00226     }
00227 
00228     return 0;
00229 
00230 /*     End of DGTT01 */
00231 
00232 } /* dgtt01_ */


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