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


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