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


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