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


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