zget01.c
Go to the documentation of this file.
00001 /* zget01.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 = {1.,0.};
00019 static integer c__1 = 1;
00020 static integer c_n1 = -1;
00021 
00022 /* Subroutine */ int zget01_(integer *m, integer *n, doublecomplex *a, 
00023         integer *lda, doublecomplex *afac, integer *ldafac, integer *ipiv, 
00024         doublereal *rwork, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, afac_dim1, afac_offset, i__1, i__2, i__3, i__4, 
00028             i__5;
00029     doublecomplex z__1, z__2;
00030 
00031     /* Local variables */
00032     integer i__, j, k;
00033     doublecomplex t;
00034     doublereal eps, anorm;
00035     extern /* Subroutine */ int zscal_(integer *, doublecomplex *, 
00036             doublecomplex *, integer *), zgemv_(char *, integer *, integer *, 
00037             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00038             integer *, doublecomplex *, doublecomplex *, integer *);
00039     extern /* Double Complex */ VOID zdotu_(doublecomplex *, integer *, 
00040             doublecomplex *, integer *, doublecomplex *, integer *);
00041     extern /* Subroutine */ int ztrmv_(char *, char *, char *, integer *, 
00042             doublecomplex *, integer *, doublecomplex *, integer *);
00043     extern doublereal dlamch_(char *), zlange_(char *, integer *, 
00044             integer *, doublecomplex *, integer *, doublereal *);
00045     extern /* Subroutine */ int zlaswp_(integer *, doublecomplex *, integer *, 
00046              integer *, integer *, integer *, integer *);
00047 
00048 
00049 /*  -- LAPACK test routine (version 3.1) -- */
00050 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00051 /*     November 2006 */
00052 
00053 /*     .. Scalar Arguments .. */
00054 /*     .. */
00055 /*     .. Array Arguments .. */
00056 /*     .. */
00057 
00058 /*  Purpose */
00059 /*  ======= */
00060 
00061 /*  ZGET01 reconstructs a matrix A from its L*U factorization and */
00062 /*  computes the residual */
00063 /*     norm(L*U - A) / ( N * norm(A) * EPS ), */
00064 /*  where EPS is the machine epsilon. */
00065 
00066 /*  Arguments */
00067 /*  ========== */
00068 
00069 /*  M       (input) INTEGER */
00070 /*          The number of rows of the matrix A.  M >= 0. */
00071 
00072 /*  N       (input) INTEGER */
00073 /*          The number of columns of the matrix A.  N >= 0. */
00074 
00075 /*  A       (input) COMPLEX*16 array, dimension (LDA,N) */
00076 /*          The original M x N matrix A. */
00077 
00078 /*  LDA     (input) INTEGER */
00079 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00080 
00081 /*  AFAC    (input/output) COMPLEX*16 array, dimension (LDAFAC,N) */
00082 /*          The factored form of the matrix A.  AFAC contains the factors */
00083 /*          L and U from the L*U factorization as computed by ZGETRF. */
00084 /*          Overwritten with the reconstructed matrix, and then with the */
00085 /*          difference L*U - A. */
00086 
00087 /*  LDAFAC  (input) INTEGER */
00088 /*          The leading dimension of the array AFAC.  LDAFAC >= max(1,M). */
00089 
00090 /*  IPIV    (input) INTEGER array, dimension (N) */
00091 /*          The pivot indices from ZGETRF. */
00092 
00093 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (M) */
00094 
00095 /*  RESID   (output) DOUBLE PRECISION */
00096 /*          norm(L*U - A) / ( N * norm(A) * EPS ) */
00097 
00098 /*  ===================================================================== */
00099 
00100 /*     .. Parameters .. */
00101 /*     .. */
00102 /*     .. Local Scalars .. */
00103 /*     .. */
00104 /*     .. External Functions .. */
00105 /*     .. */
00106 /*     .. External Subroutines .. */
00107 /*     .. */
00108 /*     .. Intrinsic Functions .. */
00109 /*     .. */
00110 /*     .. Executable Statements .. */
00111 
00112 /*     Quick exit if M = 0 or N = 0. */
00113 
00114     /* Parameter adjustments */
00115     a_dim1 = *lda;
00116     a_offset = 1 + a_dim1;
00117     a -= a_offset;
00118     afac_dim1 = *ldafac;
00119     afac_offset = 1 + afac_dim1;
00120     afac -= afac_offset;
00121     --ipiv;
00122     --rwork;
00123 
00124     /* Function Body */
00125     if (*m <= 0 || *n <= 0) {
00126         *resid = 0.;
00127         return 0;
00128     }
00129 
00130 /*     Determine EPS and the norm of A. */
00131 
00132     eps = dlamch_("Epsilon");
00133     anorm = zlange_("1", m, n, &a[a_offset], lda, &rwork[1]);
00134 
00135 /*     Compute the product L*U and overwrite AFAC with the result. */
00136 /*     A column at a time of the product is obtained, starting with */
00137 /*     column N. */
00138 
00139     for (k = *n; k >= 1; --k) {
00140         if (k > *m) {
00141             ztrmv_("Lower", "No transpose", "Unit", m, &afac[afac_offset], 
00142                     ldafac, &afac[k * afac_dim1 + 1], &c__1);
00143         } else {
00144 
00145 /*           Compute elements (K+1:M,K) */
00146 
00147             i__1 = k + k * afac_dim1;
00148             t.r = afac[i__1].r, t.i = afac[i__1].i;
00149             if (k + 1 <= *m) {
00150                 i__1 = *m - k;
00151                 zscal_(&i__1, &t, &afac[k + 1 + k * afac_dim1], &c__1);
00152                 i__1 = *m - k;
00153                 i__2 = k - 1;
00154                 zgemv_("No transpose", &i__1, &i__2, &c_b1, &afac[k + 1 + 
00155                         afac_dim1], ldafac, &afac[k * afac_dim1 + 1], &c__1, &
00156                         c_b1, &afac[k + 1 + k * afac_dim1], &c__1)
00157                         ;
00158             }
00159 
00160 /*           Compute the (K,K) element */
00161 
00162             i__1 = k + k * afac_dim1;
00163             i__2 = k - 1;
00164             zdotu_(&z__2, &i__2, &afac[k + afac_dim1], ldafac, &afac[k * 
00165                     afac_dim1 + 1], &c__1);
00166             z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00167             afac[i__1].r = z__1.r, afac[i__1].i = z__1.i;
00168 
00169 /*           Compute elements (1:K-1,K) */
00170 
00171             i__1 = k - 1;
00172             ztrmv_("Lower", "No transpose", "Unit", &i__1, &afac[afac_offset], 
00173                      ldafac, &afac[k * afac_dim1 + 1], &c__1);
00174         }
00175 /* L10: */
00176     }
00177     i__1 = min(*m,*n);
00178     zlaswp_(n, &afac[afac_offset], ldafac, &c__1, &i__1, &ipiv[1], &c_n1);
00179 
00180 /*     Compute the difference  L*U - A  and store in AFAC. */
00181 
00182     i__1 = *n;
00183     for (j = 1; j <= i__1; ++j) {
00184         i__2 = *m;
00185         for (i__ = 1; i__ <= i__2; ++i__) {
00186             i__3 = i__ + j * afac_dim1;
00187             i__4 = i__ + j * afac_dim1;
00188             i__5 = i__ + j * a_dim1;
00189             z__1.r = afac[i__4].r - a[i__5].r, z__1.i = afac[i__4].i - a[i__5]
00190                     .i;
00191             afac[i__3].r = z__1.r, afac[i__3].i = z__1.i;
00192 /* L20: */
00193         }
00194 /* L30: */
00195     }
00196 
00197 /*     Compute norm( L*U - A ) / ( N * norm(A) * EPS ) */
00198 
00199     *resid = zlange_("1", m, n, &afac[afac_offset], ldafac, &rwork[1]);
00200 
00201     if (anorm <= 0.) {
00202         if (*resid != 0.) {
00203             *resid = 1. / eps;
00204         }
00205     } else {
00206         *resid = *resid / (doublereal) (*n) / anorm / eps;
00207     }
00208 
00209     return 0;
00210 
00211 /*     End of ZGET01 */
00212 
00213 } /* zget01_ */


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