ctpt02.c
Go to the documentation of this file.
00001 /* ctpt02.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 ctpt02_(char *uplo, char *trans, char *diag, integer *n, 
00022         integer *nrhs, complex *ap, complex *x, integer *ldx, complex *b, 
00023         integer *ldb, complex *work, real *rwork, real *resid)
00024 {
00025     /* System generated locals */
00026     integer 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 *), ctpmv_(char *, char *, char *, 
00037             integer *, complex *, complex *, integer *);
00038     real xnorm;
00039     extern doublereal slamch_(char *), clantp_(char *, char *, char *, 
00040              integer *, complex *, real *), scasum_(
00041             integer *, complex *, integer *);
00042 
00043 
00044 /*  -- LAPACK test routine (version 3.1) -- */
00045 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00046 /*     November 2006 */
00047 
00048 /*     .. Scalar Arguments .. */
00049 /*     .. */
00050 /*     .. Array Arguments .. */
00051 /*     .. */
00052 
00053 /*  Purpose */
00054 /*  ======= */
00055 
00056 /*  CTPT02 computes the residual for the computed solution to a */
00057 /*  triangular system of linear equations  A*x = b,  A**T *x = b,  or */
00058 /*  A**H *x = b, when the triangular matrix A is stored in packed format. */
00059 /*  Here A**T denotes the transpose of A, A**H denotes the conjugate */
00060 /*  transpose of A, and x and b are N by NRHS matrices.  The test ratio */
00061 /*  is the maximum over the number of right hand sides of */
00062 /*  the maximum over the number of right 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 /*  AP      (input) COMPLEX array, dimension (N*(N+1)/2) */
00093 /*          The upper or lower triangular matrix A, packed columnwise in */
00094 /*          a linear array.  The j-th column of A is stored in the array */
00095 /*          AP as follows: */
00096 /*          if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j; */
00097 /*          if UPLO = 'L', */
00098 /*             AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n. */
00099 
00100 /*  X       (input) COMPLEX array, dimension (LDX,NRHS) */
00101 /*          The computed solution vectors for the system of linear */
00102 /*          equations. */
00103 
00104 /*  LDX     (input) INTEGER */
00105 /*          The leading dimension of the array X.  LDX >= max(1,N). */
00106 
00107 /*  B       (input) COMPLEX array, dimension (LDB,NRHS) */
00108 /*          The right hand side vectors for the system of linear */
00109 /*          equations. */
00110 
00111 /*  LDB     (input) INTEGER */
00112 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00113 
00114 /*  WORK    (workspace) COMPLEX array, dimension (N) */
00115 
00116 /*  RWORK   (workspace) REAL array, dimension (N) */
00117 
00118 /*  RESID   (output) REAL */
00119 /*          The maximum over the number of right hand sides of */
00120 /*          norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00121 
00122 /*  ===================================================================== */
00123 
00124 /*     .. Parameters .. */
00125 /*     .. */
00126 /*     .. Local Scalars .. */
00127 /*     .. */
00128 /*     .. External Functions .. */
00129 /*     .. */
00130 /*     .. External Subroutines .. */
00131 /*     .. */
00132 /*     .. Intrinsic Functions .. */
00133 /*     .. */
00134 /*     .. Executable Statements .. */
00135 
00136 /*     Quick exit if N = 0 or NRHS = 0 */
00137 
00138     /* Parameter adjustments */
00139     --ap;
00140     x_dim1 = *ldx;
00141     x_offset = 1 + x_dim1;
00142     x -= x_offset;
00143     b_dim1 = *ldb;
00144     b_offset = 1 + b_dim1;
00145     b -= b_offset;
00146     --work;
00147     --rwork;
00148 
00149     /* Function Body */
00150     if (*n <= 0 || *nrhs <= 0) {
00151         *resid = 0.f;
00152         return 0;
00153     }
00154 
00155 /*     Compute the 1-norm of A or A**H. */
00156 
00157     if (lsame_(trans, "N")) {
00158         anorm = clantp_("1", uplo, diag, n, &ap[1], &rwork[1]);
00159     } else {
00160         anorm = clantp_("I", uplo, diag, n, &ap[1], &rwork[1]);
00161     }
00162 
00163 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00164 
00165     eps = slamch_("Epsilon");
00166     if (anorm <= 0.f) {
00167         *resid = 1.f / eps;
00168         return 0;
00169     }
00170 
00171 /*     Compute the maximum over the number of right hand sides of */
00172 /*        norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ). */
00173 
00174     *resid = 0.f;
00175     i__1 = *nrhs;
00176     for (j = 1; j <= i__1; ++j) {
00177         ccopy_(n, &x[j * x_dim1 + 1], &c__1, &work[1], &c__1);
00178         ctpmv_(uplo, trans, diag, n, &ap[1], &work[1], &c__1);
00179         caxpy_(n, &c_b12, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00180         bnorm = scasum_(n, &work[1], &c__1);
00181         xnorm = scasum_(n, &x[j * x_dim1 + 1], &c__1);
00182         if (xnorm <= 0.f) {
00183             *resid = 1.f / eps;
00184         } else {
00185 /* Computing MAX */
00186             r__1 = *resid, r__2 = bnorm / anorm / xnorm / eps;
00187             *resid = dmax(r__1,r__2);
00188         }
00189 /* L10: */
00190     }
00191 
00192     return 0;
00193 
00194 /*     End of CTPT02 */
00195 
00196 } /* ctpt02_ */


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