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


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