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


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