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


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