ztrt02.c
Go to the documentation of this file.
00001 /* ztrt02.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 static doublecomplex c_b12 = {-1.,0.};
00020 
00021 /* Subroutine */ int ztrt02_(char *uplo, char *trans, char *diag, integer *n, 
00022         integer *nrhs, doublecomplex *a, integer *lda, doublecomplex *x, 
00023         integer *ldx, doublecomplex *b, integer *ldb, doublecomplex *work, 
00024         doublereal *rwork, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1;
00028     doublereal d__1, d__2;
00029 
00030     /* Local variables */
00031     integer j;
00032     doublereal eps;
00033     extern logical lsame_(char *, char *);
00034     doublereal anorm, bnorm, xnorm;
00035     extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 
00036             doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, 
00037             doublecomplex *, integer *, doublecomplex *, integer *), ztrmv_(
00038             char *, char *, char *, integer *, doublecomplex *, integer *, 
00039             doublecomplex *, integer *);
00040     extern doublereal dlamch_(char *), dzasum_(integer *, 
00041             doublecomplex *, integer *), zlantr_(char *, char *, char *, 
00042             integer *, integer *, doublecomplex *, integer *, doublereal *);
00043 
00044 
00045 /*  -- LAPACK test routine (version 3.1) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  ZTRT02 computes the residual for the computed solution to a */
00058 /*  triangular system of linear equations  A*x = b,  A**T *x = b, */
00059 /*  or A**H *x = b.  Here A is a triangular matrix, A**T is the transpose */
00060 /*  of A, A**H is the conjugate transpose of A, and x and b are N by NRHS */
00061 /*  matrices.  The test ratio is the maximum over the number of right */
00062 /*  hand sides of */
00063 /*     norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ), */
00064 /*  where op(A) denotes A, A**T, or A**H, and EPS is the machine epsilon. */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  UPLO    (input) CHARACTER*1 */
00070 /*          Specifies whether the matrix A is upper or lower triangular. */
00071 /*          = 'U':  Upper triangular */
00072 /*          = 'L':  Lower triangular */
00073 
00074 /*  TRANS   (input) CHARACTER*1 */
00075 /*          Specifies the operation applied to A. */
00076 /*          = 'N':  A *x = b     (No transpose) */
00077 /*          = 'T':  A**T *x = b  (Transpose) */
00078 /*          = 'C':  A**H *x = b  (Conjugate transpose) */
00079 
00080 /*  DIAG    (input) CHARACTER*1 */
00081 /*          Specifies whether or not the matrix A is unit triangular. */
00082 /*          = 'N':  Non-unit triangular */
00083 /*          = 'U':  Unit triangular */
00084 
00085 /*  N       (input) INTEGER */
00086 /*          The order of the matrix A.  N >= 0. */
00087 
00088 /*  NRHS    (input) INTEGER */
00089 /*          The number of right hand sides, i.e., the number of columns */
00090 /*          of the matrices X and B.  NRHS >= 0. */
00091 
00092 /*  A       (input) COMPLEX*16 array, dimension (LDA,N) */
00093 /*          The triangular matrix A.  If UPLO = 'U', the leading n by n */
00094 /*          upper triangular part of the array A contains the upper */
00095 /*          triangular matrix, and the strictly lower triangular part of */
00096 /*          A is not referenced.  If UPLO = 'L', the leading n by n lower */
00097 /*          triangular part of the array A contains the lower triangular */
00098 /*          matrix, and the strictly upper triangular part of A is not */
00099 /*          referenced.  If DIAG = 'U', the diagonal elements of A are */
00100 /*          also not referenced and are assumed to be 1. */
00101 
00102 /*  LDA     (input) INTEGER */
00103 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00104 
00105 /*  X       (input) COMPLEX*16 array, dimension (LDX,NRHS) */
00106 /*          The computed solution vectors for the system of linear */
00107 /*          equations. */
00108 
00109 /*  LDX     (input) INTEGER */
00110 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00111 
00112 /*  B       (input) COMPLEX*16 array, dimension (LDB,NRHS) */
00113 /*          The right hand side vectors for the system of linear */
00114 /*          equations. */
00115 
00116 /*  LDB     (input) INTEGER */
00117 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00118 
00119 /*  WORK    (workspace) COMPLEX*16 array, dimension (N) */
00120 
00121 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00122 
00123 /*  RESID   (output) DOUBLE PRECISION */
00124 /*          The maximum over the number of right hand sides of */
00125 /*          norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00126 
00127 /*  ===================================================================== */
00128 
00129 /*     .. Parameters .. */
00130 /*     .. */
00131 /*     .. Local Scalars .. */
00132 /*     .. */
00133 /*     .. External Functions .. */
00134 /*     .. */
00135 /*     .. External Subroutines .. */
00136 /*     .. */
00137 /*     .. Intrinsic Functions .. */
00138 /*     .. */
00139 /*     .. Executable Statements .. */
00140 
00141 /*     Quick exit if N = 0 or NRHS = 0 */
00142 
00143     /* Parameter adjustments */
00144     a_dim1 = *lda;
00145     a_offset = 1 + a_dim1;
00146     a -= a_offset;
00147     x_dim1 = *ldx;
00148     x_offset = 1 + x_dim1;
00149     x -= x_offset;
00150     b_dim1 = *ldb;
00151     b_offset = 1 + b_dim1;
00152     b -= b_offset;
00153     --work;
00154     --rwork;
00155 
00156     /* Function Body */
00157     if (*n <= 0 || *nrhs <= 0) {
00158         *resid = 0.;
00159         return 0;
00160     }
00161 
00162 /*     Compute the 1-norm of A or A**H. */
00163 
00164     if (lsame_(trans, "N")) {
00165         anorm = zlantr_("1", uplo, diag, n, n, &a[a_offset], lda, &rwork[1]);
00166     } else {
00167         anorm = zlantr_("I", uplo, diag, n, n, &a[a_offset], lda, &rwork[1]);
00168     }
00169 
00170 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00171 
00172     eps = dlamch_("Epsilon");
00173     if (anorm <= 0.) {
00174         *resid = 1. / eps;
00175         return 0;
00176     }
00177 
00178 /*     Compute the maximum over the number of right hand sides of */
00179 /*        norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ) */
00180 
00181     *resid = 0.;
00182     i__1 = *nrhs;
00183     for (j = 1; j <= i__1; ++j) {
00184         zcopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1);
00185         ztrmv_(uplo, trans, diag, n, &a[a_offset], lda, &work[1], &c__1);
00186         zaxpy_(n, &c_b12, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00187         bnorm = dzasum_(n, &work[1], &c__1);
00188         xnorm = dzasum_(n, &x[j * x_dim1 + 1], &c__1);
00189         if (xnorm <= 0.) {
00190             *resid = 1. / eps;
00191         } else {
00192 /* Computing MAX */
00193             d__1 = *resid, d__2 = bnorm / anorm / xnorm / eps;
00194             *resid = max(d__1,d__2);
00195         }
00196 /* L10: */
00197     }
00198 
00199     return 0;
00200 
00201 /*     End of ZTRT02 */
00202 
00203 } /* ztrt02_ */


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