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


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