chst01.c
Go to the documentation of this file.
00001 /* chst01.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_b7 = {1.f,0.f};
00019 static complex c_b8 = {0.f,0.f};
00020 static complex c_b11 = {-1.f,0.f};
00021 
00022 /* Subroutine */ int chst01_(integer *n, integer *ilo, integer *ihi, complex *
00023         a, integer *lda, complex *h__, integer *ldh, complex *q, integer *ldq, 
00024          complex *work, integer *lwork, real *rwork, real *result)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, h_dim1, h_offset, q_dim1, q_offset;
00028     real r__1, r__2;
00029 
00030     /* Local variables */
00031     real eps, unfl, ovfl;
00032     extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, 
00033             integer *, complex *, complex *, integer *, complex *, integer *, 
00034             complex *, complex *, integer *), cunt01_(char *, 
00035             integer *, integer *, complex *, integer *, complex *, integer *, 
00036             real *, real *);
00037     real anorm, wnorm;
00038     extern /* Subroutine */ int slabad_(real *, real *);
00039     extern doublereal clange_(char *, integer *, integer *, complex *, 
00040             integer *, real *), slamch_(char *);
00041     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00042             *, integer *, complex *, integer *);
00043     integer ldwork;
00044     real smlnum;
00045 
00046 
00047 /*  -- LAPACK test routine (version 3.1) -- */
00048 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00049 /*     November 2006 */
00050 
00051 /*     .. Scalar Arguments .. */
00052 /*     .. */
00053 /*     .. Array Arguments .. */
00054 /*     .. */
00055 
00056 /*  Purpose */
00057 /*  ======= */
00058 
00059 /*  CHST01 tests the reduction of a general matrix A to upper Hessenberg */
00060 /*  form:  A = Q*H*Q'.  Two test ratios are computed; */
00061 
00062 /*  RESULT(1) = norm( A - Q*H*Q' ) / ( norm(A) * N * EPS ) */
00063 /*  RESULT(2) = norm( I - Q'*Q ) / ( N * EPS ) */
00064 
00065 /*  The matrix Q is assumed to be given explicitly as it would be */
00066 /*  following CGEHRD + CUNGHR. */
00067 
00068 /*  In this version, ILO and IHI are not used, but they could be used */
00069 /*  to save some work if this is desired. */
00070 
00071 /*  Arguments */
00072 /*  ========= */
00073 
00074 /*  N       (input) INTEGER */
00075 /*          The order of the matrix A.  N >= 0. */
00076 
00077 /*  ILO     (input) INTEGER */
00078 /*  IHI     (input) INTEGER */
00079 /*          A is assumed to be upper triangular in rows and columns */
00080 /*          1:ILO-1 and IHI+1:N, so Q differs from the identity only in */
00081 /*          rows and columns ILO+1:IHI. */
00082 
00083 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00084 /*          The original n by n matrix A. */
00085 
00086 /*  LDA     (input) INTEGER */
00087 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00088 
00089 /*  H       (input) COMPLEX array, dimension (LDH,N) */
00090 /*          The upper Hessenberg matrix H from the reduction A = Q*H*Q' */
00091 /*          as computed by CGEHRD.  H is assumed to be zero below the */
00092 /*          first subdiagonal. */
00093 
00094 /*  LDH     (input) INTEGER */
00095 /*          The leading dimension of the array H.  LDH >= max(1,N). */
00096 
00097 /*  Q       (input) COMPLEX array, dimension (LDQ,N) */
00098 /*          The orthogonal matrix Q from the reduction A = Q*H*Q' as */
00099 /*          computed by CGEHRD + CUNGHR. */
00100 
00101 /*  LDQ     (input) INTEGER */
00102 /*          The leading dimension of the array Q.  LDQ >= max(1,N). */
00103 
00104 /*  WORK    (workspace) COMPLEX array, dimension (LWORK) */
00105 
00106 /*  LWORK   (input) INTEGER */
00107 /*          The length of the array WORK.  LWORK >= 2*N*N. */
00108 
00109 /*  RWORK   (workspace) REAL array, dimension (N) */
00110 
00111 /*  RESULT  (output) REAL array, dimension (2) */
00112 /*          RESULT(1) = norm( A - Q*H*Q' ) / ( norm(A) * N * EPS ) */
00113 /*          RESULT(2) = norm( I - Q'*Q ) / ( N * EPS ) */
00114 
00115 /*  ===================================================================== */
00116 
00117 /*     .. Parameters .. */
00118 /*     .. */
00119 /*     .. Local Scalars .. */
00120 /*     .. */
00121 /*     .. External Functions .. */
00122 /*     .. */
00123 /*     .. External Subroutines .. */
00124 /*     .. */
00125 /*     .. Intrinsic Functions .. */
00126 /*     .. */
00127 /*     .. Executable Statements .. */
00128 
00129 /*     Quick return if possible */
00130 
00131     /* Parameter adjustments */
00132     a_dim1 = *lda;
00133     a_offset = 1 + a_dim1;
00134     a -= a_offset;
00135     h_dim1 = *ldh;
00136     h_offset = 1 + h_dim1;
00137     h__ -= h_offset;
00138     q_dim1 = *ldq;
00139     q_offset = 1 + q_dim1;
00140     q -= q_offset;
00141     --work;
00142     --rwork;
00143     --result;
00144 
00145     /* Function Body */
00146     if (*n <= 0) {
00147         result[1] = 0.f;
00148         result[2] = 0.f;
00149         return 0;
00150     }
00151 
00152     unfl = slamch_("Safe minimum");
00153     eps = slamch_("Precision");
00154     ovfl = 1.f / unfl;
00155     slabad_(&unfl, &ovfl);
00156     smlnum = unfl * *n / eps;
00157 
00158 /*     Test 1:  Compute norm( A - Q*H*Q' ) / ( norm(A) * N * EPS ) */
00159 
00160 /*     Copy A to WORK */
00161 
00162     ldwork = max(1,*n);
00163     clacpy_(" ", n, n, &a[a_offset], lda, &work[1], &ldwork);
00164 
00165 /*     Compute Q*H */
00166 
00167     cgemm_("No transpose", "No transpose", n, n, n, &c_b7, &q[q_offset], ldq, 
00168             &h__[h_offset], ldh, &c_b8, &work[ldwork * *n + 1], &ldwork);
00169 
00170 /*     Compute A - Q*H*Q' */
00171 
00172     cgemm_("No transpose", "Conjugate transpose", n, n, n, &c_b11, &work[
00173             ldwork * *n + 1], &ldwork, &q[q_offset], ldq, &c_b7, &work[1], &
00174             ldwork);
00175 
00176 /* Computing MAX */
00177     r__1 = clange_("1", n, n, &a[a_offset], lda, &rwork[1]);
00178     anorm = dmax(r__1,unfl);
00179     wnorm = clange_("1", n, n, &work[1], &ldwork, &rwork[1]);
00180 
00181 /*     Note that RESULT(1) cannot overflow and is bounded by 1/(N*EPS) */
00182 
00183 /* Computing MAX */
00184     r__1 = smlnum, r__2 = anorm * eps;
00185     result[1] = dmin(wnorm,anorm) / dmax(r__1,r__2) / *n;
00186 
00187 /*     Test 2:  Compute norm( I - Q'*Q ) / ( N * EPS ) */
00188 
00189     cunt01_("Columns", n, n, &q[q_offset], ldq, &work[1], lwork, &rwork[1], &
00190             result[2]);
00191 
00192     return 0;
00193 
00194 /*     End of CHST01 */
00195 
00196 } /* chst01_ */


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