ddisna.c
Go to the documentation of this file.
00001 /* ddisna.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 ddisna_(char *job, integer *m, integer *n, doublereal *
00017         d__, doublereal *sep, integer *info)
00018 {
00019     /* System generated locals */
00020     integer i__1;
00021     doublereal d__1, d__2, d__3;
00022 
00023     /* Local variables */
00024     integer i__, k;
00025     doublereal eps;
00026     logical decr, left, incr, sing, eigen;
00027     extern logical lsame_(char *, char *);
00028     doublereal anorm;
00029     logical right;
00030     extern doublereal dlamch_(char *);
00031     doublereal oldgap, safmin;
00032     extern /* Subroutine */ int xerbla_(char *, integer *);
00033     doublereal newgap, thresh;
00034 
00035 
00036 /*  -- LAPACK routine (version 3.2) -- */
00037 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00038 /*     November 2006 */
00039 
00040 /*     .. Scalar Arguments .. */
00041 /*     .. */
00042 /*     .. Array Arguments .. */
00043 /*     .. */
00044 
00045 /*  Purpose */
00046 /*  ======= */
00047 
00048 /*  DDISNA computes the reciprocal condition numbers for the eigenvectors */
00049 /*  of a real symmetric or complex Hermitian matrix or for the left or */
00050 /*  right singular vectors of a general m-by-n matrix. The reciprocal */
00051 /*  condition number is the 'gap' between the corresponding eigenvalue or */
00052 /*  singular value and the nearest other one. */
00053 
00054 /*  The bound on the error, measured by angle in radians, in the I-th */
00055 /*  computed vector is given by */
00056 
00057 /*         DLAMCH( 'E' ) * ( ANORM / SEP( I ) ) */
00058 
00059 /*  where ANORM = 2-norm(A) = max( abs( D(j) ) ).  SEP(I) is not allowed */
00060 /*  to be smaller than DLAMCH( 'E' )*ANORM in order to limit the size of */
00061 /*  the error bound. */
00062 
00063 /*  DDISNA may also be used to compute error bounds for eigenvectors of */
00064 /*  the generalized symmetric definite eigenproblem. */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  JOB     (input) CHARACTER*1 */
00070 /*          Specifies for which problem the reciprocal condition numbers */
00071 /*          should be computed: */
00072 /*          = 'E':  the eigenvectors of a symmetric/Hermitian matrix; */
00073 /*          = 'L':  the left singular vectors of a general matrix; */
00074 /*          = 'R':  the right singular vectors of a general matrix. */
00075 
00076 /*  M       (input) INTEGER */
00077 /*          The number of rows of the matrix. M >= 0. */
00078 
00079 /*  N       (input) INTEGER */
00080 /*          If JOB = 'L' or 'R', the number of columns of the matrix, */
00081 /*          in which case N >= 0. Ignored if JOB = 'E'. */
00082 
00083 /*  D       (input) DOUBLE PRECISION array, dimension (M) if JOB = 'E' */
00084 /*                              dimension (min(M,N)) if JOB = 'L' or 'R' */
00085 /*          The eigenvalues (if JOB = 'E') or singular values (if JOB = */
00086 /*          'L' or 'R') of the matrix, in either increasing or decreasing */
00087 /*          order. If singular values, they must be non-negative. */
00088 
00089 /*  SEP     (output) DOUBLE PRECISION array, dimension (M) if JOB = 'E' */
00090 /*                               dimension (min(M,N)) if JOB = 'L' or 'R' */
00091 /*          The reciprocal condition numbers of the vectors. */
00092 
00093 /*  INFO    (output) INTEGER */
00094 /*          = 0:  successful exit. */
00095 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00096 
00097 /*  ===================================================================== */
00098 
00099 /*     .. Parameters .. */
00100 /*     .. */
00101 /*     .. Local Scalars .. */
00102 /*     .. */
00103 /*     .. External Functions .. */
00104 /*     .. */
00105 /*     .. Intrinsic Functions .. */
00106 /*     .. */
00107 /*     .. External Subroutines .. */
00108 /*     .. */
00109 /*     .. Executable Statements .. */
00110 
00111 /*     Test the input arguments */
00112 
00113     /* Parameter adjustments */
00114     --sep;
00115     --d__;
00116 
00117     /* Function Body */
00118     *info = 0;
00119     eigen = lsame_(job, "E");
00120     left = lsame_(job, "L");
00121     right = lsame_(job, "R");
00122     sing = left || right;
00123     if (eigen) {
00124         k = *m;
00125     } else if (sing) {
00126         k = min(*m,*n);
00127     }
00128     if (! eigen && ! sing) {
00129         *info = -1;
00130     } else if (*m < 0) {
00131         *info = -2;
00132     } else if (k < 0) {
00133         *info = -3;
00134     } else {
00135         incr = TRUE_;
00136         decr = TRUE_;
00137         i__1 = k - 1;
00138         for (i__ = 1; i__ <= i__1; ++i__) {
00139             if (incr) {
00140                 incr = incr && d__[i__] <= d__[i__ + 1];
00141             }
00142             if (decr) {
00143                 decr = decr && d__[i__] >= d__[i__ + 1];
00144             }
00145 /* L10: */
00146         }
00147         if (sing && k > 0) {
00148             if (incr) {
00149                 incr = incr && 0. <= d__[1];
00150             }
00151             if (decr) {
00152                 decr = decr && d__[k] >= 0.;
00153             }
00154         }
00155         if (! (incr || decr)) {
00156             *info = -4;
00157         }
00158     }
00159     if (*info != 0) {
00160         i__1 = -(*info);
00161         xerbla_("DDISNA", &i__1);
00162         return 0;
00163     }
00164 
00165 /*     Quick return if possible */
00166 
00167     if (k == 0) {
00168         return 0;
00169     }
00170 
00171 /*     Compute reciprocal condition numbers */
00172 
00173     if (k == 1) {
00174         sep[1] = dlamch_("O");
00175     } else {
00176         oldgap = (d__1 = d__[2] - d__[1], abs(d__1));
00177         sep[1] = oldgap;
00178         i__1 = k - 1;
00179         for (i__ = 2; i__ <= i__1; ++i__) {
00180             newgap = (d__1 = d__[i__ + 1] - d__[i__], abs(d__1));
00181             sep[i__] = min(oldgap,newgap);
00182             oldgap = newgap;
00183 /* L20: */
00184         }
00185         sep[k] = oldgap;
00186     }
00187     if (sing) {
00188         if (left && *m > *n || right && *m < *n) {
00189             if (incr) {
00190                 sep[1] = min(sep[1],d__[1]);
00191             }
00192             if (decr) {
00193 /* Computing MIN */
00194                 d__1 = sep[k], d__2 = d__[k];
00195                 sep[k] = min(d__1,d__2);
00196             }
00197         }
00198     }
00199 
00200 /*     Ensure that reciprocal condition numbers are not less than */
00201 /*     threshold, in order to limit the size of the error bound */
00202 
00203     eps = dlamch_("E");
00204     safmin = dlamch_("S");
00205 /* Computing MAX */
00206     d__2 = abs(d__[1]), d__3 = (d__1 = d__[k], abs(d__1));
00207     anorm = max(d__2,d__3);
00208     if (anorm == 0.) {
00209         thresh = eps;
00210     } else {
00211 /* Computing MAX */
00212         d__1 = eps * anorm;
00213         thresh = max(d__1,safmin);
00214     }
00215     i__1 = k;
00216     for (i__ = 1; i__ <= i__1; ++i__) {
00217 /* Computing MAX */
00218         d__1 = sep[i__];
00219         sep[i__] = max(d__1,thresh);
00220 /* L30: */
00221     }
00222 
00223     return 0;
00224 
00225 /*     End of DDISNA */
00226 
00227 } /* ddisna_ */


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