sget53.c
Go to the documentation of this file.
00001 /* sget53.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 /* Subroutine */ int sget53_(real *a, integer *lda, real *b, integer *ldb, 
00017         real *scale, real *wr, real *wi, real *result, integer *info)
00018 {
00019     /* System generated locals */
00020     integer a_dim1, a_offset, b_dim1, b_offset;
00021     real r__1, r__2, r__3, r__4, r__5, r__6;
00022 
00023     /* Builtin functions */
00024     double sqrt(doublereal);
00025 
00026     /* Local variables */
00027     real s1, ci11, ci12, ci22, cr11, cr12, cr21, cr22, ulp, wis, wrs, deti, 
00028             absw, detr, temp, anorm, bnorm, cnorm, cscale;
00029     extern doublereal slamch_(char *);
00030     real scales, safmin, sigmin;
00031 
00032 
00033 /*  -- LAPACK test routine (version 3.1) -- */
00034 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00035 /*     November 2006 */
00036 
00037 /*     .. Scalar Arguments .. */
00038 /*     .. */
00039 /*     .. Array Arguments .. */
00040 /*     .. */
00041 
00042 /*  Purpose */
00043 /*  ======= */
00044 
00045 /*  SGET53  checks the generalized eigenvalues computed by SLAG2. */
00046 
00047 /*  The basic test for an eigenvalue is: */
00048 
00049 /*                               | det( s A - w B ) | */
00050 /*      RESULT =  --------------------------------------------------- */
00051 /*                ulp max( s norm(A), |w| norm(B) )*norm( s A - w B ) */
00052 
00053 /*  Two "safety checks" are performed: */
00054 
00055 /*  (1)  ulp*max( s*norm(A), |w|*norm(B) )  must be at least */
00056 /*       safe_minimum.  This insures that the test performed is */
00057 /*       not essentially  det(0*A + 0*B)=0. */
00058 
00059 /*  (2)  s*norm(A) + |w|*norm(B) must be less than 1/safe_minimum. */
00060 /*       This insures that  s*A - w*B  will not overflow. */
00061 
00062 /*  If these tests are not passed, then  s  and  w  are scaled and */
00063 /*  tested anyway, if this is possible. */
00064 
00065 /*  Arguments */
00066 /*  ========= */
00067 
00068 /*  A       (input) REAL array, dimension (LDA, 2) */
00069 /*          The 2x2 matrix A. */
00070 
00071 /*  LDA     (input) INTEGER */
00072 /*          The leading dimension of A.  It must be at least 2. */
00073 
00074 /*  B       (input) REAL array, dimension (LDB, N) */
00075 /*          The 2x2 upper-triangular matrix B. */
00076 
00077 /*  LDB     (input) INTEGER */
00078 /*          The leading dimension of B.  It must be at least 2. */
00079 
00080 /*  SCALE   (input) REAL */
00081 /*          The "scale factor" s in the formula  s A - w B .  It is */
00082 /*          assumed to be non-negative. */
00083 
00084 /*  WR      (input) REAL */
00085 /*          The real part of the eigenvalue  w  in the formula */
00086 /*          s A - w B . */
00087 
00088 /*  WI      (input) REAL */
00089 /*          The imaginary part of the eigenvalue  w  in the formula */
00090 /*          s A - w B . */
00091 
00092 /*  RESULT  (output) REAL */
00093 /*          If INFO is 2 or less, the value computed by the test */
00094 /*             described above. */
00095 /*          If INFO=3, this will just be 1/ulp. */
00096 
00097 /*  INFO    (output) INTEGER */
00098 /*          =0:  The input data pass the "safety checks". */
00099 /*          =1:  s*norm(A) + |w|*norm(B) > 1/safe_minimum. */
00100 /*          =2:  ulp*max( s*norm(A), |w|*norm(B) ) < safe_minimum */
00101 /*          =3:  same as INFO=2, but  s  and  w  could not be scaled so */
00102 /*               as to compute the test. */
00103 
00104 /*  ===================================================================== */
00105 
00106 /*     .. Parameters .. */
00107 /*     .. */
00108 /*     .. Local Scalars .. */
00109 /*     .. */
00110 /*     .. External Functions .. */
00111 /*     .. */
00112 /*     .. Intrinsic Functions .. */
00113 /*     .. */
00114 /*     .. Executable Statements .. */
00115 
00116 /*     Initialize */
00117 
00118     /* Parameter adjustments */
00119     a_dim1 = *lda;
00120     a_offset = 1 + a_dim1;
00121     a -= a_offset;
00122     b_dim1 = *ldb;
00123     b_offset = 1 + b_dim1;
00124     b -= b_offset;
00125 
00126     /* Function Body */
00127     *info = 0;
00128     *result = 0.f;
00129     scales = *scale;
00130     wrs = *wr;
00131     wis = *wi;
00132 
00133 /*     Machine constants and norms */
00134 
00135     safmin = slamch_("Safe minimum");
00136     ulp = slamch_("Epsilon") * slamch_("Base");
00137     absw = dabs(wrs) + dabs(wis);
00138 /* Computing MAX */
00139     r__5 = (r__1 = a[a_dim1 + 1], dabs(r__1)) + (r__2 = a[a_dim1 + 2], dabs(
00140             r__2)), r__6 = (r__3 = a[(a_dim1 << 1) + 1], dabs(r__3)) + (r__4 =
00141              a[(a_dim1 << 1) + 2], dabs(r__4)), r__5 = max(r__5,r__6);
00142     anorm = dmax(r__5,safmin);
00143 /* Computing MAX */
00144     r__4 = (r__3 = b[b_dim1 + 1], dabs(r__3)), r__5 = (r__1 = b[(b_dim1 << 1) 
00145             + 1], dabs(r__1)) + (r__2 = b[(b_dim1 << 1) + 2], dabs(r__2)), 
00146             r__4 = max(r__4,r__5);
00147     bnorm = dmax(r__4,safmin);
00148 
00149 /*     Check for possible overflow. */
00150 
00151     temp = safmin * bnorm * absw + safmin * anorm * scales;
00152     if (temp >= 1.f) {
00153 
00154 /*        Scale down to avoid overflow */
00155 
00156         *info = 1;
00157         temp = 1.f / temp;
00158         scales *= temp;
00159         wrs *= temp;
00160         wis *= temp;
00161         absw = dabs(wrs) + dabs(wis);
00162     }
00163 /* Computing MAX */
00164 /* Computing MAX */
00165     r__3 = scales * anorm, r__4 = absw * bnorm;
00166     r__1 = ulp * dmax(r__3,r__4), r__2 = safmin * dmax(scales,absw);
00167     s1 = dmax(r__1,r__2);
00168 
00169 /*     Check for W and SCALE essentially zero. */
00170 
00171     if (s1 < safmin) {
00172         *info = 2;
00173         if (scales < safmin && absw < safmin) {
00174             *info = 3;
00175             *result = 1.f / ulp;
00176             return 0;
00177         }
00178 
00179 /*        Scale up to avoid underflow */
00180 
00181 /* Computing MAX */
00182         r__1 = scales * anorm + absw * bnorm;
00183         temp = 1.f / dmax(r__1,safmin);
00184         scales *= temp;
00185         wrs *= temp;
00186         wis *= temp;
00187         absw = dabs(wrs) + dabs(wis);
00188 /* Computing MAX */
00189 /* Computing MAX */
00190         r__3 = scales * anorm, r__4 = absw * bnorm;
00191         r__1 = ulp * dmax(r__3,r__4), r__2 = safmin * dmax(scales,absw);
00192         s1 = dmax(r__1,r__2);
00193         if (s1 < safmin) {
00194             *info = 3;
00195             *result = 1.f / ulp;
00196             return 0;
00197         }
00198     }
00199 
00200 /*     Compute C = s A - w B */
00201 
00202     cr11 = scales * a[a_dim1 + 1] - wrs * b[b_dim1 + 1];
00203     ci11 = -wis * b[b_dim1 + 1];
00204     cr21 = scales * a[a_dim1 + 2];
00205     cr12 = scales * a[(a_dim1 << 1) + 1] - wrs * b[(b_dim1 << 1) + 1];
00206     ci12 = -wis * b[(b_dim1 << 1) + 1];
00207     cr22 = scales * a[(a_dim1 << 1) + 2] - wrs * b[(b_dim1 << 1) + 2];
00208     ci22 = -wis * b[(b_dim1 << 1) + 2];
00209 
00210 /*     Compute the smallest singular value of s A - w B: */
00211 
00212 /*                 |det( s A - w B )| */
00213 /*     sigma_min = ------------------ */
00214 /*                 norm( s A - w B ) */
00215 
00216 /* Computing MAX */
00217     r__1 = dabs(cr11) + dabs(ci11) + dabs(cr21), r__2 = dabs(cr12) + dabs(
00218             ci12) + dabs(cr22) + dabs(ci22), r__1 = max(r__1,r__2);
00219     cnorm = dmax(r__1,safmin);
00220     cscale = 1.f / sqrt(cnorm);
00221     detr = cscale * cr11 * (cscale * cr22) - cscale * ci11 * (cscale * ci22) 
00222             - cscale * cr12 * (cscale * cr21);
00223     deti = cscale * cr11 * (cscale * ci22) + cscale * ci11 * (cscale * cr22) 
00224             - cscale * ci12 * (cscale * cr21);
00225     sigmin = dabs(detr) + dabs(deti);
00226     *result = sigmin / s1;
00227     return 0;
00228 
00229 /*     End of SGET53 */
00230 
00231 } /* sget53_ */


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