dlas2.c
Go to the documentation of this file.
00001 /* dlas2.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 dlas2_(doublereal *f, doublereal *g, doublereal *h__, 
00017         doublereal *ssmin, doublereal *ssmax)
00018 {
00019     /* System generated locals */
00020     doublereal d__1, d__2;
00021 
00022     /* Builtin functions */
00023     double sqrt(doublereal);
00024 
00025     /* Local variables */
00026     doublereal c__, fa, ga, ha, as, at, au, fhmn, fhmx;
00027 
00028 
00029 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00030 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00031 /*     November 2006 */
00032 
00033 /*     .. Scalar Arguments .. */
00034 /*     .. */
00035 
00036 /*  Purpose */
00037 /*  ======= */
00038 
00039 /*  DLAS2  computes the singular values of the 2-by-2 matrix */
00040 /*     [  F   G  ] */
00041 /*     [  0   H  ]. */
00042 /*  On return, SSMIN is the smaller singular value and SSMAX is the */
00043 /*  larger singular value. */
00044 
00045 /*  Arguments */
00046 /*  ========= */
00047 
00048 /*  F       (input) DOUBLE PRECISION */
00049 /*          The (1,1) element of the 2-by-2 matrix. */
00050 
00051 /*  G       (input) DOUBLE PRECISION */
00052 /*          The (1,2) element of the 2-by-2 matrix. */
00053 
00054 /*  H       (input) DOUBLE PRECISION */
00055 /*          The (2,2) element of the 2-by-2 matrix. */
00056 
00057 /*  SSMIN   (output) DOUBLE PRECISION */
00058 /*          The smaller singular value. */
00059 
00060 /*  SSMAX   (output) DOUBLE PRECISION */
00061 /*          The larger singular value. */
00062 
00063 /*  Further Details */
00064 /*  =============== */
00065 
00066 /*  Barring over/underflow, all output quantities are correct to within */
00067 /*  a few units in the last place (ulps), even in the absence of a guard */
00068 /*  digit in addition/subtraction. */
00069 
00070 /*  In IEEE arithmetic, the code works correctly if one matrix element is */
00071 /*  infinite. */
00072 
00073 /*  Overflow will not occur unless the largest singular value itself */
00074 /*  overflows, or is within a few ulps of overflow. (On machines with */
00075 /*  partial overflow, like the Cray, overflow may occur if the largest */
00076 /*  singular value is within a factor of 2 of overflow.) */
00077 
00078 /*  Underflow is harmless if underflow is gradual. Otherwise, results */
00079 /*  may correspond to a matrix modified by perturbations of size near */
00080 /*  the underflow threshold. */
00081 
00082 /*  ==================================================================== */
00083 
00084 /*     .. Parameters .. */
00085 /*     .. */
00086 /*     .. Local Scalars .. */
00087 /*     .. */
00088 /*     .. Intrinsic Functions .. */
00089 /*     .. */
00090 /*     .. Executable Statements .. */
00091 
00092     fa = abs(*f);
00093     ga = abs(*g);
00094     ha = abs(*h__);
00095     fhmn = min(fa,ha);
00096     fhmx = max(fa,ha);
00097     if (fhmn == 0.) {
00098         *ssmin = 0.;
00099         if (fhmx == 0.) {
00100             *ssmax = ga;
00101         } else {
00102 /* Computing 2nd power */
00103             d__1 = min(fhmx,ga) / max(fhmx,ga);
00104             *ssmax = max(fhmx,ga) * sqrt(d__1 * d__1 + 1.);
00105         }
00106     } else {
00107         if (ga < fhmx) {
00108             as = fhmn / fhmx + 1.;
00109             at = (fhmx - fhmn) / fhmx;
00110 /* Computing 2nd power */
00111             d__1 = ga / fhmx;
00112             au = d__1 * d__1;
00113             c__ = 2. / (sqrt(as * as + au) + sqrt(at * at + au));
00114             *ssmin = fhmn * c__;
00115             *ssmax = fhmx / c__;
00116         } else {
00117             au = fhmx / ga;
00118             if (au == 0.) {
00119 
00120 /*              Avoid possible harmful underflow if exponent range */
00121 /*              asymmetric (true SSMIN may not underflow even if */
00122 /*              AU underflows) */
00123 
00124                 *ssmin = fhmn * fhmx / ga;
00125                 *ssmax = ga;
00126             } else {
00127                 as = fhmn / fhmx + 1.;
00128                 at = (fhmx - fhmn) / fhmx;
00129 /* Computing 2nd power */
00130                 d__1 = as * au;
00131 /* Computing 2nd power */
00132                 d__2 = at * au;
00133                 c__ = 1. / (sqrt(d__1 * d__1 + 1.) + sqrt(d__2 * d__2 + 1.));
00134                 *ssmin = fhmn * c__ * au;
00135                 *ssmin += *ssmin;
00136                 *ssmax = ga / (c__ + c__);
00137             }
00138         }
00139     }
00140     return 0;
00141 
00142 /*     End of DLAS2 */
00143 
00144 } /* dlas2_ */


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