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


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