zspt01.c
Go to the documentation of this file.
00001 /* zspt01.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 zspt01_(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     doublecomplex z__1;
00028 
00029     /* Local variables */
00030     integer i__, j, jc;
00031     doublereal eps;
00032     integer info;
00033     extern logical lsame_(char *, char *);
00034     doublereal anorm;
00035     extern doublereal dlamch_(char *);
00036     extern /* Subroutine */ int zlaset_(char *, integer *, integer *, 
00037             doublecomplex *, doublecomplex *, doublecomplex *, integer *);
00038     extern doublereal zlansp_(char *, char *, integer *, doublecomplex *, 
00039             doublereal *);
00040     extern /* Subroutine */ int zlavsp_(char *, char *, char *, integer *, 
00041             integer *, doublecomplex *, integer *, doublecomplex *, integer *, 
00042              integer *);
00043     extern doublereal zlansy_(char *, char *, integer *, doublecomplex *, 
00044             integer *, doublereal *);
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 /*  ZSPT01 reconstructs a symmetric indefinite packed matrix A from its */
00060 /*  diagonal pivoting factorization A = U*D*U' or A = L*D*L' and computes */
00061 /*  the residual */
00062 /*     norm( C - A ) / ( N * norm(A) * EPS ), */
00063 /*  where C is the reconstructed matrix and 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 order of the matrix A.  N >= 0. */
00076 
00077 /*  A       (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00078 /*          The original symmetric matrix A, stored as a packed */
00079 /*          triangular matrix. */
00080 
00081 /*  AFAC    (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00082 /*          The factored form of the matrix A, stored as a packed */
00083 /*          triangular matrix.  AFAC contains the block diagonal matrix D */
00084 /*          and the multipliers used to obtain the factor L or U from the */
00085 /*          L*D*L' or U*D*U' factorization as computed by ZSPTRF. */
00086 
00087 /*  IPIV    (input) INTEGER array, dimension (N) */
00088 /*          The pivot indices from ZSPTRF. */
00089 
00090 /*  C       (workspace) COMPLEX*16 array, dimension (LDC,N) */
00091 
00092 /*  LDC     (integer) INTEGER */
00093 /*          The leading dimension of the array C.  LDC >= max(1,N). */
00094 
00095 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00096 
00097 /*  RESID   (output) DOUBLE PRECISION */
00098 /*          If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS ) */
00099 /*          If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS ) */
00100 
00101 /*  ===================================================================== */
00102 
00103 /*     .. Parameters .. */
00104 /*     .. */
00105 /*     .. Local Scalars .. */
00106 /*     .. */
00107 /*     .. External Functions .. */
00108 /*     .. */
00109 /*     .. External Subroutines .. */
00110 /*     .. */
00111 /*     .. Intrinsic Functions .. */
00112 /*     .. */
00113 /*     .. Executable Statements .. */
00114 
00115 /*     Quick exit if N = 0. */
00116 
00117     /* Parameter adjustments */
00118     --a;
00119     --afac;
00120     --ipiv;
00121     c_dim1 = *ldc;
00122     c_offset = 1 + c_dim1;
00123     c__ -= c_offset;
00124     --rwork;
00125 
00126     /* Function Body */
00127     if (*n <= 0) {
00128         *resid = 0.;
00129         return 0;
00130     }
00131 
00132 /*     Determine EPS and the norm of A. */
00133 
00134     eps = dlamch_("Epsilon");
00135     anorm = zlansp_("1", uplo, n, &a[1], &rwork[1]);
00136 
00137 /*     Initialize C to the identity matrix. */
00138 
00139     zlaset_("Full", n, n, &c_b1, &c_b2, &c__[c_offset], ldc);
00140 
00141 /*     Call ZLAVSP to form the product D * U' (or D * L' ). */
00142 
00143     zlavsp_(uplo, "Transpose", "Non-unit", n, n, &afac[1], &ipiv[1], &c__[
00144             c_offset], ldc, &info);
00145 
00146 /*     Call ZLAVSP again to multiply by U ( or L ). */
00147 
00148     zlavsp_(uplo, "No transpose", "Unit", n, n, &afac[1], &ipiv[1], &c__[
00149             c_offset], ldc, &info);
00150 
00151 /*     Compute the difference  C - A . */
00152 
00153     if (lsame_(uplo, "U")) {
00154         jc = 0;
00155         i__1 = *n;
00156         for (j = 1; j <= i__1; ++j) {
00157             i__2 = j;
00158             for (i__ = 1; i__ <= i__2; ++i__) {
00159                 i__3 = i__ + j * c_dim1;
00160                 i__4 = i__ + j * c_dim1;
00161                 i__5 = jc + i__;
00162                 z__1.r = c__[i__4].r - a[i__5].r, z__1.i = c__[i__4].i - a[
00163                         i__5].i;
00164                 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00165 /* L10: */
00166             }
00167             jc += j;
00168 /* L20: */
00169         }
00170     } else {
00171         jc = 1;
00172         i__1 = *n;
00173         for (j = 1; j <= i__1; ++j) {
00174             i__2 = *n;
00175             for (i__ = j; i__ <= i__2; ++i__) {
00176                 i__3 = i__ + j * c_dim1;
00177                 i__4 = i__ + j * c_dim1;
00178                 i__5 = jc + i__ - j;
00179                 z__1.r = c__[i__4].r - a[i__5].r, z__1.i = c__[i__4].i - a[
00180                         i__5].i;
00181                 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00182 /* L30: */
00183             }
00184             jc = jc + *n - j + 1;
00185 /* L40: */
00186         }
00187     }
00188 
00189 /*     Compute norm( C - A ) / ( N * norm(A) * EPS ) */
00190 
00191     *resid = zlansy_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]);
00192 
00193     if (anorm <= 0.) {
00194         if (*resid != 0.) {
00195             *resid = 1. / eps;
00196         }
00197     } else {
00198         *resid = *resid / (doublereal) (*n) / anorm / eps;
00199     }
00200 
00201     return 0;
00202 
00203 /*     End of ZSPT01 */
00204 
00205 } /* zspt01_ */


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