dgbt01.c
Go to the documentation of this file.
00001 /* dgbt01.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_b12 = -1.;
00020 
00021 /* Subroutine */ int dgbt01_(integer *m, integer *n, integer *kl, integer *ku, 
00022          doublereal *a, integer *lda, doublereal *afac, integer *ldafac, 
00023         integer *ipiv, doublereal *work, doublereal *resid)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, afac_dim1, afac_offset, i__1, i__2, i__3, i__4;
00027     doublereal d__1, d__2;
00028 
00029     /* Local variables */
00030     integer i__, j;
00031     doublereal t;
00032     integer i1, i2, kd, il, jl, ip, ju, iw, jua;
00033     doublereal eps;
00034     integer lenj;
00035     extern doublereal dasum_(integer *, doublereal *, integer *);
00036     doublereal anorm;
00037     extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 
00038             doublereal *, integer *), daxpy_(integer *, doublereal *, 
00039             doublereal *, integer *, doublereal *, integer *);
00040     extern doublereal dlamch_(char *);
00041 
00042 
00043 /*  -- LAPACK test routine (version 3.1) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  DGBT01 reconstructs a band matrix  A  from its L*U factorization and */
00056 /*  computes the residual: */
00057 /*     norm(L*U - A) / ( N * norm(A) * EPS ), */
00058 /*  where EPS is the machine epsilon. */
00059 
00060 /*  The expression L*U - A is computed one column at a time, so A and */
00061 /*  AFAC are not modified. */
00062 
00063 /*  Arguments */
00064 /*  ========= */
00065 
00066 /*  M       (input) INTEGER */
00067 /*          The number of rows of the matrix A.  M >= 0. */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The number of columns of the matrix A.  N >= 0. */
00071 
00072 /*  KL      (input) INTEGER */
00073 /*          The number of subdiagonals within the band of A.  KL >= 0. */
00074 
00075 /*  KU      (input) INTEGER */
00076 /*          The number of superdiagonals within the band of A.  KU >= 0. */
00077 
00078 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
00079 /*          The original matrix A in band storage, stored in rows 1 to */
00080 /*          KL+KU+1. */
00081 
00082 /*  LDA     (input) INTEGER. */
00083 /*          The leading dimension of the array A.  LDA >= max(1,KL+KU+1). */
00084 
00085 /*  AFAC    (input) DOUBLE PRECISION array, dimension (LDAFAC,N) */
00086 /*          The factored form of the matrix A.  AFAC contains the banded */
00087 /*          factors L and U from the L*U factorization, as computed by */
00088 /*          DGBTRF.  U is stored as an upper triangular band matrix with */
00089 /*          KL+KU superdiagonals in rows 1 to KL+KU+1, and the */
00090 /*          multipliers used during the factorization are stored in rows */
00091 /*          KL+KU+2 to 2*KL+KU+1.  See DGBTRF for further details. */
00092 
00093 /*  LDAFAC  (input) INTEGER */
00094 /*          The leading dimension of the array AFAC. */
00095 /*          LDAFAC >= max(1,2*KL*KU+1). */
00096 
00097 /*  IPIV    (input) INTEGER array, dimension (min(M,N)) */
00098 /*          The pivot indices from DGBTRF. */
00099 
00100 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (2*KL+KU+1) */
00101 
00102 /*  RESID   (output) DOUBLE PRECISION */
00103 /*          norm(L*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 M = 0 or 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     --work;
00130 
00131     /* Function Body */
00132     *resid = 0.;
00133     if (*m <= 0 || *n <= 0) {
00134         return 0;
00135     }
00136 
00137 /*     Determine EPS and the norm of A. */
00138 
00139     eps = dlamch_("Epsilon");
00140     kd = *ku + 1;
00141     anorm = 0.;
00142     i__1 = *n;
00143     for (j = 1; j <= i__1; ++j) {
00144 /* Computing MAX */
00145         i__2 = kd + 1 - j;
00146         i1 = max(i__2,1);
00147 /* Computing MIN */
00148         i__2 = kd + *m - j, i__3 = *kl + kd;
00149         i2 = min(i__2,i__3);
00150         if (i2 >= i1) {
00151 /* Computing MAX */
00152             i__2 = i2 - i1 + 1;
00153             d__1 = anorm, d__2 = dasum_(&i__2, &a[i1 + j * a_dim1], &c__1);
00154             anorm = max(d__1,d__2);
00155         }
00156 /* L10: */
00157     }
00158 
00159 /*     Compute one column at a time of L*U - A. */
00160 
00161     kd = *kl + *ku + 1;
00162     i__1 = *n;
00163     for (j = 1; j <= i__1; ++j) {
00164 
00165 /*        Copy the J-th column of U to WORK. */
00166 
00167 /* Computing MIN */
00168         i__2 = *kl + *ku, i__3 = j - 1;
00169         ju = min(i__2,i__3);
00170 /* Computing MIN */
00171         i__2 = *kl, i__3 = *m - j;
00172         jl = min(i__2,i__3);
00173         lenj = min(*m,j) - j + ju + 1;
00174         if (lenj > 0) {
00175             dcopy_(&lenj, &afac[kd - ju + j * afac_dim1], &c__1, &work[1], &
00176                     c__1);
00177             i__2 = ju + jl + 1;
00178             for (i__ = lenj + 1; i__ <= i__2; ++i__) {
00179                 work[i__] = 0.;
00180 /* L20: */
00181             }
00182 
00183 /*           Multiply by the unit lower triangular matrix L.  Note that L */
00184 /*           is stored as a product of transformations and permutations. */
00185 
00186 /* Computing MIN */
00187             i__2 = *m - 1;
00188             i__3 = j - ju;
00189             for (i__ = min(i__2,j); i__ >= i__3; --i__) {
00190 /* Computing MIN */
00191                 i__2 = *kl, i__4 = *m - i__;
00192                 il = min(i__2,i__4);
00193                 if (il > 0) {
00194                     iw = i__ - j + ju + 1;
00195                     t = work[iw];
00196                     daxpy_(&il, &t, &afac[kd + 1 + i__ * afac_dim1], &c__1, &
00197                             work[iw + 1], &c__1);
00198                     ip = ipiv[i__];
00199                     if (i__ != ip) {
00200                         ip = ip - j + ju + 1;
00201                         work[iw] = work[ip];
00202                         work[ip] = t;
00203                     }
00204                 }
00205 /* L30: */
00206             }
00207 
00208 /*           Subtract the corresponding column of A. */
00209 
00210             jua = min(ju,*ku);
00211             if (jua + jl + 1 > 0) {
00212                 i__3 = jua + jl + 1;
00213                 daxpy_(&i__3, &c_b12, &a[*ku + 1 - jua + j * a_dim1], &c__1, &
00214                         work[ju + 1 - jua], &c__1);
00215             }
00216 
00217 /*           Compute the 1-norm of the column. */
00218 
00219 /* Computing MAX */
00220             i__3 = ju + jl + 1;
00221             d__1 = *resid, d__2 = dasum_(&i__3, &work[1], &c__1);
00222             *resid = max(d__1,d__2);
00223         }
00224 /* L40: */
00225     }
00226 
00227 /*     Compute norm( L*U - A ) / ( N * norm(A) * EPS ) */
00228 
00229     if (anorm <= 0.) {
00230         if (*resid != 0.) {
00231             *resid = 1. / eps;
00232         }
00233     } else {
00234         *resid = *resid / (doublereal) (*n) / anorm / eps;
00235     }
00236 
00237     return 0;
00238 
00239 /*     End of DGBT01 */
00240 
00241 } /* dgbt01_ */


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