dpbt01.c
Go to the documentation of this file.
00001 /* dpbt01.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_b14 = 1.;
00020 
00021 /* Subroutine */ int dpbt01_(char *uplo, integer *n, integer *kd, doublereal *
00022         a, integer *lda, doublereal *afac, integer *ldafac, doublereal *rwork, 
00023          doublereal *resid)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, afac_dim1, afac_offset, i__1, i__2, i__3;
00027 
00028     /* Local variables */
00029     integer i__, j, k;
00030     doublereal t;
00031     integer kc, ml, mu;
00032     doublereal eps;
00033     integer klen;
00034     extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, 
00035             integer *);
00036     extern /* Subroutine */ int dsyr_(char *, integer *, doublereal *, 
00037             doublereal *, integer *, doublereal *, integer *), dscal_(
00038             integer *, doublereal *, doublereal *, integer *);
00039     extern logical lsame_(char *, char *);
00040     doublereal anorm;
00041     extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *, 
00042             doublereal *, integer *, doublereal *, integer *);
00043     extern doublereal dlamch_(char *), dlansb_(char *, char *, 
00044             integer *, integer *, doublereal *, integer *, doublereal *);
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 /*  DPBT01 reconstructs a symmetric positive definite band matrix A from */
00060 /*  its L*L' or U'*U factorization and computes the residual */
00061 /*     norm( L*L' - A ) / ( N * norm(A) * EPS ) or */
00062 /*     norm( U'*U - A ) / ( N * norm(A) * EPS ), */
00063 /*  where EPS is the machine epsilon, L' is the conjugate transpose of */
00064 /*  L, and U' is the conjugate transpose of U. */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  UPLO    (input) CHARACTER*1 */
00070 /*          Specifies whether the upper or lower triangular part of the */
00071 /*          symmetric matrix A is stored: */
00072 /*          = 'U':  Upper triangular */
00073 /*          = 'L':  Lower triangular */
00074 
00075 /*  N       (input) INTEGER */
00076 /*          The number of rows and columns of the matrix A.  N >= 0. */
00077 
00078 /*  KD      (input) INTEGER */
00079 /*          The number of super-diagonals of the matrix A if UPLO = 'U', */
00080 /*          or the number of sub-diagonals if UPLO = 'L'.  KD >= 0. */
00081 
00082 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00083 /*          The original symmetric band matrix A.  If UPLO = 'U', the */
00084 /*          upper triangular part of A is stored as a band matrix; if */
00085 /*          UPLO = 'L', the lower triangular part of A is stored.  The */
00086 /*          columns of the appropriate triangle are stored in the columns */
00087 /*          of A and the diagonals of the triangle are stored in the rows */
00088 /*          of A.  See DPBTRF for further details. */
00089 
00090 /*  LDA     (input) INTEGER. */
00091 /*          The leading dimension of the array A.  LDA >= max(1,KD+1). */
00092 
00093 /*  AFAC    (input) DOUBLE PRECISION array, dimension (LDAFAC,N) */
00094 /*          The factored form of the matrix A.  AFAC contains the factor */
00095 /*          L or U from the L*L' or U'*U factorization in band storage */
00096 /*          format, as computed by DPBTRF. */
00097 
00098 /*  LDAFAC  (input) INTEGER */
00099 /*          The leading dimension of the array AFAC. */
00100 /*          LDAFAC >= max(1,KD+1). */
00101 
00102 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00103 
00104 /*  RESID   (output) DOUBLE PRECISION */
00105 /*          If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS ) */
00106 /*          If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS ) */
00107 
00108 /*  ===================================================================== */
00109 
00110 
00111 /*     .. Parameters .. */
00112 /*     .. */
00113 /*     .. Local Scalars .. */
00114 /*     .. */
00115 /*     .. External Functions .. */
00116 /*     .. */
00117 /*     .. External Subroutines .. */
00118 /*     .. */
00119 /*     .. Intrinsic Functions .. */
00120 /*     .. */
00121 /*     .. Executable Statements .. */
00122 
00123 /*     Quick exit if N = 0. */
00124 
00125     /* Parameter adjustments */
00126     a_dim1 = *lda;
00127     a_offset = 1 + a_dim1;
00128     a -= a_offset;
00129     afac_dim1 = *ldafac;
00130     afac_offset = 1 + afac_dim1;
00131     afac -= afac_offset;
00132     --rwork;
00133 
00134     /* Function Body */
00135     if (*n <= 0) {
00136         *resid = 0.;
00137         return 0;
00138     }
00139 
00140 /*     Exit with RESID = 1/EPS if ANORM = 0. */
00141 
00142     eps = dlamch_("Epsilon");
00143     anorm = dlansb_("1", uplo, n, kd, &a[a_offset], lda, &rwork[1]);
00144     if (anorm <= 0.) {
00145         *resid = 1. / eps;
00146         return 0;
00147     }
00148 
00149 /*     Compute the product U'*U, overwriting U. */
00150 
00151     if (lsame_(uplo, "U")) {
00152         for (k = *n; k >= 1; --k) {
00153 /* Computing MAX */
00154             i__1 = 1, i__2 = *kd + 2 - k;
00155             kc = max(i__1,i__2);
00156             klen = *kd + 1 - kc;
00157 
00158 /*           Compute the (K,K) element of the result. */
00159 
00160             i__1 = klen + 1;
00161             t = ddot_(&i__1, &afac[kc + k * afac_dim1], &c__1, &afac[kc + k * 
00162                     afac_dim1], &c__1);
00163             afac[*kd + 1 + k * afac_dim1] = t;
00164 
00165 /*           Compute the rest of column K. */
00166 
00167             if (klen > 0) {
00168                 i__1 = *ldafac - 1;
00169                 dtrmv_("Upper", "Transpose", "Non-unit", &klen, &afac[*kd + 1 
00170                         + (k - klen) * afac_dim1], &i__1, &afac[kc + k * 
00171                         afac_dim1], &c__1);
00172             }
00173 
00174 /* L10: */
00175         }
00176 
00177 /*     UPLO = 'L':  Compute the product L*L', overwriting L. */
00178 
00179     } else {
00180         for (k = *n; k >= 1; --k) {
00181 /* Computing MIN */
00182             i__1 = *kd, i__2 = *n - k;
00183             klen = min(i__1,i__2);
00184 
00185 /*           Add a multiple of column K of the factor L to each of */
00186 /*           columns K+1 through N. */
00187 
00188             if (klen > 0) {
00189                 i__1 = *ldafac - 1;
00190                 dsyr_("Lower", &klen, &c_b14, &afac[k * afac_dim1 + 2], &c__1, 
00191                          &afac[(k + 1) * afac_dim1 + 1], &i__1);
00192             }
00193 
00194 /*           Scale column K by the diagonal element. */
00195 
00196             t = afac[k * afac_dim1 + 1];
00197             i__1 = klen + 1;
00198             dscal_(&i__1, &t, &afac[k * afac_dim1 + 1], &c__1);
00199 
00200 /* L20: */
00201         }
00202     }
00203 
00204 /*     Compute the difference  L*L' - A  or  U'*U - A. */
00205 
00206     if (lsame_(uplo, "U")) {
00207         i__1 = *n;
00208         for (j = 1; j <= i__1; ++j) {
00209 /* Computing MAX */
00210             i__2 = 1, i__3 = *kd + 2 - j;
00211             mu = max(i__2,i__3);
00212             i__2 = *kd + 1;
00213             for (i__ = mu; i__ <= i__2; ++i__) {
00214                 afac[i__ + j * afac_dim1] -= a[i__ + j * a_dim1];
00215 /* L30: */
00216             }
00217 /* L40: */
00218         }
00219     } else {
00220         i__1 = *n;
00221         for (j = 1; j <= i__1; ++j) {
00222 /* Computing MIN */
00223             i__2 = *kd + 1, i__3 = *n - j + 1;
00224             ml = min(i__2,i__3);
00225             i__2 = ml;
00226             for (i__ = 1; i__ <= i__2; ++i__) {
00227                 afac[i__ + j * afac_dim1] -= a[i__ + j * a_dim1];
00228 /* L50: */
00229             }
00230 /* L60: */
00231         }
00232     }
00233 
00234 /*     Compute norm( L*L' - A ) / ( N * norm(A) * EPS ) */
00235 
00236     *resid = dlansb_("I", uplo, n, kd, &afac[afac_offset], ldafac, &rwork[1]);
00237 
00238     *resid = *resid / (doublereal) (*n) / anorm / eps;
00239 
00240     return 0;
00241 
00242 /*     End of DPBT01 */
00243 
00244 } /* dpbt01_ */


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