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


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