sgtcon.c
Go to the documentation of this file.
00001 /* sgtcon.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 sgtcon_(char *norm, integer *n, real *dl, real *d__, 
00021         real *du, real *du2, integer *ipiv, real *anorm, real *rcond, real *
00022         work, integer *iwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer i__1;
00026 
00027     /* Local variables */
00028     integer i__, kase, kase1;
00029     extern logical lsame_(char *, char *);
00030     integer isave[3];
00031     extern /* Subroutine */ int slacn2_(integer *, real *, real *, integer *, 
00032             real *, integer *, integer *), xerbla_(char *, integer *);
00033     real ainvnm;
00034     logical onenrm;
00035     extern /* Subroutine */ int sgttrs_(char *, integer *, integer *, real *, 
00036             real *, real *, real *, integer *, real *, integer *, integer *);
00037 
00038 
00039 /*  -- LAPACK routine (version 3.2) -- */
00040 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00041 /*     November 2006 */
00042 
00043 /*     Modified to call SLACN2 in place of SLACON, 7 Feb 03, SJH. */
00044 
00045 /*     .. Scalar Arguments .. */
00046 /*     .. */
00047 /*     .. Array Arguments .. */
00048 /*     .. */
00049 
00050 /*  Purpose */
00051 /*  ======= */
00052 
00053 /*  SGTCON estimates the reciprocal of the condition number of a real */
00054 /*  tridiagonal matrix A using the LU factorization as computed by */
00055 /*  SGTTRF. */
00056 
00057 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00058 /*  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
00059 
00060 /*  Arguments */
00061 /*  ========= */
00062 
00063 /*  NORM    (input) CHARACTER*1 */
00064 /*          Specifies whether the 1-norm condition number or the */
00065 /*          infinity-norm condition number is required: */
00066 /*          = '1' or 'O':  1-norm; */
00067 /*          = 'I':         Infinity-norm. */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The order of the matrix A.  N >= 0. */
00071 
00072 /*  DL      (input) REAL array, dimension (N-1) */
00073 /*          The (n-1) multipliers that define the matrix L from the */
00074 /*          LU factorization of A as computed by SGTTRF. */
00075 
00076 /*  D       (input) REAL array, dimension (N) */
00077 /*          The n diagonal elements of the upper triangular matrix U from */
00078 /*          the LU factorization of A. */
00079 
00080 /*  DU      (input) REAL array, dimension (N-1) */
00081 /*          The (n-1) elements of the first superdiagonal of U. */
00082 
00083 /*  DU2     (input) REAL array, dimension (N-2) */
00084 /*          The (n-2) elements of the second superdiagonal of U. */
00085 
00086 /*  IPIV    (input) INTEGER array, dimension (N) */
00087 /*          The pivot indices; for 1 <= i <= n, row i of the matrix was */
00088 /*          interchanged with row IPIV(i).  IPIV(i) will always be either */
00089 /*          i or i+1; IPIV(i) = i indicates a row interchange was not */
00090 /*          required. */
00091 
00092 /*  ANORM   (input) REAL */
00093 /*          If NORM = '1' or 'O', the 1-norm of the original matrix A. */
00094 /*          If NORM = 'I', the infinity-norm of the original matrix A. */
00095 
00096 /*  RCOND   (output) REAL */
00097 /*          The reciprocal of the condition number of the matrix A, */
00098 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
00099 /*          estimate of the 1-norm of inv(A) computed in this routine. */
00100 
00101 /*  WORK    (workspace) REAL array, dimension (2*N) */
00102 
00103 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00104 
00105 /*  INFO    (output) INTEGER */
00106 /*          = 0:  successful exit */
00107 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00108 
00109 /*  ===================================================================== */
00110 
00111 /*     .. Parameters .. */
00112 /*     .. */
00113 /*     .. Local Scalars .. */
00114 /*     .. */
00115 /*     .. Local Arrays .. */
00116 /*     .. */
00117 /*     .. External Functions .. */
00118 /*     .. */
00119 /*     .. External Subroutines .. */
00120 /*     .. */
00121 /*     .. Executable Statements .. */
00122 
00123 /*     Test the input arguments. */
00124 
00125     /* Parameter adjustments */
00126     --iwork;
00127     --work;
00128     --ipiv;
00129     --du2;
00130     --du;
00131     --d__;
00132     --dl;
00133 
00134     /* Function Body */
00135     *info = 0;
00136     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00137     if (! onenrm && ! lsame_(norm, "I")) {
00138         *info = -1;
00139     } else if (*n < 0) {
00140         *info = -2;
00141     } else if (*anorm < 0.f) {
00142         *info = -8;
00143     }
00144     if (*info != 0) {
00145         i__1 = -(*info);
00146         xerbla_("SGTCON", &i__1);
00147         return 0;
00148     }
00149 
00150 /*     Quick return if possible */
00151 
00152     *rcond = 0.f;
00153     if (*n == 0) {
00154         *rcond = 1.f;
00155         return 0;
00156     } else if (*anorm == 0.f) {
00157         return 0;
00158     }
00159 
00160 /*     Check that D(1:N) is non-zero. */
00161 
00162     i__1 = *n;
00163     for (i__ = 1; i__ <= i__1; ++i__) {
00164         if (d__[i__] == 0.f) {
00165             return 0;
00166         }
00167 /* L10: */
00168     }
00169 
00170     ainvnm = 0.f;
00171     if (onenrm) {
00172         kase1 = 1;
00173     } else {
00174         kase1 = 2;
00175     }
00176     kase = 0;
00177 L20:
00178     slacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00179     if (kase != 0) {
00180         if (kase == kase1) {
00181 
00182 /*           Multiply by inv(U)*inv(L). */
00183 
00184             sgttrs_("No transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1]
00185 , &ipiv[1], &work[1], n, info);
00186         } else {
00187 
00188 /*           Multiply by inv(L')*inv(U'). */
00189 
00190             sgttrs_("Transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1], &
00191                     ipiv[1], &work[1], n, info);
00192         }
00193         goto L20;
00194     }
00195 
00196 /*     Compute the estimate of the reciprocal condition number. */
00197 
00198     if (ainvnm != 0.f) {
00199         *rcond = 1.f / ainvnm / *anorm;
00200     }
00201 
00202     return 0;
00203 
00204 /*     End of SGTCON */
00205 
00206 } /* sgtcon_ */


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