clanhs.c
Go to the documentation of this file.
00001 /* clanhs.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 clanhs_(char *norm, integer *n, complex *a, integer *lda, real *
00021         work)
00022 {
00023     /* System generated locals */
00024     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
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, 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 /*  CLANHS  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 /*  Hessenberg matrix A. */
00054 
00055 /*  Description */
00056 /*  =========== */
00057 
00058 /*  CLANHS returns the value */
00059 
00060 /*     CLANHS = ( 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 CLANHS as described */
00078 /*          above. */
00079 
00080 /*  N       (input) INTEGER */
00081 /*          The order of the matrix A.  N >= 0.  When N = 0, CLANHS is */
00082 /*          set to zero. */
00083 
00084 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00085 /*          The n by n upper Hessenberg matrix A; the part of A below the */
00086 /*          first sub-diagonal is not referenced. */
00087 
00088 /*  LDA     (input) INTEGER */
00089 /*          The leading dimension of the array A.  LDA >= max(N,1). */
00090 
00091 /*  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)), */
00092 /*          where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
00093 /*          referenced. */
00094 
00095 /* ===================================================================== */
00096 
00097 /*     .. Parameters .. */
00098 /*     .. */
00099 /*     .. Local Scalars .. */
00100 /*     .. */
00101 /*     .. External Functions .. */
00102 /*     .. */
00103 /*     .. External Subroutines .. */
00104 /*     .. */
00105 /*     .. Intrinsic Functions .. */
00106 /*     .. */
00107 /*     .. Executable Statements .. */
00108 
00109     /* Parameter adjustments */
00110     a_dim1 = *lda;
00111     a_offset = 1 + a_dim1;
00112     a -= a_offset;
00113     --work;
00114 
00115     /* Function Body */
00116     if (*n == 0) {
00117         value = 0.f;
00118     } else if (lsame_(norm, "M")) {
00119 
00120 /*        Find max(abs(A(i,j))). */
00121 
00122         value = 0.f;
00123         i__1 = *n;
00124         for (j = 1; j <= i__1; ++j) {
00125 /* Computing MIN */
00126             i__3 = *n, i__4 = j + 1;
00127             i__2 = min(i__3,i__4);
00128             for (i__ = 1; i__ <= i__2; ++i__) {
00129 /* Computing MAX */
00130                 r__1 = value, r__2 = c_abs(&a[i__ + j * a_dim1]);
00131                 value = dmax(r__1,r__2);
00132 /* L10: */
00133             }
00134 /* L20: */
00135         }
00136     } else if (lsame_(norm, "O") || *(unsigned char *)
00137             norm == '1') {
00138 
00139 /*        Find norm1(A). */
00140 
00141         value = 0.f;
00142         i__1 = *n;
00143         for (j = 1; j <= i__1; ++j) {
00144             sum = 0.f;
00145 /* Computing MIN */
00146             i__3 = *n, i__4 = j + 1;
00147             i__2 = min(i__3,i__4);
00148             for (i__ = 1; i__ <= i__2; ++i__) {
00149                 sum += c_abs(&a[i__ + j * a_dim1]);
00150 /* L30: */
00151             }
00152             value = dmax(value,sum);
00153 /* L40: */
00154         }
00155     } else if (lsame_(norm, "I")) {
00156 
00157 /*        Find normI(A). */
00158 
00159         i__1 = *n;
00160         for (i__ = 1; i__ <= i__1; ++i__) {
00161             work[i__] = 0.f;
00162 /* L50: */
00163         }
00164         i__1 = *n;
00165         for (j = 1; j <= i__1; ++j) {
00166 /* Computing MIN */
00167             i__3 = *n, i__4 = j + 1;
00168             i__2 = min(i__3,i__4);
00169             for (i__ = 1; i__ <= i__2; ++i__) {
00170                 work[i__] += c_abs(&a[i__ + j * a_dim1]);
00171 /* L60: */
00172             }
00173 /* L70: */
00174         }
00175         value = 0.f;
00176         i__1 = *n;
00177         for (i__ = 1; i__ <= i__1; ++i__) {
00178 /* Computing MAX */
00179             r__1 = value, r__2 = work[i__];
00180             value = dmax(r__1,r__2);
00181 /* L80: */
00182         }
00183     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00184 
00185 /*        Find normF(A). */
00186 
00187         scale = 0.f;
00188         sum = 1.f;
00189         i__1 = *n;
00190         for (j = 1; j <= i__1; ++j) {
00191 /* Computing MIN */
00192             i__3 = *n, i__4 = j + 1;
00193             i__2 = min(i__3,i__4);
00194             classq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
00195 /* L90: */
00196         }
00197         value = scale * sqrt(sum);
00198     }
00199 
00200     ret_val = value;
00201     return ret_val;
00202 
00203 /*     End of CLANHS */
00204 
00205 } /* clanhs_ */


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