sptcon.c
Go to the documentation of this file.
00001 /* sptcon.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 /* Table of constant values */
00017 
00018 static integer c__1 = 1;
00019 
00020 /* Subroutine */ int sptcon_(integer *n, real *d__, real *e, real *anorm, 
00021         real *rcond, real *work, integer *info)
00022 {
00023     /* System generated locals */
00024     integer i__1;
00025     real r__1;
00026 
00027     /* Local variables */
00028     integer i__, ix;
00029     extern /* Subroutine */ int xerbla_(char *, integer *);
00030     extern integer isamax_(integer *, real *, integer *);
00031     real ainvnm;
00032 
00033 
00034 /*  -- LAPACK routine (version 3.2) -- */
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 /*  SPTCON computes the reciprocal of the condition number (in the */
00047 /*  1-norm) of a real symmetric positive definite tridiagonal matrix */
00048 /*  using the factorization A = L*D*L**T or A = U**T*D*U computed by */
00049 /*  SPTTRF. */
00050 
00051 /*  Norm(inv(A)) is computed by a direct method, and the reciprocal of */
00052 /*  the condition number is computed as */
00053 /*               RCOND = 1 / (ANORM * norm(inv(A))). */
00054 
00055 /*  Arguments */
00056 /*  ========= */
00057 
00058 /*  N       (input) INTEGER */
00059 /*          The order of the matrix A.  N >= 0. */
00060 
00061 /*  D       (input) REAL array, dimension (N) */
00062 /*          The n diagonal elements of the diagonal matrix D from the */
00063 /*          factorization of A, as computed by SPTTRF. */
00064 
00065 /*  E       (input) REAL array, dimension (N-1) */
00066 /*          The (n-1) off-diagonal elements of the unit bidiagonal factor */
00067 /*          U or L from the factorization of A,  as computed by SPTTRF. */
00068 
00069 /*  ANORM   (input) REAL */
00070 /*          The 1-norm of the original matrix A. */
00071 
00072 /*  RCOND   (output) REAL */
00073 /*          The reciprocal of the condition number of the matrix A, */
00074 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is the */
00075 /*          1-norm of inv(A) computed in this routine. */
00076 
00077 /*  WORK    (workspace) REAL array, dimension (N) */
00078 
00079 /*  INFO    (output) INTEGER */
00080 /*          = 0:  successful exit */
00081 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00082 
00083 /*  Further Details */
00084 /*  =============== */
00085 
00086 /*  The method used is described in Nicholas J. Higham, "Efficient */
00087 /*  Algorithms for Computing the Condition Number of a Tridiagonal */
00088 /*  Matrix", SIAM J. Sci. Stat. Comput., Vol. 7, No. 1, January 1986. */
00089 
00090 /*  ===================================================================== */
00091 
00092 /*     .. Parameters .. */
00093 /*     .. */
00094 /*     .. Local Scalars .. */
00095 /*     .. */
00096 /*     .. External Functions .. */
00097 /*     .. */
00098 /*     .. External Subroutines .. */
00099 /*     .. */
00100 /*     .. Intrinsic Functions .. */
00101 /*     .. */
00102 /*     .. Executable Statements .. */
00103 
00104 /*     Test the input arguments. */
00105 
00106     /* Parameter adjustments */
00107     --work;
00108     --e;
00109     --d__;
00110 
00111     /* Function Body */
00112     *info = 0;
00113     if (*n < 0) {
00114         *info = -1;
00115     } else if (*anorm < 0.f) {
00116         *info = -4;
00117     }
00118     if (*info != 0) {
00119         i__1 = -(*info);
00120         xerbla_("SPTCON", &i__1);
00121         return 0;
00122     }
00123 
00124 /*     Quick return if possible */
00125 
00126     *rcond = 0.f;
00127     if (*n == 0) {
00128         *rcond = 1.f;
00129         return 0;
00130     } else if (*anorm == 0.f) {
00131         return 0;
00132     }
00133 
00134 /*     Check that D(1:N) is positive. */
00135 
00136     i__1 = *n;
00137     for (i__ = 1; i__ <= i__1; ++i__) {
00138         if (d__[i__] <= 0.f) {
00139             return 0;
00140         }
00141 /* L10: */
00142     }
00143 
00144 /*     Solve M(A) * x = e, where M(A) = (m(i,j)) is given by */
00145 
00146 /*        m(i,j) =  abs(A(i,j)), i = j, */
00147 /*        m(i,j) = -abs(A(i,j)), i .ne. j, */
00148 
00149 /*     and e = [ 1, 1, ..., 1 ]'.  Note M(A) = M(L)*D*M(L)'. */
00150 
00151 /*     Solve M(L) * x = e. */
00152 
00153     work[1] = 1.f;
00154     i__1 = *n;
00155     for (i__ = 2; i__ <= i__1; ++i__) {
00156         work[i__] = work[i__ - 1] * (r__1 = e[i__ - 1], dabs(r__1)) + 1.f;
00157 /* L20: */
00158     }
00159 
00160 /*     Solve D * M(L)' * x = b. */
00161 
00162     work[*n] /= d__[*n];
00163     for (i__ = *n - 1; i__ >= 1; --i__) {
00164         work[i__] = work[i__] / d__[i__] + work[i__ + 1] * (r__1 = e[i__], 
00165                 dabs(r__1));
00166 /* L30: */
00167     }
00168 
00169 /*     Compute AINVNM = max(x(i)), 1<=i<=n. */
00170 
00171     ix = isamax_(n, &work[1], &c__1);
00172     ainvnm = (r__1 = work[ix], dabs(r__1));
00173 
00174 /*     Compute the reciprocal condition number. */
00175 
00176     if (ainvnm != 0.f) {
00177         *rcond = 1.f / ainvnm / *anorm;
00178     }
00179 
00180     return 0;
00181 
00182 /*     End of SPTCON */
00183 
00184 } /* sptcon_ */


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