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


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