slas2.c
Go to the documentation of this file.
00001 /* slas2.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 slas2_(real *f, real *g, real *h__, real *ssmin, real *
00017         ssmax)
00018 {
00019     /* System generated locals */
00020     real r__1, r__2;
00021 
00022     /* Builtin functions */
00023     double sqrt(doublereal);
00024 
00025     /* Local variables */
00026     real 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 /*  SLAS2  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) REAL */
00049 /*          The (1,1) element of the 2-by-2 matrix. */
00050 
00051 /*  G       (input) REAL */
00052 /*          The (1,2) element of the 2-by-2 matrix. */
00053 
00054 /*  H       (input) REAL */
00055 /*          The (2,2) element of the 2-by-2 matrix. */
00056 
00057 /*  SSMIN   (output) REAL */
00058 /*          The smaller singular value. */
00059 
00060 /*  SSMAX   (output) REAL */
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 = dabs(*f);
00093     ga = dabs(*g);
00094     ha = dabs(*h__);
00095     fhmn = dmin(fa,ha);
00096     fhmx = dmax(fa,ha);
00097     if (fhmn == 0.f) {
00098         *ssmin = 0.f;
00099         if (fhmx == 0.f) {
00100             *ssmax = ga;
00101         } else {
00102 /* Computing 2nd power */
00103             r__1 = dmin(fhmx,ga) / dmax(fhmx,ga);
00104             *ssmax = dmax(fhmx,ga) * sqrt(r__1 * r__1 + 1.f);
00105         }
00106     } else {
00107         if (ga < fhmx) {
00108             as = fhmn / fhmx + 1.f;
00109             at = (fhmx - fhmn) / fhmx;
00110 /* Computing 2nd power */
00111             r__1 = ga / fhmx;
00112             au = r__1 * r__1;
00113             c__ = 2.f / (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.f) {
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.f;
00128                 at = (fhmx - fhmn) / fhmx;
00129 /* Computing 2nd power */
00130                 r__1 = as * au;
00131 /* Computing 2nd power */
00132                 r__2 = at * au;
00133                 c__ = 1.f / (sqrt(r__1 * r__1 + 1.f) + sqrt(r__2 * r__2 + 1.f)
00134                         );
00135                 *ssmin = fhmn * c__ * au;
00136                 *ssmin += *ssmin;
00137                 *ssmax = ga / (c__ + c__);
00138             }
00139         }
00140     }
00141     return 0;
00142 
00143 /*     End of SLAS2 */
00144 
00145 } /* slas2_ */


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