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


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