zppt01.c
Go to the documentation of this file.
00001 /* zppt01.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 doublereal c_b19 = 1.;
00020 
00021 /* Subroutine */ int zppt01_(char *uplo, integer *n, doublecomplex *a, 
00022         doublecomplex *afac, doublereal *rwork, doublereal *resid)
00023 {
00024     /* System generated locals */
00025     integer i__1, i__2, i__3, i__4, i__5;
00026     doublereal d__1;
00027     doublecomplex z__1;
00028 
00029     /* Builtin functions */
00030     double d_imag(doublecomplex *);
00031 
00032     /* Local variables */
00033     integer i__, k, kc;
00034     doublecomplex tc;
00035     doublereal tr, eps;
00036     extern /* Subroutine */ int zhpr_(char *, integer *, doublereal *, 
00037             doublecomplex *, integer *, doublecomplex *);
00038     extern logical lsame_(char *, char *);
00039     doublereal anorm;
00040     extern /* Subroutine */ int zscal_(integer *, doublecomplex *, 
00041             doublecomplex *, integer *);
00042     extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *, 
00043             doublecomplex *, integer *, doublecomplex *, integer *);
00044     extern /* Subroutine */ int ztpmv_(char *, char *, char *, integer *, 
00045             doublecomplex *, doublecomplex *, integer *);
00046     extern doublereal dlamch_(char *), zlanhp_(char *, char *, 
00047             integer *, doublecomplex *, doublereal *);
00048 
00049 
00050 /*  -- LAPACK test routine (version 3.1) -- */
00051 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00052 /*     November 2006 */
00053 
00054 /*     .. Scalar Arguments .. */
00055 /*     .. */
00056 /*     .. Array Arguments .. */
00057 /*     .. */
00058 
00059 /*  Purpose */
00060 /*  ======= */
00061 
00062 /*  ZPPT01 reconstructs a Hermitian positive definite packed matrix A */
00063 /*  from its L*L' or U'*U factorization and computes the residual */
00064 /*     norm( L*L' - A ) / ( N * norm(A) * EPS ) or */
00065 /*     norm( U'*U - A ) / ( N * norm(A) * EPS ), */
00066 /*  where EPS is the machine epsilon, L' is the conjugate transpose of */
00067 /*  L, and U' is the conjugate transpose of U. */
00068 
00069 /*  Arguments */
00070 /*  ========== */
00071 
00072 /*  UPLO    (input) CHARACTER*1 */
00073 /*          Specifies whether the upper or lower triangular part of the */
00074 /*          Hermitian matrix A is stored: */
00075 /*          = 'U':  Upper triangular */
00076 /*          = 'L':  Lower triangular */
00077 
00078 /*  N       (input) INTEGER */
00079 /*          The number of rows and columns of the matrix A.  N >= 0. */
00080 
00081 /*  A       (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00082 /*          The original Hermitian matrix A, stored as a packed */
00083 /*          triangular matrix. */
00084 
00085 /*  AFAC    (input/output) COMPLEX*16 array, dimension (N*(N+1)/2) */
00086 /*          On entry, the factor L or U from the L*L' or U'*U */
00087 /*          factorization of A, stored as a packed triangular matrix. */
00088 /*          Overwritten with the reconstructed matrix, and then with the */
00089 /*          difference L*L' - A (or U'*U - A). */
00090 
00091 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00092 
00093 /*  RESID   (output) DOUBLE PRECISION */
00094 /*          If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS ) */
00095 /*          If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * 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     --afac;
00116     --a;
00117 
00118     /* Function Body */
00119     if (*n <= 0) {
00120         *resid = 0.;
00121         return 0;
00122     }
00123 
00124 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00125 
00126     eps = dlamch_("Epsilon");
00127     anorm = zlanhp_("1", uplo, n, &a[1], &rwork[1]);
00128     if (anorm <= 0.) {
00129         *resid = 1. / eps;
00130         return 0;
00131     }
00132 
00133 /*     Check the imaginary parts of the diagonal elements and return with */
00134 /*     an error code if any are nonzero. */
00135 
00136     kc = 1;
00137     if (lsame_(uplo, "U")) {
00138         i__1 = *n;
00139         for (k = 1; k <= i__1; ++k) {
00140             if (d_imag(&afac[kc]) != 0.) {
00141                 *resid = 1. / eps;
00142                 return 0;
00143             }
00144             kc = kc + k + 1;
00145 /* L10: */
00146         }
00147     } else {
00148         i__1 = *n;
00149         for (k = 1; k <= i__1; ++k) {
00150             if (d_imag(&afac[kc]) != 0.) {
00151                 *resid = 1. / eps;
00152                 return 0;
00153             }
00154             kc = kc + *n - k + 1;
00155 /* L20: */
00156         }
00157     }
00158 
00159 /*     Compute the product U'*U, overwriting U. */
00160 
00161     if (lsame_(uplo, "U")) {
00162         kc = *n * (*n - 1) / 2 + 1;
00163         for (k = *n; k >= 1; --k) {
00164 
00165 /*           Compute the (K,K) element of the result. */
00166 
00167             zdotc_(&z__1, &k, &afac[kc], &c__1, &afac[kc], &c__1);
00168             tr = z__1.r;
00169             i__1 = kc + k - 1;
00170             afac[i__1].r = tr, afac[i__1].i = 0.;
00171 
00172 /*           Compute the rest of column K. */
00173 
00174             if (k > 1) {
00175                 i__1 = k - 1;
00176                 ztpmv_("Upper", "Conjugate", "Non-unit", &i__1, &afac[1], &
00177                         afac[kc], &c__1);
00178                 kc -= k - 1;
00179             }
00180 /* L30: */
00181         }
00182 
00183 /*        Compute the difference  L*L' - A */
00184 
00185         kc = 1;
00186         i__1 = *n;
00187         for (k = 1; k <= i__1; ++k) {
00188             i__2 = k - 1;
00189             for (i__ = 1; i__ <= i__2; ++i__) {
00190                 i__3 = kc + i__ - 1;
00191                 i__4 = kc + i__ - 1;
00192                 i__5 = kc + i__ - 1;
00193                 z__1.r = afac[i__4].r - a[i__5].r, z__1.i = afac[i__4].i - a[
00194                         i__5].i;
00195                 afac[i__3].r = z__1.r, afac[i__3].i = z__1.i;
00196 /* L40: */
00197             }
00198             i__2 = kc + k - 1;
00199             i__3 = kc + k - 1;
00200             i__4 = kc + k - 1;
00201             d__1 = a[i__4].r;
00202             z__1.r = afac[i__3].r - d__1, z__1.i = afac[i__3].i;
00203             afac[i__2].r = z__1.r, afac[i__2].i = z__1.i;
00204             kc += k;
00205 /* L50: */
00206         }
00207 
00208 /*     Compute the product L*L', overwriting L. */
00209 
00210     } else {
00211         kc = *n * (*n + 1) / 2;
00212         for (k = *n; k >= 1; --k) {
00213 
00214 /*           Add a multiple of column K of the factor L to each of */
00215 /*           columns K+1 through N. */
00216 
00217             if (k < *n) {
00218                 i__1 = *n - k;
00219                 zhpr_("Lower", &i__1, &c_b19, &afac[kc + 1], &c__1, &afac[kc 
00220                         + *n - k + 1]);
00221             }
00222 
00223 /*           Scale column K by the diagonal element. */
00224 
00225             i__1 = kc;
00226             tc.r = afac[i__1].r, tc.i = afac[i__1].i;
00227             i__1 = *n - k + 1;
00228             zscal_(&i__1, &tc, &afac[kc], &c__1);
00229 
00230             kc -= *n - k + 2;
00231 /* L60: */
00232         }
00233 
00234 /*        Compute the difference  U'*U - A */
00235 
00236         kc = 1;
00237         i__1 = *n;
00238         for (k = 1; k <= i__1; ++k) {
00239             i__2 = kc;
00240             i__3 = kc;
00241             i__4 = kc;
00242             d__1 = a[i__4].r;
00243             z__1.r = afac[i__3].r - d__1, z__1.i = afac[i__3].i;
00244             afac[i__2].r = z__1.r, afac[i__2].i = z__1.i;
00245             i__2 = *n;
00246             for (i__ = k + 1; i__ <= i__2; ++i__) {
00247                 i__3 = kc + i__ - k;
00248                 i__4 = kc + i__ - k;
00249                 i__5 = kc + i__ - k;
00250                 z__1.r = afac[i__4].r - a[i__5].r, z__1.i = afac[i__4].i - a[
00251                         i__5].i;
00252                 afac[i__3].r = z__1.r, afac[i__3].i = z__1.i;
00253 /* L70: */
00254             }
00255             kc = kc + *n - k + 1;
00256 /* L80: */
00257         }
00258     }
00259 
00260 /*     Compute norm( L*U - A ) / ( N * norm(A) * EPS ) */
00261 
00262     *resid = zlanhp_("1", uplo, n, &afac[1], &rwork[1]);
00263 
00264     *resid = *resid / (doublereal) (*n) / anorm / eps;
00265 
00266     return 0;
00267 
00268 /*     End of ZPPT01 */
00269 
00270 } /* zppt01_ */


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