zgbt01.c
Go to the documentation of this file.
00001 /* zgbt01.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 doublecomplex c_b12 = {-1.,-0.};
00020 
00021 /* Subroutine */ int zgbt01_(integer *m, integer *n, integer *kl, integer *ku, 
00022          doublecomplex *a, integer *lda, doublecomplex *afac, integer *ldafac, 
00023          integer *ipiv, doublecomplex *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     doublecomplex t;
00032     integer i1, i2, kd, il, jl, ip, ju, iw, jua;
00033     doublereal eps;
00034     integer lenj;
00035     doublereal anorm;
00036     extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 
00037             doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *, 
00038             doublecomplex *, integer *, doublecomplex *, integer *);
00039     extern doublereal dlamch_(char *), dzasum_(integer *, 
00040             doublecomplex *, integer *);
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 /*  ZGBT01 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) COMPLEX*16 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) COMPLEX*16 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 /*          ZGBTRF.  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 ZGBTRF 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 ZGBTRF. */
00099 
00100 /*  WORK    (workspace) COMPLEX*16 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 = dzasum_(&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             zcopy_(&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                 i__3 = i__;
00180                 work[i__3].r = 0., work[i__3].i = 0.;
00181 /* L20: */
00182             }
00183 
00184 /*           Multiply by the unit lower triangular matrix L.  Note that L */
00185 /*           is stored as a product of transformations and permutations. */
00186 
00187 /* Computing MIN */
00188             i__2 = *m - 1;
00189             i__3 = j - ju;
00190             for (i__ = min(i__2,j); i__ >= i__3; --i__) {
00191 /* Computing MIN */
00192                 i__2 = *kl, i__4 = *m - i__;
00193                 il = min(i__2,i__4);
00194                 if (il > 0) {
00195                     iw = i__ - j + ju + 1;
00196                     i__2 = iw;
00197                     t.r = work[i__2].r, t.i = work[i__2].i;
00198                     zaxpy_(&il, &t, &afac[kd + 1 + i__ * afac_dim1], &c__1, &
00199                             work[iw + 1], &c__1);
00200                     ip = ipiv[i__];
00201                     if (i__ != ip) {
00202                         ip = ip - j + ju + 1;
00203                         i__2 = iw;
00204                         i__4 = ip;
00205                         work[i__2].r = work[i__4].r, work[i__2].i = work[i__4]
00206                                 .i;
00207                         i__2 = ip;
00208                         work[i__2].r = t.r, work[i__2].i = t.i;
00209                     }
00210                 }
00211 /* L30: */
00212             }
00213 
00214 /*           Subtract the corresponding column of A. */
00215 
00216             jua = min(ju,*ku);
00217             if (jua + jl + 1 > 0) {
00218                 i__3 = jua + jl + 1;
00219                 zaxpy_(&i__3, &c_b12, &a[*ku + 1 - jua + j * a_dim1], &c__1, &
00220                         work[ju + 1 - jua], &c__1);
00221             }
00222 
00223 /*           Compute the 1-norm of the column. */
00224 
00225 /* Computing MAX */
00226             i__3 = ju + jl + 1;
00227             d__1 = *resid, d__2 = dzasum_(&i__3, &work[1], &c__1);
00228             *resid = max(d__1,d__2);
00229         }
00230 /* L40: */
00231     }
00232 
00233 /*     Compute norm( L*U - A ) / ( N * norm(A) * EPS ) */
00234 
00235     if (anorm <= 0.) {
00236         if (*resid != 0.) {
00237             *resid = 1. / eps;
00238         }
00239     } else {
00240         *resid = *resid / (doublereal) (*n) / anorm / eps;
00241     }
00242 
00243     return 0;
00244 
00245 /*     End of ZGBT01 */
00246 
00247 } /* zgbt01_ */


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