dtpcon.c
Go to the documentation of this file.
00001 /* dtpcon.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 dtpcon_(char *norm, char *uplo, char *diag, integer *n, 
00021         doublereal *ap, doublereal *rcond, doublereal *work, integer *iwork, 
00022         integer *info)
00023 {
00024     /* System generated locals */
00025     integer 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 dlantp_(char *, char *, char *, integer *, doublereal *, 
00044              doublereal *);
00045     doublereal ainvnm;
00046     extern /* Subroutine */ int dlatps_(char *, char *, char *, char *, 
00047             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00048              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 /*  DTPCON estimates the reciprocal of the condition number of a packed */
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 /*  AP      (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00098 /*          The upper or lower triangular matrix A, packed columnwise in */
00099 /*          a linear array.  The j-th column of A is stored in the array */
00100 /*          AP as follows: */
00101 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00102 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00103 /*          If DIAG = 'U', the diagonal elements of A are not referenced */
00104 /*          and are assumed to be 1. */
00105 
00106 /*  RCOND   (output) DOUBLE PRECISION */
00107 /*          The reciprocal of the condition number of the matrix A, */
00108 /*          computed as RCOND = 1/(norm(A) * norm(inv(A))). */
00109 
00110 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (3*N) */
00111 
00112 /*  IWORK   (workspace) INTEGER array, dimension (N) */
00113 
00114 /*  INFO    (output) INTEGER */
00115 /*          = 0:  successful exit */
00116 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00117 
00118 /*  ===================================================================== */
00119 
00120 /*     .. Parameters .. */
00121 /*     .. */
00122 /*     .. Local Scalars .. */
00123 /*     .. */
00124 /*     .. Local Arrays .. */
00125 /*     .. */
00126 /*     .. External Functions .. */
00127 /*     .. */
00128 /*     .. External Subroutines .. */
00129 /*     .. */
00130 /*     .. Intrinsic Functions .. */
00131 /*     .. */
00132 /*     .. Executable Statements .. */
00133 
00134 /*     Test the input parameters. */
00135 
00136     /* Parameter adjustments */
00137     --iwork;
00138     --work;
00139     --ap;
00140 
00141     /* Function Body */
00142     *info = 0;
00143     upper = lsame_(uplo, "U");
00144     onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O");
00145     nounit = lsame_(diag, "N");
00146 
00147     if (! onenrm && ! lsame_(norm, "I")) {
00148         *info = -1;
00149     } else if (! upper && ! lsame_(uplo, "L")) {
00150         *info = -2;
00151     } else if (! nounit && ! lsame_(diag, "U")) {
00152         *info = -3;
00153     } else if (*n < 0) {
00154         *info = -4;
00155     }
00156     if (*info != 0) {
00157         i__1 = -(*info);
00158         xerbla_("DTPCON", &i__1);
00159         return 0;
00160     }
00161 
00162 /*     Quick return if possible */
00163 
00164     if (*n == 0) {
00165         *rcond = 1.;
00166         return 0;
00167     }
00168 
00169     *rcond = 0.;
00170     smlnum = dlamch_("Safe minimum") * (doublereal) max(1,*n);
00171 
00172 /*     Compute the norm of the triangular matrix A. */
00173 
00174     anorm = dlantp_(norm, uplo, diag, n, &ap[1], &work[1]);
00175 
00176 /*     Continue only if ANORM > 0. */
00177 
00178     if (anorm > 0.) {
00179 
00180 /*        Estimate the norm of the inverse of A. */
00181 
00182         ainvnm = 0.;
00183         *(unsigned char *)normin = 'N';
00184         if (onenrm) {
00185             kase1 = 1;
00186         } else {
00187             kase1 = 2;
00188         }
00189         kase = 0;
00190 L10:
00191         dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave);
00192         if (kase != 0) {
00193             if (kase == kase1) {
00194 
00195 /*              Multiply by inv(A). */
00196 
00197                 dlatps_(uplo, "No transpose", diag, normin, n, &ap[1], &work[
00198                         1], &scale, &work[(*n << 1) + 1], info);
00199             } else {
00200 
00201 /*              Multiply by inv(A'). */
00202 
00203                 dlatps_(uplo, "Transpose", diag, normin, n, &ap[1], &work[1], 
00204                         &scale, &work[(*n << 1) + 1], info);
00205             }
00206             *(unsigned char *)normin = 'Y';
00207 
00208 /*           Multiply by 1/SCALE if doing so will not cause overflow. */
00209 
00210             if (scale != 1.) {
00211                 ix = idamax_(n, &work[1], &c__1);
00212                 xnorm = (d__1 = work[ix], abs(d__1));
00213                 if (scale < xnorm * smlnum || scale == 0.) {
00214                     goto L20;
00215                 }
00216                 drscl_(n, &scale, &work[1], &c__1);
00217             }
00218             goto L10;
00219         }
00220 
00221 /*        Compute the estimate of the reciprocal condition number. */
00222 
00223         if (ainvnm != 0.) {
00224             *rcond = 1. / anorm / ainvnm;
00225         }
00226     }
00227 
00228 L20:
00229     return 0;
00230 
00231 /*     End of DTPCON */
00232 
00233 } /* dtpcon_ */


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