csycon.c
Go to the documentation of this file.
00001 /* csycon.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 csycon_(char *uplo, integer *n, complex *a, integer *lda, 
00021          integer *ipiv, real *anorm, real *rcond, complex *work, integer *
00022         info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2;
00026 
00027     /* Local variables */
00028     integer i__, kase;
00029     extern logical lsame_(char *, char *);
00030     integer isave[3];
00031     logical upper;
00032     extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real 
00033             *, integer *, integer *), xerbla_(char *, integer *);
00034     real ainvnm;
00035     extern /* Subroutine */ int csytrs_(char *, integer *, integer *, complex 
00036             *, integer *, integer *, complex *, integer *, integer *);
00037 
00038 
00039 /*  -- LAPACK routine (version 3.2) -- */
00040 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00041 /*     November 2006 */
00042 
00043 /*     Modified to call CLACN2 in place of CLACON, 10 Feb 03, SJH. */
00044 
00045 /*     .. Scalar Arguments .. */
00046 /*     .. */
00047 /*     .. Array Arguments .. */
00048 /*     .. */
00049 
00050 /*  Purpose */
00051 /*  ======= */
00052 
00053 /*  CSYCON estimates the reciprocal of the condition number (in the */
00054 /*  1-norm) of a complex symmetric matrix A using the factorization */
00055 /*  A = U*D*U**T or A = L*D*L**T computed by CSYTRF. */
00056 
00057 /*  An estimate is obtained for norm(inv(A)), and the reciprocal of the */
00058 /*  condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */
00059 
00060 /*  Arguments */
00061 /*  ========= */
00062 
00063 /*  UPLO    (input) CHARACTER*1 */
00064 /*          Specifies whether the details of the factorization are stored */
00065 /*          as an upper or lower triangular matrix. */
00066 /*          = 'U':  Upper triangular, form is A = U*D*U**T; */
00067 /*          = 'L':  Lower triangular, form is A = L*D*L**T. */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The order of the matrix A.  N >= 0. */
00071 
00072 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00073 /*          The block diagonal matrix D and the multipliers used to */
00074 /*          obtain the factor U or L as computed by CSYTRF. */
00075 
00076 /*  LDA     (input) INTEGER */
00077 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00078 
00079 /*  IPIV    (input) INTEGER array, dimension (N) */
00080 /*          Details of the interchanges and the block structure of D */
00081 /*          as determined by CSYTRF. */
00082 
00083 /*  ANORM   (input) REAL */
00084 /*          The 1-norm of the original matrix A. */
00085 
00086 /*  RCOND   (output) REAL */
00087 /*          The reciprocal of the condition number of the matrix A, */
00088 /*          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */
00089 /*          estimate of the 1-norm of inv(A) computed in this routine. */
00090 
00091 /*  WORK    (workspace) COMPLEX array, dimension (2*N) */
00092 
00093 /*  INFO    (output) INTEGER */
00094 /*          = 0:  successful exit */
00095 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00096 
00097 /*  ===================================================================== */
00098 
00099 /*     .. Parameters .. */
00100 /*     .. */
00101 /*     .. Local Scalars .. */
00102 /*     .. */
00103 /*     .. Local Arrays .. */
00104 /*     .. */
00105 /*     .. External Functions .. */
00106 /*     .. */
00107 /*     .. External Subroutines .. */
00108 /*     .. */
00109 /*     .. Intrinsic Functions .. */
00110 /*     .. */
00111 /*     .. Executable Statements .. */
00112 
00113 /*     Test the input parameters. */
00114 
00115     /* Parameter adjustments */
00116     a_dim1 = *lda;
00117     a_offset = 1 + a_dim1;
00118     a -= a_offset;
00119     --ipiv;
00120     --work;
00121 
00122     /* Function Body */
00123     *info = 0;
00124     upper = lsame_(uplo, "U");
00125     if (! upper && ! lsame_(uplo, "L")) {
00126         *info = -1;
00127     } else if (*n < 0) {
00128         *info = -2;
00129     } else if (*lda < max(1,*n)) {
00130         *info = -4;
00131     } else if (*anorm < 0.f) {
00132         *info = -6;
00133     }
00134     if (*info != 0) {
00135         i__1 = -(*info);
00136         xerbla_("CSYCON", &i__1);
00137         return 0;
00138     }
00139 
00140 /*     Quick return if possible */
00141 
00142     *rcond = 0.f;
00143     if (*n == 0) {
00144         *rcond = 1.f;
00145         return 0;
00146     } else if (*anorm <= 0.f) {
00147         return 0;
00148     }
00149 
00150 /*     Check that the diagonal matrix D is nonsingular. */
00151 
00152     if (upper) {
00153 
00154 /*        Upper triangular storage: examine D from bottom to top */
00155 
00156         for (i__ = *n; i__ >= 1; --i__) {
00157             i__1 = i__ + i__ * a_dim1;
00158             if (ipiv[i__] > 0 && (a[i__1].r == 0.f && a[i__1].i == 0.f)) {
00159                 return 0;
00160             }
00161 /* L10: */
00162         }
00163     } else {
00164 
00165 /*        Lower triangular storage: examine D from top to bottom. */
00166 
00167         i__1 = *n;
00168         for (i__ = 1; i__ <= i__1; ++i__) {
00169             i__2 = i__ + i__ * a_dim1;
00170             if (ipiv[i__] > 0 && (a[i__2].r == 0.f && a[i__2].i == 0.f)) {
00171                 return 0;
00172             }
00173 /* L20: */
00174         }
00175     }
00176 
00177 /*     Estimate the 1-norm of the inverse. */
00178 
00179     kase = 0;
00180 L30:
00181     clacn2_(n, &work[*n + 1], &work[1], &ainvnm, &kase, isave);
00182     if (kase != 0) {
00183 
00184 /*        Multiply by inv(L*D*L') or inv(U*D*U'). */
00185 
00186         csytrs_(uplo, n, &c__1, &a[a_offset], lda, &ipiv[1], &work[1], n, 
00187                 info);
00188         goto L30;
00189     }
00190 
00191 /*     Compute the estimate of the reciprocal condition number. */
00192 
00193     if (ainvnm != 0.f) {
00194         *rcond = 1.f / ainvnm / *anorm;
00195     }
00196 
00197     return 0;
00198 
00199 /*     End of CSYCON */
00200 
00201 } /* csycon_ */


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