dtrt01.c
Go to the documentation of this file.
00001 /* dtrt01.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 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 /* Subroutine */ int dtrt01_(char *uplo, char *diag, integer *n, doublereal *
00021         a, integer *lda, doublereal *ainv, integer *ldainv, doublereal *rcond, 
00022          doublereal *work, doublereal *resid)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, ainv_dim1, ainv_offset, i__1, i__2;
00026 
00027     /* Local variables */
00028     integer j;
00029     doublereal eps;
00030     extern logical lsame_(char *, char *);
00031     doublereal anorm;
00032     extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *, 
00033             doublereal *, integer *, doublereal *, integer *);
00034     extern doublereal dlamch_(char *), dlantr_(char *, char *, char *, 
00035              integer *, integer *, doublereal *, integer *, doublereal *);
00036     doublereal ainvnm;
00037 
00038 
00039 /*  -- LAPACK test routine (version 3.1) -- */
00040 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00041 /*     November 2006 */
00042 
00043 /*     .. Scalar Arguments .. */
00044 /*     .. */
00045 /*     .. Array Arguments .. */
00046 /*     .. */
00047 
00048 /*  Purpose */
00049 /*  ======= */
00050 
00051 /*  DTRT01 computes the residual for a triangular matrix A times its */
00052 /*  inverse: */
00053 /*     RESID = norm( A*AINV - I ) / ( N * norm(A) * norm(AINV) * EPS ), */
00054 /*  where EPS is the machine epsilon. */
00055 
00056 /*  Arguments */
00057 /*  ========== */
00058 
00059 /*  UPLO    (input) CHARACTER*1 */
00060 /*          Specifies whether the matrix A is upper or lower triangular. */
00061 /*          = 'U':  Upper triangular */
00062 /*          = 'L':  Lower triangular */
00063 
00064 /*  DIAG    (input) CHARACTER*1 */
00065 /*          Specifies whether or not the matrix A is unit triangular. */
00066 /*          = 'N':  Non-unit triangular */
00067 /*          = 'U':  Unit triangular */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The order of the matrix A.  N >= 0. */
00071 
00072 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00073 /*          The triangular matrix A.  If UPLO = 'U', the leading n by n */
00074 /*          upper triangular part of the array A contains the upper */
00075 /*          triangular matrix, and the strictly lower triangular part of */
00076 /*          A is not referenced.  If UPLO = 'L', the leading n by n lower */
00077 /*          triangular part of the array A contains the lower triangular */
00078 /*          matrix, and the strictly upper triangular part of A is not */
00079 /*          referenced.  If DIAG = 'U', the diagonal elements of A are */
00080 /*          also not referenced and are assumed to be 1. */
00081 
00082 /*  LDA     (input) INTEGER */
00083 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00084 
00085 /*  AINV    (input/output) DOUBLE PRECISION array, dimension (LDAINV,N) */
00086 /*          On entry, the (triangular) inverse of the matrix A, in the */
00087 /*          same storage format as A. */
00088 /*          On exit, the contents of AINV are destroyed. */
00089 
00090 /*  LDAINV  (input) INTEGER */
00091 /*          The leading dimension of the array AINV.  LDAINV >= max(1,N). */
00092 
00093 /*  RCOND   (output) DOUBLE PRECISION */
00094 /*          The reciprocal condition number of A, computed as */
00095 /*          1/(norm(A) * norm(AINV)). */
00096 
00097 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (N) */
00098 
00099 /*  RESID   (output) DOUBLE PRECISION */
00100 /*          norm(A*AINV - I) / ( N * norm(A) * norm(AINV) * EPS ) */
00101 
00102 /*  ===================================================================== */
00103 
00104 /*     .. Parameters .. */
00105 /*     .. */
00106 /*     .. Local Scalars .. */
00107 /*     .. */
00108 /*     .. External Functions .. */
00109 /*     .. */
00110 /*     .. External Subroutines .. */
00111 /*     .. */
00112 /*     .. Intrinsic Functions .. */
00113 /*     .. */
00114 /*     .. Executable Statements .. */
00115 
00116 /*     Quick exit if N = 0 */
00117 
00118     /* Parameter adjustments */
00119     a_dim1 = *lda;
00120     a_offset = 1 + a_dim1;
00121     a -= a_offset;
00122     ainv_dim1 = *ldainv;
00123     ainv_offset = 1 + ainv_dim1;
00124     ainv -= ainv_offset;
00125     --work;
00126 
00127     /* Function Body */
00128     if (*n <= 0) {
00129         *rcond = 1.;
00130         *resid = 0.;
00131         return 0;
00132     }
00133 
00134 /*     Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0. */
00135 
00136     eps = dlamch_("Epsilon");
00137     anorm = dlantr_("1", uplo, diag, n, n, &a[a_offset], lda, &work[1]);
00138     ainvnm = dlantr_("1", uplo, diag, n, n, &ainv[ainv_offset], ldainv, &work[
00139             1]);
00140     if (anorm <= 0. || ainvnm <= 0.) {
00141         *rcond = 0.;
00142         *resid = 1. / eps;
00143         return 0;
00144     }
00145     *rcond = 1. / anorm / ainvnm;
00146 
00147 /*     Set the diagonal of AINV to 1 if AINV has unit diagonal. */
00148 
00149     if (lsame_(diag, "U")) {
00150         i__1 = *n;
00151         for (j = 1; j <= i__1; ++j) {
00152             ainv[j + j * ainv_dim1] = 1.;
00153 /* L10: */
00154         }
00155     }
00156 
00157 /*     Compute A * AINV, overwriting AINV. */
00158 
00159     if (lsame_(uplo, "U")) {
00160         i__1 = *n;
00161         for (j = 1; j <= i__1; ++j) {
00162             dtrmv_("Upper", "No transpose", diag, &j, &a[a_offset], lda, &
00163                     ainv[j * ainv_dim1 + 1], &c__1);
00164 /* L20: */
00165         }
00166     } else {
00167         i__1 = *n;
00168         for (j = 1; j <= i__1; ++j) {
00169             i__2 = *n - j + 1;
00170             dtrmv_("Lower", "No transpose", diag, &i__2, &a[j + j * a_dim1], 
00171                     lda, &ainv[j + j * ainv_dim1], &c__1);
00172 /* L30: */
00173         }
00174     }
00175 
00176 /*     Subtract 1 from each diagonal element to form A*AINV - I. */
00177 
00178     i__1 = *n;
00179     for (j = 1; j <= i__1; ++j) {
00180         ainv[j + j * ainv_dim1] += -1.;
00181 /* L40: */
00182     }
00183 
00184 /*     Compute norm(A*AINV - I) / (N * norm(A) * norm(AINV) * EPS) */
00185 
00186     *resid = dlantr_("1", uplo, "Non-unit", n, n, &ainv[ainv_offset], ldainv, 
00187             &work[1]);
00188 
00189     *resid = *resid * *rcond / (doublereal) (*n) / eps;
00190 
00191     return 0;
00192 
00193 /*     End of DTRT01 */
00194 
00195 } /* dtrt01_ */


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