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


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