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


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