dtrcon.c
Go to the documentation of this file.
00001 /* dtrcon.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 dtrcon_(char *norm, char *uplo, char *diag, integer *n, 
00021         doublereal *a, integer *lda, doublereal *rcond, doublereal *work, 
00022         integer *iwork, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1;
00026     doublereal d__1;
00027 
00028     /* Local variables */
00029     integer ix, kase, kase1;
00030     doublereal scale;
00031     extern logical lsame_(char *, char *);
00032     integer isave[3];
00033     extern /* Subroutine */ int drscl_(integer *, doublereal *, doublereal *, 
00034             integer *);
00035     doublereal anorm;
00036     logical upper;
00037     doublereal xnorm;
00038     extern /* Subroutine */ int dlacn2_(integer *, doublereal *, doublereal *, 
00039              integer *, doublereal *, integer *, integer *);
00040     extern doublereal dlamch_(char *);
00041     extern integer idamax_(integer *, doublereal *, integer *);
00042     extern /* Subroutine */ int xerbla_(char *, integer *);
00043     extern doublereal dlantr_(char *, char *, char *, integer *, integer *, 
00044             doublereal *, integer *, doublereal *);
00045     doublereal ainvnm;
00046     extern /* Subroutine */ int dlatrs_(char *, char *, char *, char *, 
00047             integer *, doublereal *, integer *, doublereal *, doublereal *, 
00048             doublereal *, integer *);
00049     logical onenrm;
00050     char normin[1];
00051     doublereal smlnum;
00052     logical nounit;
00053 
00054 
00055 /*  -- LAPACK routine (version 3.2) -- */
00056 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00057 /*     November 2006 */
00058 
00059 /*     Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */
00060 
00061 /*     .. Scalar Arguments .. */
00062 /*     .. */
00063 /*     .. Array Arguments .. */
00064 /*     .. */
00065 
00066 /*  Purpose */
00067 /*  ======= */
00068 
00069 /*  DTRCON estimates the reciprocal of the condition number of a */
00070 /*  triangular matrix A, in either the 1-norm or the infinity-norm. */
00071 
00072 /*  The norm of A is computed and an estimate is obtained for */
00073 /*  norm(inv(A)), then the reciprocal of the condition number is */
00074 /*  computed as */
00075 /*     RCOND = 1 / ( norm(A) * norm(inv(A)) ). */
00076 
00077 /*  Arguments */
00078 /*  ========= */
00079 
00080 /*  NORM    (input) CHARACTER*1 */
00081 /*          Specifies whether the 1-norm condition number or the */
00082 /*          infinity-norm condition number is required: */
00083 /*          = '1' or 'O':  1-norm; */
00084 /*          = 'I':         Infinity-norm. */
00085 
00086 /*  UPLO    (input) CHARACTER*1 */
00087 /*          = 'U':  A is upper triangular; */
00088 /*          = 'L':  A is lower triangular. */
00089 
00090 /*  DIAG    (input) CHARACTER*1 */
00091 /*          = 'N':  A is non-unit triangular; */
00092 /*          = 'U':  A is unit triangular. */
00093 
00094 /*  N       (input) INTEGER */
00095 /*          The order of the matrix A.  N >= 0. */
00096 
00097 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00098 /*          The triangular matrix A.  If UPLO = 'U', the leading N-by-N */
00099 /*          upper triangular part of the array A contains the upper */
00100 /*          triangular matrix, and the strictly lower triangular part of */
00101 /*          A is not referenced.  If UPLO = 'L', the leading N-by-N lower */
00102 /*          triangular part of the array A contains the lower triangular */
00103 /*          matrix, and the strictly upper triangular part of A is not */
00104 /*          referenced.  If DIAG = 'U', the diagonal elements of A are */
00105 /*          also not referenced and are assumed to be 1. */
00106 
00107 /*  LDA     (input) INTEGER */
00108 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00109 
00110 /*  RCOND   (output) DOUBLE PRECISION */
00111 /*          The reciprocal of the condition number of the matrix A, */
00112 /*          computed as RCOND = 1/(norm(A) * norm(inv(A))). */
00113 
00114 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (3*N) */
00115 
00116 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00117 
00118 /*  INFO    (output) INTEGER */
00119 /*          = 0:  successful exit */
00120 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00121 
00122 /*  ===================================================================== */
00123 
00124 /*     .. Parameters .. */
00125 /*     .. */
00126 /*     .. Local Scalars .. */
00127 /*     .. */
00128 /*     .. Local Arrays .. */
00129 /*     .. */
00130 /*     .. External Functions .. */
00131 /*     .. */
00132 /*     .. External Subroutines .. */
00133 /*     .. */
00134 /*     .. Intrinsic Functions .. */
00135 /*     .. */
00136 /*     .. Executable Statements .. */
00137 
00138 /*     Test the input parameters. */
00139 
00140     /* Parameter adjustments */
00141     a_dim1 = *lda;
00142     a_offset = 1 + a_dim1;
00143     a -= a_offset;
00144     --work;
00145     --iwork;
00146 
00147     /* Function Body */
00148     *info = 0;
00149     upper = lsame_(uplo, "U");
00150     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00151     nounit = lsame_(diag, "N");
00152 
00153     if (! onenrm && ! lsame_(norm, "I")) {
00154         *info = -1;
00155     } else if (! upper && ! lsame_(uplo, "L")) {
00156         *info = -2;
00157     } else if (! nounit && ! lsame_(diag, "U")) {
00158         *info = -3;
00159     } else if (*n < 0) {
00160         *info = -4;
00161     } else if (*lda < max(1,*n)) {
00162         *info = -6;
00163     }
00164     if (*info != 0) {
00165         i__1 = -(*info);
00166         xerbla_("DTRCON", &i__1);
00167         return 0;
00168     }
00169 
00170 /*     Quick return if possible */
00171 
00172     if (*n == 0) {
00173         *rcond = 1.;
00174         return 0;
00175     }
00176 
00177     *rcond = 0.;
00178     smlnum = dlamch_("Safe minimum") * (doublereal) max(1,*n);
00179 
00180 /*     Compute the norm of the triangular matrix A. */
00181 
00182     anorm = dlantr_(norm, uplo, diag, n, n, &a[a_offset], lda, &work[1]);
00183 
00184 /*     Continue only if ANORM > 0. */
00185 
00186     if (anorm > 0.) {
00187 
00188 /*        Estimate the norm of the inverse of A. */
00189 
00190         ainvnm = 0.;
00191         *(unsigned char *)normin = 'N';
00192         if (onenrm) {
00193             kase1 = 1;
00194         } else {
00195             kase1 = 2;
00196         }
00197         kase = 0;
00198 L10:
00199         dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00200         if (kase != 0) {
00201             if (kase == kase1) {
00202 
00203 /*              Multiply by inv(A). */
00204 
00205                 dlatrs_(uplo, "No transpose", diag, normin, n, &a[a_offset], 
00206                         lda, &work[1], &scale, &work[(*n << 1) + 1], info);
00207             } else {
00208 
00209 /*              Multiply by inv(A'). */
00210 
00211                 dlatrs_(uplo, "Transpose", diag, normin, n, &a[a_offset], lda, 
00212                          &work[1], &scale, &work[(*n << 1) + 1], info);
00213             }
00214             *(unsigned char *)normin = 'Y';
00215 
00216 /*           Multiply by 1/SCALE if doing so will not cause overflow. */
00217 
00218             if (scale != 1.) {
00219                 ix = idamax_(n, &work[1], &c__1);
00220                 xnorm = (d__1 = work[ix], abs(d__1));
00221                 if (scale < xnorm * smlnum || scale == 0.) {
00222                     goto L20;
00223                 }
00224                 drscl_(n, &scale, &work[1], &c__1);
00225             }
00226             goto L10;
00227         }
00228 
00229 /*        Compute the estimate of the reciprocal condition number. */
00230 
00231         if (ainvnm != 0.) {
00232             *rcond = 1. / anorm / ainvnm;
00233         }
00234     }
00235 
00236 L20:
00237     return 0;
00238 
00239 /*     End of DTRCON */
00240 
00241 } /* dtrcon_ */


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