dsyt01.c
Go to the documentation of this file.
00001 /* dsyt01.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 doublereal c_b5 = 0.;
00019 static doublereal c_b6 = 1.;
00020 
00021 /* Subroutine */ int dsyt01_(char *uplo, integer *n, doublereal *a, integer *
00022         lda, doublereal *afac, integer *ldafac, integer *ipiv, doublereal *
00023         c__, integer *ldc, doublereal *rwork, doublereal *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;
00028 
00029     /* Local variables */
00030     integer i__, j;
00031     doublereal eps;
00032     integer info;
00033     extern logical lsame_(char *, char *);
00034     doublereal anorm;
00035     extern doublereal dlamch_(char *);
00036     extern /* Subroutine */ int dlaset_(char *, integer *, integer *, 
00037             doublereal *, doublereal *, doublereal *, integer *);
00038     extern doublereal dlansy_(char *, char *, integer *, doublereal *, 
00039             integer *, doublereal *);
00040     extern /* Subroutine */ int dlavsy_(char *, char *, char *, integer *, 
00041             integer *, doublereal *, integer *, integer *, doublereal *, 
00042             integer *, integer *);
00043 
00044 
00045 /*  -- LAPACK test routine (version 3.1) -- */
00046 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00047 /*     November 2006 */
00048 
00049 /*     .. Scalar Arguments .. */
00050 /*     .. */
00051 /*     .. Array Arguments .. */
00052 /*     .. */
00053 
00054 /*  Purpose */
00055 /*  ======= */
00056 
00057 /*  DSYT01 reconstructs a symmetric indefinite matrix A from its */
00058 /*  block L*D*L' or U*D*U' factorization and computes the residual */
00059 /*     norm( C - A ) / ( N * norm(A) * EPS ), */
00060 /*  where C is the reconstructed matrix and EPS is the machine epsilon. */
00061 
00062 /*  Arguments */
00063 /*  ========== */
00064 
00065 /*  UPLO    (input) CHARACTER*1 */
00066 /*          Specifies whether the upper or lower triangular part of the */
00067 /*          symmetric matrix A is stored: */
00068 /*          = 'U':  Upper triangular */
00069 /*          = 'L':  Lower triangular */
00070 
00071 /*  N       (input) INTEGER */
00072 /*          The number of rows and columns of the matrix A.  N >= 0. */
00073 
00074 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00075 /*          The original symmetric matrix A. */
00076 
00077 /*  LDA     (input) INTEGER */
00078 /*          The leading dimension of the array A.  LDA >= max(1,N) */
00079 
00080 /*  AFAC    (input) DOUBLE PRECISION array, dimension (LDAFAC,N) */
00081 /*          The factored form of the matrix A.  AFAC contains the block */
00082 /*          diagonal matrix D and the multipliers used to obtain the */
00083 /*          factor L or U from the block L*D*L' or U*D*U' factorization */
00084 /*          as computed by DSYTRF. */
00085 
00086 /*  LDAFAC  (input) INTEGER */
00087 /*          The leading dimension of the array AFAC.  LDAFAC >= max(1,N). */
00088 
00089 /*  IPIV    (input) INTEGER array, dimension (N) */
00090 /*          The pivot indices from DSYTRF. */
00091 
00092 /*  C       (workspace) DOUBLE PRECISION array, dimension (LDC,N) */
00093 
00094 /*  LDC     (integer) INTEGER */
00095 /*          The leading dimension of the array C.  LDC >= max(1,N). */
00096 
00097 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00098 
00099 /*  RESID   (output) DOUBLE PRECISION */
00100 /*          If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS ) */
00101 /*          If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS ) */
00102 
00103 /*  ===================================================================== */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Functions .. */
00110 /*     .. */
00111 /*     .. External Subroutines .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117 /*     Quick exit if N = 0. */
00118 
00119     /* Parameter adjustments */
00120     a_dim1 = *lda;
00121     a_offset = 1 + a_dim1;
00122     a -= a_offset;
00123     afac_dim1 = *ldafac;
00124     afac_offset = 1 + afac_dim1;
00125     afac -= afac_offset;
00126     --ipiv;
00127     c_dim1 = *ldc;
00128     c_offset = 1 + c_dim1;
00129     c__ -= c_offset;
00130     --rwork;
00131 
00132     /* Function Body */
00133     if (*n <= 0) {
00134         *resid = 0.;
00135         return 0;
00136     }
00137 
00138 /*     Determine EPS and the norm of A. */
00139 
00140     eps = dlamch_("Epsilon");
00141     anorm = dlansy_("1", uplo, n, &a[a_offset], lda, &rwork[1]);
00142 
00143 /*     Initialize C to the identity matrix. */
00144 
00145     dlaset_("Full", n, n, &c_b5, &c_b6, &c__[c_offset], ldc);
00146 
00147 /*     Call DLAVSY to form the product D * U' (or D * L' ). */
00148 
00149     dlavsy_(uplo, "Transpose", "Non-unit", n, n, &afac[afac_offset], ldafac, &
00150             ipiv[1], &c__[c_offset], ldc, &info);
00151 
00152 /*     Call DLAVSY again to multiply by U (or L ). */
00153 
00154     dlavsy_(uplo, "No transpose", "Unit", n, n, &afac[afac_offset], ldafac, &
00155             ipiv[1], &c__[c_offset], ldc, &info);
00156 
00157 /*     Compute the difference  C - A . */
00158 
00159     if (lsame_(uplo, "U")) {
00160         i__1 = *n;
00161         for (j = 1; j <= i__1; ++j) {
00162             i__2 = j;
00163             for (i__ = 1; i__ <= i__2; ++i__) {
00164                 c__[i__ + j * c_dim1] -= a[i__ + j * a_dim1];
00165 /* L10: */
00166             }
00167 /* L20: */
00168         }
00169     } else {
00170         i__1 = *n;
00171         for (j = 1; j <= i__1; ++j) {
00172             i__2 = *n;
00173             for (i__ = j; i__ <= i__2; ++i__) {
00174                 c__[i__ + j * c_dim1] -= a[i__ + j * a_dim1];
00175 /* L30: */
00176             }
00177 /* L40: */
00178         }
00179     }
00180 
00181 /*     Compute norm( C - A ) / ( N * norm(A) * EPS ) */
00182 
00183     *resid = dlansy_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]);
00184 
00185     if (anorm <= 0.) {
00186         if (*resid != 0.) {
00187             *resid = 1. / eps;
00188         }
00189     } else {
00190         *resid = *resid / (doublereal) (*n) / anorm / eps;
00191     }
00192 
00193     return 0;
00194 
00195 /*     End of DSYT01 */
00196 
00197 } /* dsyt01_ */


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