zstt21.c
Go to the documentation of this file.
00001 /* zstt21.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 zstt21_(integer *n, integer *kband, doublereal *ad, 
00023         doublereal *ae, doublereal *sd, doublereal *se, doublecomplex *u, 
00024         integer *ldu, doublecomplex *work, doublereal *rwork, doublereal *
00025         result)
00026 {
00027     /* System generated locals */
00028     integer u_dim1, u_offset, i__1, i__2, i__3;
00029     doublereal d__1, d__2, d__3;
00030     doublecomplex z__1, z__2;
00031 
00032     /* Local variables */
00033     integer j;
00034     doublereal ulp, unfl;
00035     extern /* Subroutine */ int zher_(char *, integer *, doublereal *, 
00036             doublecomplex *, integer *, doublecomplex *, integer *);
00037     doublereal temp1, temp2;
00038     extern /* Subroutine */ int zher2_(char *, integer *, doublecomplex *, 
00039             doublecomplex *, integer *, doublecomplex *, integer *, 
00040             doublecomplex *, integer *);
00041     doublereal anorm;
00042     extern /* Subroutine */ int zgemm_(char *, char *, integer *, integer *, 
00043             integer *, doublecomplex *, doublecomplex *, integer *, 
00044             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00045             integer *);
00046     doublereal wnorm;
00047     extern doublereal dlamch_(char *), zlange_(char *, integer *, 
00048             integer *, doublecomplex *, integer *, doublereal *), 
00049             zlanhe_(char *, char *, integer *, doublecomplex *, integer *, 
00050             doublereal *);
00051     extern /* Subroutine */ int zlaset_(char *, integer *, integer *, 
00052             doublecomplex *, doublecomplex *, doublecomplex *, integer *);
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 /*  ZSTT21  checks a decomposition of the form */
00068 
00069 /*     A = U S U* */
00070 
00071 /*  where * means conjugate transpose, A is real symmetric tridiagonal, */
00072 /*  U is unitary, and S is real and diagonal (if KBAND=0) or symmetric */
00073 /*  tridiagonal (if KBAND=1).  Two tests are performed: */
00074 
00075 /*     RESULT(1) = | A - U S U* | / ( |A| n ulp ) */
00076 
00077 /*     RESULT(2) = | I - UU* | / ( n ulp ) */
00078 
00079 /*  Arguments */
00080 /*  ========= */
00081 
00082 /*  N       (input) INTEGER */
00083 /*          The size of the matrix.  If it is zero, ZSTT21 does nothing. */
00084 /*          It must be at least zero. */
00085 
00086 /*  KBAND   (input) INTEGER */
00087 /*          The bandwidth of the matrix S.  It may only be zero or one. */
00088 /*          If zero, then S is diagonal, and SE is not referenced.  If */
00089 /*          one, then S is symmetric tri-diagonal. */
00090 
00091 /*  AD      (input) DOUBLE PRECISION array, dimension (N) */
00092 /*          The diagonal of the original (unfactored) matrix A.  A is */
00093 /*          assumed to be real symmetric tridiagonal. */
00094 
00095 /*  AE      (input) DOUBLE PRECISION array, dimension (N-1) */
00096 /*          The off-diagonal of the original (unfactored) matrix A.  A */
00097 /*          is assumed to be symmetric tridiagonal.  AE(1) is the (1,2) */
00098 /*          and (2,1) element, AE(2) is the (2,3) and (3,2) element, etc. */
00099 
00100 /*  SD      (input) DOUBLE PRECISION array, dimension (N) */
00101 /*          The diagonal of the real (symmetric tri-) diagonal matrix S. */
00102 
00103 /*  SE      (input) DOUBLE PRECISION array, dimension (N-1) */
00104 /*          The off-diagonal of the (symmetric tri-) diagonal matrix S. */
00105 /*          Not referenced if KBSND=0.  If KBAND=1, then AE(1) is the */
00106 /*          (1,2) and (2,1) element, SE(2) is the (2,3) and (3,2) */
00107 /*          element, etc. */
00108 
00109 /*  U       (input) COMPLEX*16 array, dimension (LDU, N) */
00110 /*          The unitary matrix in the decomposition. */
00111 
00112 /*  LDU     (input) INTEGER */
00113 /*          The leading dimension of U.  LDU must be at least N. */
00114 
00115 /*  WORK    (workspace) COMPLEX*16 array, dimension (N**2) */
00116 
00117 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00118 
00119 /*  RESULT  (output) DOUBLE PRECISION array, dimension (2) */
00120 /*          The values computed by the two tests described above.  The */
00121 /*          values are currently limited to 1/ulp, to avoid overflow. */
00122 /*          RESULT(1) is always modified. */
00123 
00124 /*  ===================================================================== */
00125 
00126 /*     .. Parameters .. */
00127 /*     .. */
00128 /*     .. Local Scalars .. */
00129 /*     .. */
00130 /*     .. External Functions .. */
00131 /*     .. */
00132 /*     .. External Subroutines .. */
00133 /*     .. */
00134 /*     .. Intrinsic Functions .. */
00135 /*     .. */
00136 /*     .. Executable Statements .. */
00137 
00138 /*     1)      Constants */
00139 
00140     /* Parameter adjustments */
00141     --ad;
00142     --ae;
00143     --sd;
00144     --se;
00145     u_dim1 = *ldu;
00146     u_offset = 1 + u_dim1;
00147     u -= u_offset;
00148     --work;
00149     --rwork;
00150     --result;
00151 
00152     /* Function Body */
00153     result[1] = 0.;
00154     result[2] = 0.;
00155     if (*n <= 0) {
00156         return 0;
00157     }
00158 
00159     unfl = dlamch_("Safe minimum");
00160     ulp = dlamch_("Precision");
00161 
00162 /*     Do Test 1 */
00163 
00164 /*     Copy A & Compute its 1-Norm: */
00165 
00166     zlaset_("Full", n, n, &c_b1, &c_b1, &work[1], n);
00167 
00168     anorm = 0.;
00169     temp1 = 0.;
00170 
00171     i__1 = *n - 1;
00172     for (j = 1; j <= i__1; ++j) {
00173         i__2 = (*n + 1) * (j - 1) + 1;
00174         i__3 = j;
00175         work[i__2].r = ad[i__3], work[i__2].i = 0.;
00176         i__2 = (*n + 1) * (j - 1) + 2;
00177         i__3 = j;
00178         work[i__2].r = ae[i__3], work[i__2].i = 0.;
00179         temp2 = (d__1 = ae[j], abs(d__1));
00180 /* Computing MAX */
00181         d__2 = anorm, d__3 = (d__1 = ad[j], abs(d__1)) + temp1 + temp2;
00182         anorm = max(d__2,d__3);
00183         temp1 = temp2;
00184 /* L10: */
00185     }
00186 
00187 /* Computing 2nd power */
00188     i__2 = *n;
00189     i__1 = i__2 * i__2;
00190     i__3 = *n;
00191     work[i__1].r = ad[i__3], work[i__1].i = 0.;
00192 /* Computing MAX */
00193     d__2 = anorm, d__3 = (d__1 = ad[*n], abs(d__1)) + temp1, d__2 = max(d__2,
00194             d__3);
00195     anorm = max(d__2,unfl);
00196 
00197 /*     Norm of A - USU* */
00198 
00199     i__1 = *n;
00200     for (j = 1; j <= i__1; ++j) {
00201         d__1 = -sd[j];
00202         zher_("L", n, &d__1, &u[j * u_dim1 + 1], &c__1, &work[1], n);
00203 /* L20: */
00204     }
00205 
00206     if (*n > 1 && *kband == 1) {
00207         i__1 = *n - 1;
00208         for (j = 1; j <= i__1; ++j) {
00209             i__2 = j;
00210             z__2.r = se[i__2], z__2.i = 0.;
00211             z__1.r = -z__2.r, z__1.i = -z__2.i;
00212             zher2_("L", n, &z__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1) * 
00213                     u_dim1 + 1], &c__1, &work[1], n);
00214 /* L30: */
00215         }
00216     }
00217 
00218     wnorm = zlanhe_("1", "L", n, &work[1], n, &rwork[1])
00219             ;
00220 
00221     if (anorm > wnorm) {
00222         result[1] = wnorm / anorm / (*n * ulp);
00223     } else {
00224         if (anorm < 1.) {
00225 /* Computing MIN */
00226             d__1 = wnorm, d__2 = *n * anorm;
00227             result[1] = min(d__1,d__2) / anorm / (*n * ulp);
00228         } else {
00229 /* Computing MIN */
00230             d__1 = wnorm / anorm, d__2 = (doublereal) (*n);
00231             result[1] = min(d__1,d__2) / (*n * ulp);
00232         }
00233     }
00234 
00235 /*     Do Test 2 */
00236 
00237 /*     Compute  UU* - I */
00238 
00239     zgemm_("N", "C", n, n, n, &c_b2, &u[u_offset], ldu, &u[u_offset], ldu, &
00240             c_b1, &work[1], n);
00241 
00242     i__1 = *n;
00243     for (j = 1; j <= i__1; ++j) {
00244         i__2 = (*n + 1) * (j - 1) + 1;
00245         i__3 = (*n + 1) * (j - 1) + 1;
00246         z__1.r = work[i__3].r - 1., z__1.i = work[i__3].i - 0.;
00247         work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00248 /* L40: */
00249     }
00250 
00251 /* Computing MIN */
00252     d__1 = (doublereal) (*n), d__2 = zlange_("1", n, n, &work[1], n, &rwork[1]
00253 );
00254     result[2] = min(d__1,d__2) / (*n * ulp);
00255 
00256     return 0;
00257 
00258 /*     End of ZSTT21 */
00259 
00260 } /* zstt21_ */


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