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


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