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


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