clansy.c
Go to the documentation of this file.
00001 /* clansy.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 doublereal clansy_(char *norm, char *uplo, integer *n, complex *a, integer *
00021         lda, real *work)
00022 {
00023     /* System generated locals */
00024     integer a_dim1, a_offset, i__1, i__2;
00025     real ret_val, r__1, r__2;
00026 
00027     /* Builtin functions */
00028     double c_abs(complex *), sqrt(doublereal);
00029 
00030     /* Local variables */
00031     integer i__, j;
00032     real sum, absa, scale;
00033     extern logical lsame_(char *, char *);
00034     real value;
00035     extern /* Subroutine */ int classq_(integer *, complex *, integer *, real 
00036             *, real *);
00037 
00038 
00039 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00040 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00041 /*     November 2006 */
00042 
00043 /*     .. Scalar Arguments .. */
00044 /*     .. */
00045 /*     .. Array Arguments .. */
00046 /*     .. */
00047 
00048 /*  Purpose */
00049 /*  ======= */
00050 
00051 /*  CLANSY  returns the value of the one norm,  or the Frobenius norm, or */
00052 /*  the  infinity norm,  or the  element of  largest absolute value  of a */
00053 /*  complex symmetric matrix A. */
00054 
00055 /*  Description */
00056 /*  =========== */
00057 
00058 /*  CLANSY returns the value */
00059 
00060 /*     CLANSY = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
00061 /*              ( */
00062 /*              ( norm1(A),         NORM = '1', 'O' or 'o' */
00063 /*              ( */
00064 /*              ( normI(A),         NORM = 'I' or 'i' */
00065 /*              ( */
00066 /*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
00067 
00068 /*  where  norm1  denotes the  one norm of a matrix (maximum column sum), */
00069 /*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
00070 /*  normF  denotes the  Frobenius norm of a matrix (square root of sum of */
00071 /*  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm. */
00072 
00073 /*  Arguments */
00074 /*  ========= */
00075 
00076 /*  NORM    (input) CHARACTER*1 */
00077 /*          Specifies the value to be returned in CLANSY as described */
00078 /*          above. */
00079 
00080 /*  UPLO    (input) CHARACTER*1 */
00081 /*          Specifies whether the upper or lower triangular part of the */
00082 /*          symmetric matrix A is to be referenced. */
00083 /*          = 'U':  Upper triangular part of A is referenced */
00084 /*          = 'L':  Lower triangular part of A is referenced */
00085 
00086 /*  N       (input) INTEGER */
00087 /*          The order of the matrix A.  N >= 0.  When N = 0, CLANSY is */
00088 /*          set to zero. */
00089 
00090 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00091 /*          The symmetric matrix A.  If UPLO = 'U', the leading n by n */
00092 /*          upper triangular part of A contains the upper triangular part */
00093 /*          of the matrix A, and the strictly lower triangular part of A */
00094 /*          is not referenced.  If UPLO = 'L', the leading n by n lower */
00095 /*          triangular part of A contains the lower triangular part of */
00096 /*          the matrix A, and the strictly upper triangular part of A is */
00097 /*          not referenced. */
00098 
00099 /*  LDA     (input) INTEGER */
00100 /*          The leading dimension of the array A.  LDA >= max(N,1). */
00101 
00102 /*  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)), */
00103 /*          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
00104 /*          WORK is not referenced. */
00105 
00106 /* ===================================================================== */
00107 
00108 /*     .. Parameters .. */
00109 /*     .. */
00110 /*     .. Local Scalars .. */
00111 /*     .. */
00112 /*     .. External Functions .. */
00113 /*     .. */
00114 /*     .. External Subroutines .. */
00115 /*     .. */
00116 /*     .. Intrinsic Functions .. */
00117 /*     .. */
00118 /*     .. Executable Statements .. */
00119 
00120     /* Parameter adjustments */
00121     a_dim1 = *lda;
00122     a_offset = 1 + a_dim1;
00123     a -= a_offset;
00124     --work;
00125 
00126     /* Function Body */
00127     if (*n == 0) {
00128         value = 0.f;
00129     } else if (lsame_(norm, "M")) {
00130 
00131 /*        Find max(abs(A(i,j))). */
00132 
00133         value = 0.f;
00134         if (lsame_(uplo, "U")) {
00135             i__1 = *n;
00136             for (j = 1; j <= i__1; ++j) {
00137                 i__2 = j;
00138                 for (i__ = 1; i__ <= i__2; ++i__) {
00139 /* Computing MAX */
00140                     r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
00141                     value = dmax(r__1,r__2);
00142 /* L10: */
00143                 }
00144 /* L20: */
00145             }
00146         } else {
00147             i__1 = *n;
00148             for (j = 1; j <= i__1; ++j) {
00149                 i__2 = *n;
00150                 for (i__ = j; i__ <= i__2; ++i__) {
00151 /* Computing MAX */
00152                     r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
00153                     value = dmax(r__1,r__2);
00154 /* L30: */
00155                 }
00156 /* L40: */
00157             }
00158         }
00159     } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
00160 
00161 /*        Find normI(A) ( = norm1(A), since A is symmetric). */
00162 
00163         value = 0.f;
00164         if (lsame_(uplo, "U")) {
00165             i__1 = *n;
00166             for (j = 1; j <= i__1; ++j) {
00167                 sum = 0.f;
00168                 i__2 = j - 1;
00169                 for (i__ = 1; i__ <= i__2; ++i__) {
00170                     absa = c_abs(&a[i__ + j * a_dim1]);
00171                     sum += absa;
00172                     work[i__] += absa;
00173 /* L50: */
00174                 }
00175                 work[j] = sum + c_abs(&a[j + j * a_dim1]);
00176 /* L60: */
00177             }
00178             i__1 = *n;
00179             for (i__ = 1; i__ <= i__1; ++i__) {
00180 /* Computing MAX */
00181                 r__1 = value, r__2 = work[i__];
00182                 value = dmax(r__1,r__2);
00183 /* L70: */
00184             }
00185         } else {
00186             i__1 = *n;
00187             for (i__ = 1; i__ <= i__1; ++i__) {
00188                 work[i__] = 0.f;
00189 /* L80: */
00190             }
00191             i__1 = *n;
00192             for (j = 1; j <= i__1; ++j) {
00193                 sum = work[j] + c_abs(&a[j + j * a_dim1]);
00194                 i__2 = *n;
00195                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00196                     absa = c_abs(&a[i__ + j * a_dim1]);
00197                     sum += absa;
00198                     work[i__] += absa;
00199 /* L90: */
00200                 }
00201                 value = dmax(value,sum);
00202 /* L100: */
00203             }
00204         }
00205     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00206 
00207 /*        Find normF(A). */
00208 
00209         scale = 0.f;
00210         sum = 1.f;
00211         if (lsame_(uplo, "U")) {
00212             i__1 = *n;
00213             for (j = 2; j <= i__1; ++j) {
00214                 i__2 = j - 1;
00215                 classq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
00216 /* L110: */
00217             }
00218         } else {
00219             i__1 = *n - 1;
00220             for (j = 1; j <= i__1; ++j) {
00221                 i__2 = *n - j;
00222                 classq_(&i__2, &a[j + 1 + j * a_dim1], &c__1, &scale, &sum);
00223 /* L120: */
00224             }
00225         }
00226         sum *= 2;
00227         i__1 = *lda + 1;
00228         classq_(n, &a[a_offset], &i__1, &scale, &sum);
00229         value = scale * sqrt(sum);
00230     }
00231 
00232     ret_val = value;
00233     return ret_val;
00234 
00235 /*     End of CLANSY */
00236 
00237 } /* clansy_ */


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