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


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