zlantb.c
Go to the documentation of this file.
00001 /* zlantb.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 zlantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, 
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;
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, l;
00032     doublereal sum, scale;
00033     logical udiag;
00034     extern logical lsame_(char *, char *);
00035     doublereal value;
00036     extern /* Subroutine */ int zlassq_(integer *, doublecomplex *, integer *, 
00037              doublereal *, doublereal *);
00038 
00039 
00040 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00041 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00042 /*     November 2006 */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  ZLANTB  returns the value of the one norm,  or the Frobenius norm, or */
00053 /*  the  infinity norm,  or the element of  largest absolute value  of an */
00054 /*  n by n triangular band matrix A,  with ( k + 1 ) diagonals. */
00055 
00056 /*  Description */
00057 /*  =========== */
00058 
00059 /*  ZLANTB returns the value */
00060 
00061 /*     ZLANTB = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
00062 /*              ( */
00063 /*              ( norm1(A),         NORM = '1', 'O' or 'o' */
00064 /*              ( */
00065 /*              ( normI(A),         NORM = 'I' or 'i' */
00066 /*              ( */
00067 /*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
00068 
00069 /*  where  norm1  denotes the  one norm of a matrix (maximum column sum), */
00070 /*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
00071 /*  normF  denotes the  Frobenius norm of a matrix (square root of sum of */
00072 /*  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm. */
00073 
00074 /*  Arguments */
00075 /*  ========= */
00076 
00077 /*  NORM    (input) CHARACTER*1 */
00078 /*          Specifies the value to be returned in ZLANTB as described */
00079 /*          above. */
00080 
00081 /*  UPLO    (input) CHARACTER*1 */
00082 /*          Specifies whether the matrix A is upper or lower triangular. */
00083 /*          = 'U':  Upper triangular */
00084 /*          = 'L':  Lower triangular */
00085 
00086 /*  DIAG    (input) CHARACTER*1 */
00087 /*          Specifies whether or not the matrix A is unit triangular. */
00088 /*          = 'N':  Non-unit triangular */
00089 /*          = 'U':  Unit triangular */
00090 
00091 /*  N       (input) INTEGER */
00092 /*          The order of the matrix A.  N >= 0.  When N = 0, ZLANTB is */
00093 /*          set to zero. */
00094 
00095 /*  K       (input) INTEGER */
00096 /*          The number of super-diagonals of the matrix A if UPLO = 'U', */
00097 /*          or the number of sub-diagonals of the matrix A if UPLO = 'L'. */
00098 /*          K >= 0. */
00099 
00100 /*  AB      (input) COMPLEX*16 array, dimension (LDAB,N) */
00101 /*          The upper or lower triangular band matrix A, stored in the */
00102 /*          first k+1 rows of AB.  The j-th column of A is stored */
00103 /*          in the j-th column of the array AB as follows: */
00104 /*          if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j; */
00105 /*          if UPLO = 'L', AB(1+i-j,j)   = A(i,j) for j<=i<=min(n,j+k). */
00106 /*          Note that when DIAG = 'U', the elements of the array AB */
00107 /*          corresponding to the diagonal elements of the matrix A are */
00108 /*          not referenced, but are assumed to be one. */
00109 
00110 /*  LDAB    (input) INTEGER */
00111 /*          The leading dimension of the array AB.  LDAB >= K+1. */
00112 
00113 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
00114 /*          where LWORK >= N when NORM = 'I'; otherwise, WORK is not */
00115 /*          referenced. */
00116 
00117 /* ===================================================================== */
00118 
00119 /*     .. Parameters .. */
00120 /*     .. */
00121 /*     .. Local Scalars .. */
00122 /*     .. */
00123 /*     .. External Functions .. */
00124 /*     .. */
00125 /*     .. External Subroutines .. */
00126 /*     .. */
00127 /*     .. Intrinsic Functions .. */
00128 /*     .. */
00129 /*     .. Executable Statements .. */
00130 
00131     /* Parameter adjustments */
00132     ab_dim1 = *ldab;
00133     ab_offset = 1 + ab_dim1;
00134     ab -= ab_offset;
00135     --work;
00136 
00137     /* Function Body */
00138     if (*n == 0) {
00139         value = 0.;
00140     } else if (lsame_(norm, "M")) {
00141 
00142 /*        Find max(abs(A(i,j))). */
00143 
00144         if (lsame_(diag, "U")) {
00145             value = 1.;
00146             if (lsame_(uplo, "U")) {
00147                 i__1 = *n;
00148                 for (j = 1; j <= i__1; ++j) {
00149 /* Computing MAX */
00150                     i__2 = *k + 2 - j;
00151                     i__3 = *k;
00152                     for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00153 /* Computing MAX */
00154                         d__1 = value, d__2 = z_abs(&ab[i__ + j * ab_dim1]);
00155                         value = max(d__1,d__2);
00156 /* L10: */
00157                     }
00158 /* L20: */
00159                 }
00160             } else {
00161                 i__1 = *n;
00162                 for (j = 1; j <= i__1; ++j) {
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                         d__1 = value, d__2 = z_abs(&ab[i__ + j * ab_dim1]);
00169                         value = max(d__1,d__2);
00170 /* L30: */
00171                     }
00172 /* L40: */
00173                 }
00174             }
00175         } else {
00176             value = 0.;
00177             if (lsame_(uplo, "U")) {
00178                 i__1 = *n;
00179                 for (j = 1; j <= i__1; ++j) {
00180 /* Computing MAX */
00181                     i__3 = *k + 2 - j;
00182                     i__2 = *k + 1;
00183                     for (i__ = max(i__3,1); i__ <= i__2; ++i__) {
00184 /* Computing MAX */
00185                         d__1 = value, d__2 = z_abs(&ab[i__ + j * ab_dim1]);
00186                         value = max(d__1,d__2);
00187 /* L50: */
00188                     }
00189 /* L60: */
00190                 }
00191             } else {
00192                 i__1 = *n;
00193                 for (j = 1; j <= i__1; ++j) {
00194 /* Computing MIN */
00195                     i__3 = *n + 1 - j, i__4 = *k + 1;
00196                     i__2 = min(i__3,i__4);
00197                     for (i__ = 1; i__ <= i__2; ++i__) {
00198 /* Computing MAX */
00199                         d__1 = value, d__2 = z_abs(&ab[i__ + j * ab_dim1]);
00200                         value = max(d__1,d__2);
00201 /* L70: */
00202                     }
00203 /* L80: */
00204                 }
00205             }
00206         }
00207     } else if (lsame_(norm, "O") || *(unsigned char *)
00208             norm == '1') {
00209 
00210 /*        Find norm1(A). */
00211 
00212         value = 0.;
00213         udiag = lsame_(diag, "U");
00214         if (lsame_(uplo, "U")) {
00215             i__1 = *n;
00216             for (j = 1; j <= i__1; ++j) {
00217                 if (udiag) {
00218                     sum = 1.;
00219 /* Computing MAX */
00220                     i__2 = *k + 2 - j;
00221                     i__3 = *k;
00222                     for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00223                         sum += z_abs(&ab[i__ + j * ab_dim1]);
00224 /* L90: */
00225                     }
00226                 } else {
00227                     sum = 0.;
00228 /* Computing MAX */
00229                     i__3 = *k + 2 - j;
00230                     i__2 = *k + 1;
00231                     for (i__ = max(i__3,1); i__ <= i__2; ++i__) {
00232                         sum += z_abs(&ab[i__ + j * ab_dim1]);
00233 /* L100: */
00234                     }
00235                 }
00236                 value = max(value,sum);
00237 /* L110: */
00238             }
00239         } else {
00240             i__1 = *n;
00241             for (j = 1; j <= i__1; ++j) {
00242                 if (udiag) {
00243                     sum = 1.;
00244 /* Computing MIN */
00245                     i__3 = *n + 1 - j, i__4 = *k + 1;
00246                     i__2 = min(i__3,i__4);
00247                     for (i__ = 2; i__ <= i__2; ++i__) {
00248                         sum += z_abs(&ab[i__ + j * ab_dim1]);
00249 /* L120: */
00250                     }
00251                 } else {
00252                     sum = 0.;
00253 /* Computing MIN */
00254                     i__3 = *n + 1 - j, i__4 = *k + 1;
00255                     i__2 = min(i__3,i__4);
00256                     for (i__ = 1; i__ <= i__2; ++i__) {
00257                         sum += z_abs(&ab[i__ + j * ab_dim1]);
00258 /* L130: */
00259                     }
00260                 }
00261                 value = max(value,sum);
00262 /* L140: */
00263             }
00264         }
00265     } else if (lsame_(norm, "I")) {
00266 
00267 /*        Find normI(A). */
00268 
00269         value = 0.;
00270         if (lsame_(uplo, "U")) {
00271             if (lsame_(diag, "U")) {
00272                 i__1 = *n;
00273                 for (i__ = 1; i__ <= i__1; ++i__) {
00274                     work[i__] = 1.;
00275 /* L150: */
00276                 }
00277                 i__1 = *n;
00278                 for (j = 1; j <= i__1; ++j) {
00279                     l = *k + 1 - j;
00280 /* Computing MAX */
00281                     i__2 = 1, i__3 = j - *k;
00282                     i__4 = j - 1;
00283                     for (i__ = max(i__2,i__3); i__ <= i__4; ++i__) {
00284                         work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]);
00285 /* L160: */
00286                     }
00287 /* L170: */
00288                 }
00289             } else {
00290                 i__1 = *n;
00291                 for (i__ = 1; i__ <= i__1; ++i__) {
00292                     work[i__] = 0.;
00293 /* L180: */
00294                 }
00295                 i__1 = *n;
00296                 for (j = 1; j <= i__1; ++j) {
00297                     l = *k + 1 - j;
00298 /* Computing MAX */
00299                     i__4 = 1, i__2 = j - *k;
00300                     i__3 = j;
00301                     for (i__ = max(i__4,i__2); i__ <= i__3; ++i__) {
00302                         work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]);
00303 /* L190: */
00304                     }
00305 /* L200: */
00306                 }
00307             }
00308         } else {
00309             if (lsame_(diag, "U")) {
00310                 i__1 = *n;
00311                 for (i__ = 1; i__ <= i__1; ++i__) {
00312                     work[i__] = 1.;
00313 /* L210: */
00314                 }
00315                 i__1 = *n;
00316                 for (j = 1; j <= i__1; ++j) {
00317                     l = 1 - j;
00318 /* Computing MIN */
00319                     i__4 = *n, i__2 = j + *k;
00320                     i__3 = min(i__4,i__2);
00321                     for (i__ = j + 1; i__ <= i__3; ++i__) {
00322                         work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]);
00323 /* L220: */
00324                     }
00325 /* L230: */
00326                 }
00327             } else {
00328                 i__1 = *n;
00329                 for (i__ = 1; i__ <= i__1; ++i__) {
00330                     work[i__] = 0.;
00331 /* L240: */
00332                 }
00333                 i__1 = *n;
00334                 for (j = 1; j <= i__1; ++j) {
00335                     l = 1 - j;
00336 /* Computing MIN */
00337                     i__4 = *n, i__2 = j + *k;
00338                     i__3 = min(i__4,i__2);
00339                     for (i__ = j; i__ <= i__3; ++i__) {
00340                         work[i__] += z_abs(&ab[l + i__ + j * ab_dim1]);
00341 /* L250: */
00342                     }
00343 /* L260: */
00344                 }
00345             }
00346         }
00347         i__1 = *n;
00348         for (i__ = 1; i__ <= i__1; ++i__) {
00349 /* Computing MAX */
00350             d__1 = value, d__2 = work[i__];
00351             value = max(d__1,d__2);
00352 /* L270: */
00353         }
00354     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00355 
00356 /*        Find normF(A). */
00357 
00358         if (lsame_(uplo, "U")) {
00359             if (lsame_(diag, "U")) {
00360                 scale = 1.;
00361                 sum = (doublereal) (*n);
00362                 if (*k > 0) {
00363                     i__1 = *n;
00364                     for (j = 2; j <= i__1; ++j) {
00365 /* Computing MIN */
00366                         i__4 = j - 1;
00367                         i__3 = min(i__4,*k);
00368 /* Computing MAX */
00369                         i__2 = *k + 2 - j;
00370                         zlassq_(&i__3, &ab[max(i__2, 1)+ j * ab_dim1], &c__1, 
00371                                 &scale, &sum);
00372 /* L280: */
00373                     }
00374                 }
00375             } else {
00376                 scale = 0.;
00377                 sum = 1.;
00378                 i__1 = *n;
00379                 for (j = 1; j <= i__1; ++j) {
00380 /* Computing MIN */
00381                     i__4 = j, i__2 = *k + 1;
00382                     i__3 = min(i__4,i__2);
00383 /* Computing MAX */
00384                     i__5 = *k + 2 - j;
00385                     zlassq_(&i__3, &ab[max(i__5, 1)+ j * ab_dim1], &c__1, &
00386                             scale, &sum);
00387 /* L290: */
00388                 }
00389             }
00390         } else {
00391             if (lsame_(diag, "U")) {
00392                 scale = 1.;
00393                 sum = (doublereal) (*n);
00394                 if (*k > 0) {
00395                     i__1 = *n - 1;
00396                     for (j = 1; j <= i__1; ++j) {
00397 /* Computing MIN */
00398                         i__4 = *n - j;
00399                         i__3 = min(i__4,*k);
00400                         zlassq_(&i__3, &ab[j * ab_dim1 + 2], &c__1, &scale, &
00401                                 sum);
00402 /* L300: */
00403                     }
00404                 }
00405             } else {
00406                 scale = 0.;
00407                 sum = 1.;
00408                 i__1 = *n;
00409                 for (j = 1; j <= i__1; ++j) {
00410 /* Computing MIN */
00411                     i__4 = *n - j + 1, i__2 = *k + 1;
00412                     i__3 = min(i__4,i__2);
00413                     zlassq_(&i__3, &ab[j * ab_dim1 + 1], &c__1, &scale, &sum);
00414 /* L310: */
00415                 }
00416             }
00417         }
00418         value = scale * sqrt(sum);
00419     }
00420 
00421     ret_val = value;
00422     return ret_val;
00423 
00424 /*     End of ZLANTB */
00425 
00426 } /* zlantb_ */


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