zhpt01.c
Go to the documentation of this file.
00001 /* zhpt01.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 doublecomplex c_b2 = {1.,0.};
00020 
00021 /* Subroutine */ int zhpt01_(char *uplo, integer *n, doublecomplex *a, 
00022         doublecomplex *afac, integer *ipiv, doublecomplex *c__, integer *ldc, 
00023         doublereal *rwork, doublereal *resid)
00024 {
00025     /* System generated locals */
00026     integer c_dim1, c_offset, i__1, i__2, i__3, i__4, i__5;
00027     doublereal d__1;
00028     doublecomplex z__1;
00029 
00030     /* Builtin functions */
00031     double d_imag(doublecomplex *);
00032 
00033     /* Local variables */
00034     integer i__, j, jc;
00035     doublereal eps;
00036     integer info;
00037     extern logical lsame_(char *, char *);
00038     doublereal anorm;
00039     extern doublereal dlamch_(char *), zlanhe_(char *, char *, 
00040             integer *, doublecomplex *, integer *, doublereal *), zlanhp_(char *, char *, integer *, doublecomplex *, 
00041             doublereal *);
00042     extern /* Subroutine */ int zlaset_(char *, integer *, integer *, 
00043             doublecomplex *, doublecomplex *, doublecomplex *, integer *), zlavhp_(char *, char *, char *, integer *, integer *, 
00044             doublecomplex *, integer *, doublecomplex *, integer *, integer *);
00045 
00046 
00047 /*  -- LAPACK test routine (version 3.1) -- */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  ZHPT01 reconstructs a Hermitian indefinite packed matrix A from its */
00060 /*  block L*D*L' or U*D*U' factorization and computes the residual */
00061 /*     norm( C - A ) / ( N * norm(A) * EPS ), */
00062 /*  where C is the reconstructed matrix, EPS is the machine epsilon, */
00063 /*  L' is the conjugate transpose of L, and U' is the conjugate transpose */
00064 /*  of U. */
00065 
00066 /*  Arguments */
00067 /*  ========== */
00068 
00069 /*  UPLO    (input) CHARACTER*1 */
00070 /*          Specifies whether the upper or lower triangular part of the */
00071 /*          Hermitian matrix A is stored: */
00072 /*          = 'U':  Upper triangular */
00073 /*          = 'L':  Lower triangular */
00074 
00075 /*  N       (input) INTEGER */
00076 /*          The number of rows and columns of the matrix A.  N >= 0. */
00077 
00078 /*  A       (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00079 /*          The original Hermitian matrix A, stored as a packed */
00080 /*          triangular matrix. */
00081 
00082 /*  AFAC    (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00083 /*          The factored form of the matrix A, stored as a packed */
00084 /*          triangular matrix.  AFAC contains the block diagonal matrix D */
00085 /*          and the multipliers used to obtain the factor L or U from the */
00086 /*          block L*D*L' or U*D*U' factorization as computed by ZHPTRF. */
00087 
00088 /*  IPIV    (input) INTEGER array, dimension (N) */
00089 /*          The pivot indices from ZHPTRF. */
00090 
00091 /*  C       (workspace) COMPLEX*16 array, dimension (LDC,N) */
00092 
00093 /*  LDC     (integer) INTEGER */
00094 /*          The leading dimension of the array C.  LDC >= max(1,N). */
00095 
00096 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00097 
00098 /*  RESID   (output) DOUBLE PRECISION */
00099 /*          If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS ) */
00100 /*          If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS ) */
00101 
00102 /*  ===================================================================== */
00103 
00104 /*     .. Parameters .. */
00105 /*     .. */
00106 /*     .. Local Scalars .. */
00107 /*     .. */
00108 /*     .. External Functions .. */
00109 /*     .. */
00110 /*     .. External Subroutines .. */
00111 /*     .. */
00112 /*     .. Intrinsic Functions .. */
00113 /*     .. */
00114 /*     .. Executable Statements .. */
00115 
00116 /*     Quick exit if N = 0. */
00117 
00118     /* Parameter adjustments */
00119     --a;
00120     --afac;
00121     --ipiv;
00122     c_dim1 = *ldc;
00123     c_offset = 1 + c_dim1;
00124     c__ -= c_offset;
00125     --rwork;
00126 
00127     /* Function Body */
00128     if (*n <= 0) {
00129         *resid = 0.;
00130         return 0;
00131     }
00132 
00133 /*     Determine EPS and the norm of A. */
00134 
00135     eps = dlamch_("Epsilon");
00136     anorm = zlanhp_("1", uplo, n, &a[1], &rwork[1]);
00137 
00138 /*     Check the imaginary parts of the diagonal elements and return with */
00139 /*     an error code if any are nonzero. */
00140 
00141     jc = 1;
00142     if (lsame_(uplo, "U")) {
00143         i__1 = *n;
00144         for (j = 1; j <= i__1; ++j) {
00145             if (d_imag(&afac[jc]) != 0.) {
00146                 *resid = 1. / eps;
00147                 return 0;
00148             }
00149             jc = jc + j + 1;
00150 /* L10: */
00151         }
00152     } else {
00153         i__1 = *n;
00154         for (j = 1; j <= i__1; ++j) {
00155             if (d_imag(&afac[jc]) != 0.) {
00156                 *resid = 1. / eps;
00157                 return 0;
00158             }
00159             jc = jc + *n - j + 1;
00160 /* L20: */
00161         }
00162     }
00163 
00164 /*     Initialize C to the identity matrix. */
00165 
00166     zlaset_("Full", n, n, &c_b1, &c_b2, &c__[c_offset], ldc);
00167 
00168 /*     Call ZLAVHP to form the product D * U' (or D * L' ). */
00169 
00170     zlavhp_(uplo, "Conjugate", "Non-unit", n, n, &afac[1], &ipiv[1], &c__[
00171             c_offset], ldc, &info);
00172 
00173 /*     Call ZLAVHP again to multiply by U ( or L ). */
00174 
00175     zlavhp_(uplo, "No transpose", "Unit", n, n, &afac[1], &ipiv[1], &c__[
00176             c_offset], ldc, &info);
00177 
00178 /*     Compute the difference  C - A . */
00179 
00180     if (lsame_(uplo, "U")) {
00181         jc = 0;
00182         i__1 = *n;
00183         for (j = 1; j <= i__1; ++j) {
00184             i__2 = j - 1;
00185             for (i__ = 1; i__ <= i__2; ++i__) {
00186                 i__3 = i__ + j * c_dim1;
00187                 i__4 = i__ + j * c_dim1;
00188                 i__5 = jc + i__;
00189                 z__1.r = c__[i__4].r - a[i__5].r, z__1.i = c__[i__4].i - a[
00190                         i__5].i;
00191                 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00192 /* L30: */
00193             }
00194             i__2 = j + j * c_dim1;
00195             i__3 = j + j * c_dim1;
00196             i__4 = jc + j;
00197             d__1 = a[i__4].r;
00198             z__1.r = c__[i__3].r - d__1, z__1.i = c__[i__3].i;
00199             c__[i__2].r = z__1.r, c__[i__2].i = z__1.i;
00200             jc += j;
00201 /* L40: */
00202         }
00203     } else {
00204         jc = 1;
00205         i__1 = *n;
00206         for (j = 1; j <= i__1; ++j) {
00207             i__2 = j + j * c_dim1;
00208             i__3 = j + j * c_dim1;
00209             i__4 = jc;
00210             d__1 = a[i__4].r;
00211             z__1.r = c__[i__3].r - d__1, z__1.i = c__[i__3].i;
00212             c__[i__2].r = z__1.r, c__[i__2].i = z__1.i;
00213             i__2 = *n;
00214             for (i__ = j + 1; i__ <= i__2; ++i__) {
00215                 i__3 = i__ + j * c_dim1;
00216                 i__4 = i__ + j * c_dim1;
00217                 i__5 = jc + i__ - j;
00218                 z__1.r = c__[i__4].r - a[i__5].r, z__1.i = c__[i__4].i - a[
00219                         i__5].i;
00220                 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00221 /* L50: */
00222             }
00223             jc = jc + *n - j + 1;
00224 /* L60: */
00225         }
00226     }
00227 
00228 /*     Compute norm( C - A ) / ( N * norm(A) * EPS ) */
00229 
00230     *resid = zlanhe_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]);
00231 
00232     if (anorm <= 0.) {
00233         if (*resid != 0.) {
00234             *resid = 1. / eps;
00235         }
00236     } else {
00237         *resid = *resid / (doublereal) (*n) / anorm / eps;
00238     }
00239 
00240     return 0;
00241 
00242 /*     End of ZHPT01 */
00243 
00244 } /* zhpt01_ */


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