zlangb.c
Go to the documentation of this file.
00001 /* zlangb.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 zlangb_(char *norm, integer *n, integer *kl, integer *ku, 
00021         doublecomplex *ab, integer *ldab, doublereal *work)
00022 {
00023     /* System generated locals */
00024     integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00025     doublereal ret_val, d__1, d__2;
00026 
00027     /* Builtin functions */
00028     double z_abs(doublecomplex *), sqrt(doublereal);
00029 
00030     /* Local variables */
00031     integer i__, j, k, l;
00032     doublereal sum, scale;
00033     extern logical lsame_(char *, char *);
00034     doublereal value;
00035     extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, 
00036              doublereal *, doublereal *);
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 /*  ZLANGB  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 band matrix  A,  with kl sub-diagonals and ku super-diagonals. */
00054 
00055 /*  Description */
00056 /*  =========== */
00057 
00058 /*  ZLANGB returns the value */
00059 
00060 /*     ZLANGB = ( 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 ZLANGB as described */
00078 /*          above. */
00079 
00080 /*  N       (input) INTEGER */
00081 /*          The order of the matrix A.  N >= 0.  When N = 0, ZLANGB is */
00082 /*          set to zero. */
00083 
00084 /*  KL      (input) INTEGER */
00085 /*          The number of sub-diagonals of the matrix A.  KL >= 0. */
00086 
00087 /*  KU      (input) INTEGER */
00088 /*          The number of super-diagonals of the matrix A.  KU >= 0. */
00089 
00090 /*  AB      (input) COMPLEX*16 array, dimension (LDAB,N) */
00091 /*          The band matrix A, stored in rows 1 to KL+KU+1.  The j-th */
00092 /*          column of A is stored in the j-th column of the array AB as */
00093 /*          follows: */
00094 /*          AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl). */
00095 
00096 /*  LDAB    (input) INTEGER */
00097 /*          The leading dimension of the array AB.  LDAB >= KL+KU+1. */
00098 
00099 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
00100 /*          where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
00101 /*          referenced. */
00102 
00103 /* ===================================================================== */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Functions .. */
00110 /*     .. */
00111 /*     .. External Subroutines .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117     /* Parameter adjustments */
00118     ab_dim1 = *ldab;
00119     ab_offset = 1 + ab_dim1;
00120     ab -= ab_offset;
00121     --work;
00122 
00123     /* Function Body */
00124     if (*n == 0) {
00125         value = 0.;
00126     } else if (lsame_(norm, "M")) {
00127 
00128 /*        Find max(abs(A(i,j))). */
00129 
00130         value = 0.;
00131         i__1 = *n;
00132         for (j = 1; j <= i__1; ++j) {
00133 /* Computing MAX */
00134             i__2 = *ku + 2 - j;
00135 /* Computing MIN */
00136             i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1;
00137             i__3 = min(i__4,i__5);
00138             for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00139 /* Computing MAX */
00140                 d__1 = value, d__2 = z_abs(&ab[i__ + j * ab_dim1]);
00141                 value = max(d__1,d__2);
00142 /* L10: */
00143             }
00144 /* L20: */
00145         }
00146     } else if (lsame_(norm, "O") || *(unsigned char *)
00147             norm == '1') {
00148 
00149 /*        Find norm1(A). */
00150 
00151         value = 0.;
00152         i__1 = *n;
00153         for (j = 1; j <= i__1; ++j) {
00154             sum = 0.;
00155 /* Computing MAX */
00156             i__3 = *ku + 2 - j;
00157 /* Computing MIN */
00158             i__4 = *n + *ku + 1 - j, i__5 = *kl + *ku + 1;
00159             i__2 = min(i__4,i__5);
00160             for (i__ = max(i__3,1); i__ <= i__2; ++i__) {
00161                 sum += z_abs(&ab[i__ + j * ab_dim1]);
00162 /* L30: */
00163             }
00164             value = max(value,sum);
00165 /* L40: */
00166         }
00167     } else if (lsame_(norm, "I")) {
00168 
00169 /*        Find normI(A). */
00170 
00171         i__1 = *n;
00172         for (i__ = 1; i__ <= i__1; ++i__) {
00173             work[i__] = 0.;
00174 /* L50: */
00175         }
00176         i__1 = *n;
00177         for (j = 1; j <= i__1; ++j) {
00178             k = *ku + 1 - j;
00179 /* Computing MAX */
00180             i__2 = 1, i__3 = j - *ku;
00181 /* Computing MIN */
00182             i__5 = *n, i__6 = j + *kl;
00183             i__4 = min(i__5,i__6);
00184             for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00185                 work[i__] += z_abs(&ab[k + i__ + j * ab_dim1]);
00186 /* L60: */
00187             }
00188 /* L70: */
00189         }
00190         value = 0.;
00191         i__1 = *n;
00192         for (i__ = 1; i__ <= i__1; ++i__) {
00193 /* Computing MAX */
00194             d__1 = value, d__2 = work[i__];
00195             value = max(d__1,d__2);
00196 /* L80: */
00197         }
00198     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00199 
00200 /*        Find normF(A). */
00201 
00202         scale = 0.;
00203         sum = 1.;
00204         i__1 = *n;
00205         for (j = 1; j <= i__1; ++j) {
00206 /* Computing MAX */
00207             i__4 = 1, i__2 = j - *ku;
00208             l = max(i__4,i__2);
00209             k = *ku + 1 - j + l;
00210 /* Computing MIN */
00211             i__2 = *n, i__3 = j + *kl;
00212             i__4 = min(i__2,i__3) - l + 1;
00213             zlassq_(&i__4, &ab[k + j * ab_dim1], &c__1, &scale, &sum);
00214 /* L90: */
00215         }
00216         value = scale * sqrt(sum);
00217     }
00218 
00219     ret_val = value;
00220     return ret_val;
00221 
00222 /*     End of ZLANGB */
00223 
00224 } /* zlangb_ */


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