cppt03.c
Go to the documentation of this file.
00001 /* cppt03.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 complex c_b1 = {0.f,0.f};
00019 static integer c__1 = 1;
00020 
00021 /* Subroutine */ int cppt03_(char *uplo, integer *n, complex *a, complex *
00022         ainv, complex *work, integer *ldwork, real *rwork, real *rcond, real *
00023         resid)
00024 {
00025     /* System generated locals */
00026     integer work_dim1, work_offset, i__1, i__2, i__3;
00027     complex q__1;
00028 
00029     /* Builtin functions */
00030     void r_cnjg(complex *, complex *);
00031 
00032     /* Local variables */
00033     integer i__, j, jj;
00034     real eps;
00035     extern logical lsame_(char *, char *);
00036     real anorm;
00037     extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, 
00038             complex *, integer *), chpmv_(char *, integer *, complex *, 
00039             complex *, complex *, integer *, complex *, complex *, integer *);
00040     extern doublereal clange_(char *, integer *, integer *, complex *, 
00041             integer *, real *), clanhp_(char *, char *, integer *, 
00042             complex *, real *), slamch_(char *);
00043     real ainvnm;
00044 
00045 
00046 /*  -- LAPACK test routine (version 3.1) -- */
00047 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00048 /*     November 2006 */
00049 
00050 /*     .. Scalar Arguments .. */
00051 /*     .. */
00052 /*     .. Array Arguments .. */
00053 /*     .. */
00054 
00055 /*  Purpose */
00056 /*  ======= */
00057 
00058 /*  CPPT03 computes the residual for a Hermitian packed matrix times its */
00059 /*  inverse: */
00060 /*     norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ), */
00061 /*  where EPS is the machine epsilon. */
00062 
00063 /*  Arguments */
00064 /*  ========== */
00065 
00066 /*  UPLO    (input) CHARACTER*1 */
00067 /*          Specifies whether the upper or lower triangular part of the */
00068 /*          Hermitian matrix A is stored: */
00069 /*          = 'U':  Upper triangular */
00070 /*          = 'L':  Lower triangular */
00071 
00072 /*  N       (input) INTEGER */
00073 /*          The number of rows and columns of the matrix A.  N >= 0. */
00074 
00075 /*  A       (input) COMPLEX array, dimension (N*(N+1)/2) */
00076 /*          The original Hermitian matrix A, stored as a packed */
00077 /*          triangular matrix. */
00078 
00079 /*  AINV    (input) COMPLEX array, dimension (N*(N+1)/2) */
00080 /*          The (Hermitian) inverse of the matrix A, stored as a packed */
00081 /*          triangular matrix. */
00082 
00083 /*  WORK    (workspace) COMPLEX array, dimension (LDWORK,N) */
00084 
00085 /*  LDWORK  (input) INTEGER */
00086 /*          The leading dimension of the array WORK.  LDWORK >= max(1,N). */
00087 
00088 /*  RWORK   (workspace) REAL array, dimension (N) */
00089 
00090 /*  RCOND   (output) REAL */
00091 /*          The reciprocal of the condition number of A, computed as */
00092 /*          ( 1/norm(A) ) / norm(AINV). */
00093 
00094 /*  RESID   (output) REAL */
00095 /*          norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS ) */
00096 
00097 /*  ===================================================================== */
00098 
00099 /*     .. Parameters .. */
00100 /*     .. */
00101 /*     .. Local Scalars .. */
00102 /*     .. */
00103 /*     .. External Functions .. */
00104 /*     .. */
00105 /*     .. Intrinsic Functions .. */
00106 /*     .. */
00107 /*     .. External Subroutines .. */
00108 /*     .. */
00109 /*     .. Executable Statements .. */
00110 
00111 /*     Quick exit if N = 0. */
00112 
00113     /* Parameter adjustments */
00114     --a;
00115     --ainv;
00116     work_dim1 = *ldwork;
00117     work_offset = 1 + work_dim1;
00118     work -= work_offset;
00119     --rwork;
00120 
00121     /* Function Body */
00122     if (*n <= 0) {
00123         *rcond = 1.f;
00124         *resid = 0.f;
00125         return 0;
00126     }
00127 
00128 /*     Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0. */
00129 
00130     eps = slamch_("Epsilon");
00131     anorm = clanhp_("1", uplo, n, &a[1], &rwork[1]);
00132     ainvnm = clanhp_("1", uplo, n, &ainv[1], &rwork[1]);
00133     if (anorm <= 0.f || ainvnm <= 0.f) {
00134         *rcond = 0.f;
00135         *resid = 1.f / eps;
00136         return 0;
00137     }
00138     *rcond = 1.f / anorm / ainvnm;
00139 
00140 /*     UPLO = 'U': */
00141 /*     Copy the leading N-1 x N-1 submatrix of AINV to WORK(1:N,2:N) and */
00142 /*     expand it to a full matrix, then multiply by A one column at a */
00143 /*     time, moving the result one column to the left. */
00144 
00145     if (lsame_(uplo, "U")) {
00146 
00147 /*        Copy AINV */
00148 
00149         jj = 1;
00150         i__1 = *n - 1;
00151         for (j = 1; j <= i__1; ++j) {
00152             ccopy_(&j, &ainv[jj], &c__1, &work[(j + 1) * work_dim1 + 1], &
00153                     c__1);
00154             i__2 = j - 1;
00155             for (i__ = 1; i__ <= i__2; ++i__) {
00156                 i__3 = j + (i__ + 1) * work_dim1;
00157                 r_cnjg(&q__1, &ainv[jj + i__ - 1]);
00158                 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00159 /* L10: */
00160             }
00161             jj += j;
00162 /* L20: */
00163         }
00164         jj = (*n - 1) * *n / 2 + 1;
00165         i__1 = *n - 1;
00166         for (i__ = 1; i__ <= i__1; ++i__) {
00167             i__2 = *n + (i__ + 1) * work_dim1;
00168             r_cnjg(&q__1, &ainv[jj + i__ - 1]);
00169             work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00170 /* L30: */
00171         }
00172 
00173 /*        Multiply by A */
00174 
00175         i__1 = *n - 1;
00176         for (j = 1; j <= i__1; ++j) {
00177             q__1.r = -1.f, q__1.i = -0.f;
00178             chpmv_("Upper", n, &q__1, &a[1], &work[(j + 1) * work_dim1 + 1], &
00179                     c__1, &c_b1, &work[j * work_dim1 + 1], &c__1);
00180 /* L40: */
00181         }
00182         q__1.r = -1.f, q__1.i = -0.f;
00183         chpmv_("Upper", n, &q__1, &a[1], &ainv[jj], &c__1, &c_b1, &work[*n * 
00184                 work_dim1 + 1], &c__1);
00185 
00186 /*     UPLO = 'L': */
00187 /*     Copy the trailing N-1 x N-1 submatrix of AINV to WORK(1:N,1:N-1) */
00188 /*     and multiply by A, moving each column to the right. */
00189 
00190     } else {
00191 
00192 /*        Copy AINV */
00193 
00194         i__1 = *n - 1;
00195         for (i__ = 1; i__ <= i__1; ++i__) {
00196             i__2 = i__ * work_dim1 + 1;
00197             r_cnjg(&q__1, &ainv[i__ + 1]);
00198             work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00199 /* L50: */
00200         }
00201         jj = *n + 1;
00202         i__1 = *n;
00203         for (j = 2; j <= i__1; ++j) {
00204             i__2 = *n - j + 1;
00205             ccopy_(&i__2, &ainv[jj], &c__1, &work[j + (j - 1) * work_dim1], &
00206                     c__1);
00207             i__2 = *n - j;
00208             for (i__ = 1; i__ <= i__2; ++i__) {
00209                 i__3 = j + (j + i__ - 1) * work_dim1;
00210                 r_cnjg(&q__1, &ainv[jj + i__]);
00211                 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00212 /* L60: */
00213             }
00214             jj = jj + *n - j + 1;
00215 /* L70: */
00216         }
00217 
00218 /*        Multiply by A */
00219 
00220         for (j = *n; j >= 2; --j) {
00221             q__1.r = -1.f, q__1.i = -0.f;
00222             chpmv_("Lower", n, &q__1, &a[1], &work[(j - 1) * work_dim1 + 1], &
00223                     c__1, &c_b1, &work[j * work_dim1 + 1], &c__1);
00224 /* L80: */
00225         }
00226         q__1.r = -1.f, q__1.i = -0.f;
00227         chpmv_("Lower", n, &q__1, &a[1], &ainv[1], &c__1, &c_b1, &work[
00228                 work_dim1 + 1], &c__1);
00229 
00230     }
00231 
00232 /*     Add the identity matrix to WORK . */
00233 
00234     i__1 = *n;
00235     for (i__ = 1; i__ <= i__1; ++i__) {
00236         i__2 = i__ + i__ * work_dim1;
00237         i__3 = i__ + i__ * work_dim1;
00238         q__1.r = work[i__3].r + 1.f, q__1.i = work[i__3].i + 0.f;
00239         work[i__2].r = q__1.r, work[i__2].i = q__1.i;
00240 /* L90: */
00241     }
00242 
00243 /*     Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS) */
00244 
00245     *resid = clange_("1", n, n, &work[work_offset], ldwork, &rwork[1]);
00246 
00247     *resid = *resid * *rcond / eps / (real) (*n);
00248 
00249     return 0;
00250 
00251 /*     End of CPPT03 */
00252 
00253 } /* cppt03_ */


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