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


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