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


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