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


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