chet01.c
Go to the documentation of this file.
00001 /* chet01.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 complex c_b2 = {1.f,0.f};
00020 
00021 /* Subroutine */ int chet01_(char *uplo, integer *n, complex *a, integer *lda, 
00022          complex *afac, integer *ldafac, integer *ipiv, complex *c__, integer 
00023         *ldc, real *rwork, real *resid)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, afac_dim1, afac_offset, c_dim1, c_offset, i__1, 
00027             i__2, i__3, i__4, i__5;
00028     real r__1;
00029     complex q__1;
00030 
00031     /* Builtin functions */
00032     double r_imag(complex *);
00033 
00034     /* Local variables */
00035     integer i__, j;
00036     real eps;
00037     integer info;
00038     extern logical lsame_(char *, char *);
00039     real anorm;
00040     extern doublereal clanhe_(char *, char *, integer *, complex *, integer *, 
00041              real *);
00042     extern /* Subroutine */ int clavhe_(char *, char *, char *, integer *, 
00043             integer *, complex *, integer *, integer *, complex *, integer *, 
00044             integer *);
00045     extern doublereal slamch_(char *);
00046     extern /* Subroutine */ int claset_(char *, integer *, integer *, complex 
00047             *, complex *, complex *, integer *);
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 /*  CHET01 reconstructs a Hermitian indefinite matrix A from its */
00063 /*  block L*D*L' or U*D*U' factorization and computes the residual */
00064 /*     norm( C - A ) / ( N * norm(A) * EPS ), */
00065 /*  where C is the reconstructed matrix, EPS is the machine epsilon, */
00066 /*  L' is the conjugate transpose of L, and U' is the conjugate transpose */
00067 /*  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 array, dimension (LDA,N) */
00082 /*          The original Hermitian matrix A. */
00083 
00084 /*  LDA     (input) INTEGER */
00085 /*          The leading dimension of the array A.  LDA >= max(1,N) */
00086 
00087 /*  AFAC    (input) COMPLEX array, dimension (LDAFAC,N) */
00088 /*          The factored form of the matrix A.  AFAC contains the block */
00089 /*          diagonal matrix D and the multipliers used to obtain the */
00090 /*          factor L or U from the block L*D*L' or U*D*U' factorization */
00091 /*          as computed by CHETRF. */
00092 
00093 /*  LDAFAC  (input) INTEGER */
00094 /*          The leading dimension of the array AFAC.  LDAFAC >= max(1,N). */
00095 
00096 /*  IPIV    (input) INTEGER array, dimension (N) */
00097 /*          The pivot indices from CHETRF. */
00098 
00099 /*  C       (workspace) COMPLEX array, dimension (LDC,N) */
00100 
00101 /*  LDC     (integer) INTEGER */
00102 /*          The leading dimension of the array C.  LDC >= max(1,N). */
00103 
00104 /*  RWORK   (workspace) REAL array, dimension (N) */
00105 
00106 /*  RESID   (output) REAL */
00107 /*          If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS ) */
00108 /*          If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS ) */
00109 
00110 /*  ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. External Functions .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. Executable Statements .. */
00123 
00124 /*     Quick exit if N = 0. */
00125 
00126     /* Parameter adjustments */
00127     a_dim1 = *lda;
00128     a_offset = 1 + a_dim1;
00129     a -= a_offset;
00130     afac_dim1 = *ldafac;
00131     afac_offset = 1 + afac_dim1;
00132     afac -= afac_offset;
00133     --ipiv;
00134     c_dim1 = *ldc;
00135     c_offset = 1 + c_dim1;
00136     c__ -= c_offset;
00137     --rwork;
00138 
00139     /* Function Body */
00140     if (*n <= 0) {
00141         *resid = 0.f;
00142         return 0;
00143     }
00144 
00145 /*     Determine EPS and the norm of A. */
00146 
00147     eps = slamch_("Epsilon");
00148     anorm = clanhe_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00149 
00150 /*     Check the imaginary parts of the diagonal elements and return with */
00151 /*     an error code if any are nonzero. */
00152 
00153     i__1 = *n;
00154     for (j = 1; j <= i__1; ++j) {
00155         if (r_imag(&afac[j + j * afac_dim1]) != 0.f) {
00156             *resid = 1.f / eps;
00157             return 0;
00158         }
00159 /* L10: */
00160     }
00161 
00162 /*     Initialize C to the identity matrix. */
00163 
00164     claset_("Full", n, n, &c_b1, &c_b2, &c__[c_offset], ldc);
00165 
00166 /*     Call CLAVHE to form the product D * U' (or D * L' ). */
00167 
00168     clavhe_(uplo, "Conjugate", "Non-unit", n, n, &afac[afac_offset], ldafac, &
00169             ipiv[1], &c__[c_offset], ldc, &info);
00170 
00171 /*     Call CLAVHE again to multiply by U (or L ). */
00172 
00173     clavhe_(uplo, "No transpose", "Unit", n, n, &afac[afac_offset], ldafac, &
00174             ipiv[1], &c__[c_offset], ldc, &info);
00175 
00176 /*     Compute the difference  C - A . */
00177 
00178     if (lsame_(uplo, "U")) {
00179         i__1 = *n;
00180         for (j = 1; j <= i__1; ++j) {
00181             i__2 = j - 1;
00182             for (i__ = 1; i__ <= i__2; ++i__) {
00183                 i__3 = i__ + j * c_dim1;
00184                 i__4 = i__ + j * c_dim1;
00185                 i__5 = i__ + j * a_dim1;
00186                 q__1.r = c__[i__4].r - a[i__5].r, q__1.i = c__[i__4].i - a[
00187                         i__5].i;
00188                 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00189 /* L20: */
00190             }
00191             i__2 = j + j * c_dim1;
00192             i__3 = j + j * c_dim1;
00193             i__4 = j + j * a_dim1;
00194             r__1 = a[i__4].r;
00195             q__1.r = c__[i__3].r - r__1, q__1.i = c__[i__3].i;
00196             c__[i__2].r = q__1.r, c__[i__2].i = q__1.i;
00197 /* L30: */
00198         }
00199     } else {
00200         i__1 = *n;
00201         for (j = 1; j <= i__1; ++j) {
00202             i__2 = j + j * c_dim1;
00203             i__3 = j + j * c_dim1;
00204             i__4 = j + j * a_dim1;
00205             r__1 = a[i__4].r;
00206             q__1.r = c__[i__3].r - r__1, q__1.i = c__[i__3].i;
00207             c__[i__2].r = q__1.r, c__[i__2].i = q__1.i;
00208             i__2 = *n;
00209             for (i__ = j + 1; i__ <= i__2; ++i__) {
00210                 i__3 = i__ + j * c_dim1;
00211                 i__4 = i__ + j * c_dim1;
00212                 i__5 = i__ + j * a_dim1;
00213                 q__1.r = c__[i__4].r - a[i__5].r, q__1.i = c__[i__4].i - a[
00214                         i__5].i;
00215                 c__[i__3].r = q__1.r, c__[i__3].i = q__1.i;
00216 /* L40: */
00217             }
00218 /* L50: */
00219         }
00220     }
00221 
00222 /*     Compute norm( C - A ) / ( N * norm(A) * EPS ) */
00223 
00224     *resid = clanhe_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]);
00225 
00226     if (anorm <= 0.f) {
00227         if (*resid != 0.f) {
00228             *resid = 1.f / eps;
00229         }
00230     } else {
00231         *resid = *resid / (real) (*n) / anorm / eps;
00232     }
00233 
00234     return 0;
00235 
00236 /*     End of CHET01 */
00237 
00238 } /* chet01_ */


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