dsbt21.c
Go to the documentation of this file.
00001 /* dsbt21.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_b22 = 1.;
00020 static doublereal c_b23 = 0.;
00021 
00022 /* Subroutine */ int dsbt21_(char *uplo, integer *n, integer *ka, integer *ks, 
00023          doublereal *a, integer *lda, doublereal *d__, doublereal *e, 
00024         doublereal *u, integer *ldu, doublereal *work, doublereal *result)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, u_dim1, u_offset, i__1, i__2, i__3, i__4;
00028     doublereal d__1, d__2;
00029 
00030     /* Local variables */
00031     integer j, jc, jr, lw, ika;
00032     doublereal ulp, unfl;
00033     extern /* Subroutine */ int dspr_(char *, integer *, doublereal *, 
00034             doublereal *, integer *, doublereal *), dspr2_(char *, 
00035             integer *, doublereal *, doublereal *, integer *, doublereal *, 
00036             integer *, doublereal *), dgemm_(char *, char *, integer *
00037 , integer *, integer *, doublereal *, doublereal *, integer *, 
00038             doublereal *, integer *, doublereal *, doublereal *, integer *);
00039     extern logical lsame_(char *, char *);
00040     doublereal anorm;
00041     char cuplo[1];
00042     logical lower;
00043     doublereal wnorm;
00044     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00045             integer *, doublereal *, integer *, doublereal *), 
00046             dlansb_(char *, char *, integer *, integer *, doublereal *, 
00047             integer *, doublereal *), dlansp_(char *, char *, 
00048             integer *, doublereal *, doublereal *);
00049 
00050 
00051 /*  -- LAPACK test routine (version 3.1) -- */
00052 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00053 /*     November 2006 */
00054 
00055 /*     .. Scalar Arguments .. */
00056 /*     .. */
00057 /*     .. Array Arguments .. */
00058 /*     .. */
00059 
00060 /*  Purpose */
00061 /*  ======= */
00062 
00063 /*  DSBT21  generally checks a decomposition of the form */
00064 
00065 /*          A = U S U' */
00066 
00067 /*  where ' means transpose, A is symmetric banded, U is */
00068 /*  orthogonal, and S is diagonal (if KS=0) or symmetric */
00069 /*  tridiagonal (if KS=1). */
00070 
00071 /*  Specifically: */
00072 
00073 /*          RESULT(1) = | A - U S U' | / ( |A| n ulp ) *and* */
00074 /*          RESULT(2) = | I - UU' | / ( n ulp ) */
00075 
00076 /*  Arguments */
00077 /*  ========= */
00078 
00079 /*  UPLO    (input) CHARACTER */
00080 /*          If UPLO='U', the upper triangle of A and V will be used and */
00081 /*          the (strictly) lower triangle will not be referenced. */
00082 /*          If UPLO='L', the lower triangle of A and V will be used and */
00083 /*          the (strictly) upper triangle will not be referenced. */
00084 
00085 /*  N       (input) INTEGER */
00086 /*          The size of the matrix.  If it is zero, DSBT21 does nothing. */
00087 /*          It must be at least zero. */
00088 
00089 /*  KA      (input) INTEGER */
00090 /*          The bandwidth of the matrix A.  It must be at least zero.  If */
00091 /*          it is larger than N-1, then max( 0, N-1 ) will be used. */
00092 
00093 /*  KS      (input) INTEGER */
00094 /*          The bandwidth of the matrix S.  It may only be zero or one. */
00095 /*          If zero, then S is diagonal, and E is not referenced.  If */
00096 /*          one, then S is symmetric tri-diagonal. */
00097 
00098 /*  A       (input) DOUBLE PRECISION array, dimension (LDA, N) */
00099 /*          The original (unfactored) matrix.  It is assumed to be */
00100 /*          symmetric, and only the upper (UPLO='U') or only the lower */
00101 /*          (UPLO='L') will be referenced. */
00102 
00103 /*  LDA     (input) INTEGER */
00104 /*          The leading dimension of A.  It must be at least 1 */
00105 /*          and at least min( KA, N-1 ). */
00106 
00107 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
00108 /*          The diagonal of the (symmetric tri-) diagonal matrix S. */
00109 
00110 /*  E       (input) DOUBLE PRECISION array, dimension (N-1) */
00111 /*          The off-diagonal of the (symmetric tri-) diagonal matrix S. */
00112 /*          E(1) is the (1,2) and (2,1) element, E(2) is the (2,3) and */
00113 /*          (3,2) element, etc. */
00114 /*          Not referenced if KS=0. */
00115 
00116 /*  U       (input) DOUBLE PRECISION array, dimension (LDU, N) */
00117 /*          The orthogonal matrix in the decomposition, expressed as a */
00118 /*          dense matrix (i.e., not as a product of Householder */
00119 /*          transformations, Givens transformations, etc.) */
00120 
00121 /*  LDU     (input) INTEGER */
00122 /*          The leading dimension of U.  LDU must be at least N and */
00123 /*          at least 1. */
00124 
00125 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (N**2+N) */
00126 
00127 /*  RESULT  (output) DOUBLE PRECISION array, dimension (2) */
00128 /*          The values computed by the two tests described above.  The */
00129 /*          values are currently limited to 1/ulp, to avoid overflow. */
00130 
00131 /*  ===================================================================== */
00132 
00133 /*     .. Parameters .. */
00134 /*     .. */
00135 /*     .. Local Scalars .. */
00136 /*     .. */
00137 /*     .. External Functions .. */
00138 /*     .. */
00139 /*     .. External Subroutines .. */
00140 /*     .. */
00141 /*     .. Intrinsic Functions .. */
00142 /*     .. */
00143 /*     .. Executable Statements .. */
00144 
00145 /*     Constants */
00146 
00147     /* Parameter adjustments */
00148     a_dim1 = *lda;
00149     a_offset = 1 + a_dim1;
00150     a -= a_offset;
00151     --d__;
00152     --e;
00153     u_dim1 = *ldu;
00154     u_offset = 1 + u_dim1;
00155     u -= u_offset;
00156     --work;
00157     --result;
00158 
00159     /* Function Body */
00160     result[1] = 0.;
00161     result[2] = 0.;
00162     if (*n <= 0) {
00163         return 0;
00164     }
00165 
00166 /* Computing MAX */
00167 /* Computing MIN */
00168     i__3 = *n - 1;
00169     i__1 = 0, i__2 = min(i__3,*ka);
00170     ika = max(i__1,i__2);
00171     lw = *n * (*n + 1) / 2;
00172 
00173     if (lsame_(uplo, "U")) {
00174         lower = FALSE_;
00175         *(unsigned char *)cuplo = 'U';
00176     } else {
00177         lower = TRUE_;
00178         *(unsigned char *)cuplo = 'L';
00179     }
00180 
00181     unfl = dlamch_("Safe minimum");
00182     ulp = dlamch_("Epsilon") * dlamch_("Base");
00183 
00184 /*     Some Error Checks */
00185 
00186 /*     Do Test 1 */
00187 
00188 /*     Norm of A: */
00189 
00190 /* Computing MAX */
00191     d__1 = dlansb_("1", cuplo, n, &ika, &a[a_offset], lda, &work[1]);
00192     anorm = max(d__1,unfl);
00193 
00194 /*     Compute error matrix:    Error = A - U S U' */
00195 
00196 /*     Copy A from SB to SP storage format. */
00197 
00198     j = 0;
00199     i__1 = *n;
00200     for (jc = 1; jc <= i__1; ++jc) {
00201         if (lower) {
00202 /* Computing MIN */
00203             i__3 = ika + 1, i__4 = *n + 1 - jc;
00204             i__2 = min(i__3,i__4);
00205             for (jr = 1; jr <= i__2; ++jr) {
00206                 ++j;
00207                 work[j] = a[jr + jc * a_dim1];
00208 /* L10: */
00209             }
00210             i__2 = *n + 1 - jc;
00211             for (jr = ika + 2; jr <= i__2; ++jr) {
00212                 ++j;
00213                 work[j] = 0.;
00214 /* L20: */
00215             }
00216         } else {
00217             i__2 = jc;
00218             for (jr = ika + 2; jr <= i__2; ++jr) {
00219                 ++j;
00220                 work[j] = 0.;
00221 /* L30: */
00222             }
00223 /* Computing MIN */
00224             i__2 = ika, i__3 = jc - 1;
00225             for (jr = min(i__2,i__3); jr >= 0; --jr) {
00226                 ++j;
00227                 work[j] = a[ika + 1 - jr + jc * a_dim1];
00228 /* L40: */
00229             }
00230         }
00231 /* L50: */
00232     }
00233 
00234     i__1 = *n;
00235     for (j = 1; j <= i__1; ++j) {
00236         d__1 = -d__[j];
00237         dspr_(cuplo, n, &d__1, &u[j * u_dim1 + 1], &c__1, &work[1])
00238                 ;
00239 /* L60: */
00240     }
00241 
00242     if (*n > 1 && *ks == 1) {
00243         i__1 = *n - 1;
00244         for (j = 1; j <= i__1; ++j) {
00245             d__1 = -e[j];
00246             dspr2_(cuplo, n, &d__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1) * 
00247                     u_dim1 + 1], &c__1, &work[1]);
00248 /* L70: */
00249         }
00250     }
00251     wnorm = dlansp_("1", cuplo, n, &work[1], &work[lw + 1]);
00252 
00253     if (anorm > wnorm) {
00254         result[1] = wnorm / anorm / (*n * ulp);
00255     } else {
00256         if (anorm < 1.) {
00257 /* Computing MIN */
00258             d__1 = wnorm, d__2 = *n * anorm;
00259             result[1] = min(d__1,d__2) / anorm / (*n * ulp);
00260         } else {
00261 /* Computing MIN */
00262             d__1 = wnorm / anorm, d__2 = (doublereal) (*n);
00263             result[1] = min(d__1,d__2) / (*n * ulp);
00264         }
00265     }
00266 
00267 /*     Do Test 2 */
00268 
00269 /*     Compute  UU' - I */
00270 
00271     dgemm_("N", "C", n, n, n, &c_b22, &u[u_offset], ldu, &u[u_offset], ldu, &
00272             c_b23, &work[1], n);
00273 
00274     i__1 = *n;
00275     for (j = 1; j <= i__1; ++j) {
00276         work[(*n + 1) * (j - 1) + 1] += -1.;
00277 /* L80: */
00278     }
00279 
00280 /* Computing MIN */
00281 /* Computing 2nd power */
00282     i__1 = *n;
00283     d__1 = dlange_("1", n, n, &work[1], n, &work[i__1 * i__1 + 1]),
00284              d__2 = (doublereal) (*n);
00285     result[2] = min(d__1,d__2) / (*n * ulp);
00286 
00287     return 0;
00288 
00289 /*     End of DSBT21 */
00290 
00291 } /* dsbt21_ */


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