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


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