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


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