clanhb.c
Go to the documentation of this file.
00001 /* clanhb.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 clanhb_(char *norm, char *uplo, integer *n, integer *k, complex *
00021         ab, integer *ldab, real *work)
00022 {
00023     /* System generated locals */
00024     integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4;
00025     real ret_val, r__1, r__2, r__3;
00026 
00027     /* Builtin functions */
00028     double c_abs(complex *), sqrt(doublereal);
00029 
00030     /* Local variables */
00031     integer i__, j, l;
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 /*  CLANHB  returns the value of the one norm,  or the Frobenius norm, or */
00052 /*  the  infinity norm,  or the element of  largest absolute value  of an */
00053 /*  n by n hermitian band matrix A,  with k super-diagonals. */
00054 
00055 /*  Description */
00056 /*  =========== */
00057 
00058 /*  CLANHB returns the value */
00059 
00060 /*     CLANHB = ( 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 CLANHB as described */
00078 /*          above. */
00079 
00080 /*  UPLO    (input) CHARACTER*1 */
00081 /*          Specifies whether the upper or lower triangular part of the */
00082 /*          band matrix A is supplied. */
00083 /*          = 'U':  Upper triangular */
00084 /*          = 'L':  Lower triangular */
00085 
00086 /*  N       (input) INTEGER */
00087 /*          The order of the matrix A.  N >= 0.  When N = 0, CLANHB is */
00088 /*          set to zero. */
00089 
00090 /*  K       (input) INTEGER */
00091 /*          The number of super-diagonals or sub-diagonals of the */
00092 /*          band matrix A.  K >= 0. */
00093 
00094 /*  AB      (input) COMPLEX array, dimension (LDAB,N) */
00095 /*          The upper or lower triangle of the hermitian band matrix A, */
00096 /*          stored in the first K+1 rows of AB.  The j-th column of A is */
00097 /*          stored in the j-th column of the array AB as follows: */
00098 /*          if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j; */
00099 /*          if UPLO = 'L', AB(1+i-j,j)   = A(i,j) for j<=i<=min(n,j+k). */
00100 /*          Note that the imaginary parts of the diagonal elements need */
00101 /*          not be set and are assumed to be zero. */
00102 
00103 /*  LDAB    (input) INTEGER */
00104 /*          The leading dimension of the array AB.  LDAB >= K+1. */
00105 
00106 /*  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)), */
00107 /*          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
00108 /*          WORK is not referenced. */
00109 
00110 /* ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. External Functions .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Intrinsic Functions .. */
00121 /*     .. */
00122 /*     .. Executable Statements .. */
00123 
00124     /* Parameter adjustments */
00125     ab_dim1 = *ldab;
00126     ab_offset = 1 + ab_dim1;
00127     ab -= ab_offset;
00128     --work;
00129 
00130     /* Function Body */
00131     if (*n == 0) {
00132         value = 0.f;
00133     } else if (lsame_(norm, "M")) {
00134 
00135 /*        Find max(abs(A(i,j))). */
00136 
00137         value = 0.f;
00138         if (lsame_(uplo, "U")) {
00139             i__1 = *n;
00140             for (j = 1; j <= i__1; ++j) {
00141 /* Computing MAX */
00142                 i__2 = *k + 2 - j;
00143                 i__3 = *k;
00144                 for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00145 /* Computing MAX */
00146                     r__1 = value, r__2 = c_abs(&ab[i__ + j * ab_dim1]);
00147                     value = dmax(r__1,r__2);
00148 /* L10: */
00149                 }
00150 /* Computing MAX */
00151                 i__3 = *k + 1 + j * ab_dim1;
00152                 r__2 = value, r__3 = (r__1 = ab[i__3].r, dabs(r__1));
00153                 value = dmax(r__2,r__3);
00154 /* L20: */
00155             }
00156         } else {
00157             i__1 = *n;
00158             for (j = 1; j <= i__1; ++j) {
00159 /* Computing MAX */
00160                 i__3 = j * ab_dim1 + 1;
00161                 r__2 = value, r__3 = (r__1 = ab[i__3].r, dabs(r__1));
00162                 value = dmax(r__2,r__3);
00163 /* Computing MIN */
00164                 i__2 = *n + 1 - j, i__4 = *k + 1;
00165                 i__3 = min(i__2,i__4);
00166                 for (i__ = 2; i__ <= i__3; ++i__) {
00167 /* Computing MAX */
00168                     r__1 = value, r__2 = c_abs(&ab[i__ + j * ab_dim1]);
00169                     value = dmax(r__1,r__2);
00170 /* L30: */
00171                 }
00172 /* L40: */
00173             }
00174         }
00175     } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
00176 
00177 /*        Find normI(A) ( = norm1(A), since A is hermitian). */
00178 
00179         value = 0.f;
00180         if (lsame_(uplo, "U")) {
00181             i__1 = *n;
00182             for (j = 1; j <= i__1; ++j) {
00183                 sum = 0.f;
00184                 l = *k + 1 - j;
00185 /* Computing MAX */
00186                 i__3 = 1, i__2 = j - *k;
00187                 i__4 = j - 1;
00188                 for (i__ = max(i__3,i__2); i__ <= i__4; ++i__) {
00189                     absa = c_abs(&ab[l + i__ + j * ab_dim1]);
00190                     sum += absa;
00191                     work[i__] += absa;
00192 /* L50: */
00193                 }
00194                 i__4 = *k + 1 + j * ab_dim1;
00195                 work[j] = sum + (r__1 = ab[i__4].r, dabs(r__1));
00196 /* L60: */
00197             }
00198             i__1 = *n;
00199             for (i__ = 1; i__ <= i__1; ++i__) {
00200 /* Computing MAX */
00201                 r__1 = value, r__2 = work[i__];
00202                 value = dmax(r__1,r__2);
00203 /* L70: */
00204             }
00205         } else {
00206             i__1 = *n;
00207             for (i__ = 1; i__ <= i__1; ++i__) {
00208                 work[i__] = 0.f;
00209 /* L80: */
00210             }
00211             i__1 = *n;
00212             for (j = 1; j <= i__1; ++j) {
00213                 i__4 = j * ab_dim1 + 1;
00214                 sum = work[j] + (r__1 = ab[i__4].r, dabs(r__1));
00215                 l = 1 - j;
00216 /* Computing MIN */
00217                 i__3 = *n, i__2 = j + *k;
00218                 i__4 = min(i__3,i__2);
00219                 for (i__ = j + 1; i__ <= i__4; ++i__) {
00220                     absa = c_abs(&ab[l + i__ + j * ab_dim1]);
00221                     sum += absa;
00222                     work[i__] += absa;
00223 /* L90: */
00224                 }
00225                 value = dmax(value,sum);
00226 /* L100: */
00227             }
00228         }
00229     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00230 
00231 /*        Find normF(A). */
00232 
00233         scale = 0.f;
00234         sum = 1.f;
00235         if (*k > 0) {
00236             if (lsame_(uplo, "U")) {
00237                 i__1 = *n;
00238                 for (j = 2; j <= i__1; ++j) {
00239 /* Computing MIN */
00240                     i__3 = j - 1;
00241                     i__4 = min(i__3,*k);
00242 /* Computing MAX */
00243                     i__2 = *k + 2 - j;
00244                     classq_(&i__4, &ab[max(i__2, 1)+ j * ab_dim1], &c__1, &
00245                             scale, &sum);
00246 /* L110: */
00247                 }
00248                 l = *k + 1;
00249             } else {
00250                 i__1 = *n - 1;
00251                 for (j = 1; j <= i__1; ++j) {
00252 /* Computing MIN */
00253                     i__3 = *n - j;
00254                     i__4 = min(i__3,*k);
00255                     classq_(&i__4, &ab[j * ab_dim1 + 2], &c__1, &scale, &sum);
00256 /* L120: */
00257                 }
00258                 l = 1;
00259             }
00260             sum *= 2;
00261         } else {
00262             l = 1;
00263         }
00264         i__1 = *n;
00265         for (j = 1; j <= i__1; ++j) {
00266             i__4 = l + j * ab_dim1;
00267             if (ab[i__4].r != 0.f) {
00268                 i__4 = l + j * ab_dim1;
00269                 absa = (r__1 = ab[i__4].r, dabs(r__1));
00270                 if (scale < absa) {
00271 /* Computing 2nd power */
00272                     r__1 = scale / absa;
00273                     sum = sum * (r__1 * r__1) + 1.f;
00274                     scale = absa;
00275                 } else {
00276 /* Computing 2nd power */
00277                     r__1 = absa / scale;
00278                     sum += r__1 * r__1;
00279                 }
00280             }
00281 /* L130: */
00282         }
00283         value = scale * sqrt(sum);
00284     }
00285 
00286     ret_val = value;
00287     return ret_val;
00288 
00289 /*     End of CLANHB */
00290 
00291 } /* clanhb_ */


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