dlantr.c
Go to the documentation of this file.
00001 /* dlantr.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 dlantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, 
00021          doublereal *a, integer *lda, doublereal *work)
00022 {
00023     /* System generated locals */
00024     integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00025     doublereal ret_val, d__1, d__2, d__3;
00026 
00027     /* Builtin functions */
00028     double sqrt(doublereal);
00029 
00030     /* Local variables */
00031     integer i__, j;
00032     doublereal sum, scale;
00033     logical udiag;
00034     extern logical lsame_(char *, char *);
00035     doublereal value;
00036     extern /* Subroutine */ int dlassq_(integer *, doublereal *, 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 /*  DLANTR  returns the value of the one norm,  or the Frobenius norm, or */
00053 /*  the  infinity norm,  or the  element of  largest absolute value  of a */
00054 /*  trapezoidal or triangular matrix A. */
00055 
00056 /*  Description */
00057 /*  =========== */
00058 
00059 /*  DLANTR returns the value */
00060 
00061 /*     DLANTR = ( 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 DLANTR as described */
00079 /*          above. */
00080 
00081 /*  UPLO    (input) CHARACTER*1 */
00082 /*          Specifies whether the matrix A is upper or lower trapezoidal. */
00083 /*          = 'U':  Upper trapezoidal */
00084 /*          = 'L':  Lower trapezoidal */
00085 /*          Note that A is triangular instead of trapezoidal if M = N. */
00086 
00087 /*  DIAG    (input) CHARACTER*1 */
00088 /*          Specifies whether or not the matrix A has unit diagonal. */
00089 /*          = 'N':  Non-unit diagonal */
00090 /*          = 'U':  Unit diagonal */
00091 
00092 /*  M       (input) INTEGER */
00093 /*          The number of rows of the matrix A.  M >= 0, and if */
00094 /*          UPLO = 'U', M <= N.  When M = 0, DLANTR is set to zero. */
00095 
00096 /*  N       (input) INTEGER */
00097 /*          The number of columns of the matrix A.  N >= 0, and if */
00098 /*          UPLO = 'L', N <= M.  When N = 0, DLANTR is set to zero. */
00099 
00100 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00101 /*          The trapezoidal matrix A (A is triangular if M = N). */
00102 /*          If UPLO = 'U', the leading m by n upper trapezoidal part of */
00103 /*          the array A contains the upper trapezoidal matrix, and the */
00104 /*          strictly lower triangular part of A is not referenced. */
00105 /*          If UPLO = 'L', the leading m by n lower trapezoidal part of */
00106 /*          the array A contains the lower trapezoidal matrix, and the */
00107 /*          strictly upper triangular part of A is not referenced.  Note */
00108 /*          that when DIAG = 'U', the diagonal elements of A are not */
00109 /*          referenced and are assumed to be one. */
00110 
00111 /*  LDA     (input) INTEGER */
00112 /*          The leading dimension of the array A.  LDA >= max(M,1). */
00113 
00114 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
00115 /*          where LWORK >= M when NORM = 'I'; otherwise, WORK is not */
00116 /*          referenced. */
00117 
00118 /* ===================================================================== */
00119 
00120 /*     .. Parameters .. */
00121 /*     .. */
00122 /*     .. Local Scalars .. */
00123 /*     .. */
00124 /*     .. External Subroutines .. */
00125 /*     .. */
00126 /*     .. External Functions .. */
00127 /*     .. */
00128 /*     .. Intrinsic Functions .. */
00129 /*     .. */
00130 /*     .. Executable Statements .. */
00131 
00132     /* Parameter adjustments */
00133     a_dim1 = *lda;
00134     a_offset = 1 + a_dim1;
00135     a -= a_offset;
00136     --work;
00137 
00138     /* Function Body */
00139     if (min(*m,*n) == 0) {
00140         value = 0.;
00141     } else if (lsame_(norm, "M")) {
00142 
00143 /*        Find max(abs(A(i,j))). */
00144 
00145         if (lsame_(diag, "U")) {
00146             value = 1.;
00147             if (lsame_(uplo, "U")) {
00148                 i__1 = *n;
00149                 for (j = 1; j <= i__1; ++j) {
00150 /* Computing MIN */
00151                     i__3 = *m, i__4 = j - 1;
00152                     i__2 = min(i__3,i__4);
00153                     for (i__ = 1; i__ <= i__2; ++i__) {
00154 /* Computing MAX */
00155                         d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
00156                                 d__1));
00157                         value = max(d__2,d__3);
00158 /* L10: */
00159                     }
00160 /* L20: */
00161                 }
00162             } else {
00163                 i__1 = *n;
00164                 for (j = 1; j <= i__1; ++j) {
00165                     i__2 = *m;
00166                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00167 /* Computing MAX */
00168                         d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
00169                                 d__1));
00170                         value = max(d__2,d__3);
00171 /* L30: */
00172                     }
00173 /* L40: */
00174                 }
00175             }
00176         } else {
00177             value = 0.;
00178             if (lsame_(uplo, "U")) {
00179                 i__1 = *n;
00180                 for (j = 1; j <= i__1; ++j) {
00181                     i__2 = min(*m,j);
00182                     for (i__ = 1; i__ <= i__2; ++i__) {
00183 /* Computing MAX */
00184                         d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
00185                                 d__1));
00186                         value = max(d__2,d__3);
00187 /* L50: */
00188                     }
00189 /* L60: */
00190                 }
00191             } else {
00192                 i__1 = *n;
00193                 for (j = 1; j <= i__1; ++j) {
00194                     i__2 = *m;
00195                     for (i__ = j; i__ <= i__2; ++i__) {
00196 /* Computing MAX */
00197                         d__2 = value, d__3 = (d__1 = a[i__ + j * a_dim1], abs(
00198                                 d__1));
00199                         value = max(d__2,d__3);
00200 /* L70: */
00201                     }
00202 /* L80: */
00203                 }
00204             }
00205         }
00206     } else if (lsame_(norm, "O") || *(unsigned char *)
00207             norm == '1') {
00208 
00209 /*        Find norm1(A). */
00210 
00211         value = 0.;
00212         udiag = lsame_(diag, "U");
00213         if (lsame_(uplo, "U")) {
00214             i__1 = *n;
00215             for (j = 1; j <= i__1; ++j) {
00216                 if (udiag && j <= *m) {
00217                     sum = 1.;
00218                     i__2 = j - 1;
00219                     for (i__ = 1; i__ <= i__2; ++i__) {
00220                         sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00221 /* L90: */
00222                     }
00223                 } else {
00224                     sum = 0.;
00225                     i__2 = min(*m,j);
00226                     for (i__ = 1; i__ <= i__2; ++i__) {
00227                         sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00228 /* L100: */
00229                     }
00230                 }
00231                 value = max(value,sum);
00232 /* L110: */
00233             }
00234         } else {
00235             i__1 = *n;
00236             for (j = 1; j <= i__1; ++j) {
00237                 if (udiag) {
00238                     sum = 1.;
00239                     i__2 = *m;
00240                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00241                         sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00242 /* L120: */
00243                     }
00244                 } else {
00245                     sum = 0.;
00246                     i__2 = *m;
00247                     for (i__ = j; i__ <= i__2; ++i__) {
00248                         sum += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00249 /* L130: */
00250                     }
00251                 }
00252                 value = max(value,sum);
00253 /* L140: */
00254             }
00255         }
00256     } else if (lsame_(norm, "I")) {
00257 
00258 /*        Find normI(A). */
00259 
00260         if (lsame_(uplo, "U")) {
00261             if (lsame_(diag, "U")) {
00262                 i__1 = *m;
00263                 for (i__ = 1; i__ <= i__1; ++i__) {
00264                     work[i__] = 1.;
00265 /* L150: */
00266                 }
00267                 i__1 = *n;
00268                 for (j = 1; j <= i__1; ++j) {
00269 /* Computing MIN */
00270                     i__3 = *m, i__4 = j - 1;
00271                     i__2 = min(i__3,i__4);
00272                     for (i__ = 1; i__ <= i__2; ++i__) {
00273                         work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00274 /* L160: */
00275                     }
00276 /* L170: */
00277                 }
00278             } else {
00279                 i__1 = *m;
00280                 for (i__ = 1; i__ <= i__1; ++i__) {
00281                     work[i__] = 0.;
00282 /* L180: */
00283                 }
00284                 i__1 = *n;
00285                 for (j = 1; j <= i__1; ++j) {
00286                     i__2 = min(*m,j);
00287                     for (i__ = 1; i__ <= i__2; ++i__) {
00288                         work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00289 /* L190: */
00290                     }
00291 /* L200: */
00292                 }
00293             }
00294         } else {
00295             if (lsame_(diag, "U")) {
00296                 i__1 = *n;
00297                 for (i__ = 1; i__ <= i__1; ++i__) {
00298                     work[i__] = 1.;
00299 /* L210: */
00300                 }
00301                 i__1 = *m;
00302                 for (i__ = *n + 1; i__ <= i__1; ++i__) {
00303                     work[i__] = 0.;
00304 /* L220: */
00305                 }
00306                 i__1 = *n;
00307                 for (j = 1; j <= i__1; ++j) {
00308                     i__2 = *m;
00309                     for (i__ = j + 1; i__ <= i__2; ++i__) {
00310                         work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00311 /* L230: */
00312                     }
00313 /* L240: */
00314                 }
00315             } else {
00316                 i__1 = *m;
00317                 for (i__ = 1; i__ <= i__1; ++i__) {
00318                     work[i__] = 0.;
00319 /* L250: */
00320                 }
00321                 i__1 = *n;
00322                 for (j = 1; j <= i__1; ++j) {
00323                     i__2 = *m;
00324                     for (i__ = j; i__ <= i__2; ++i__) {
00325                         work[i__] += (d__1 = a[i__ + j * a_dim1], abs(d__1));
00326 /* L260: */
00327                     }
00328 /* L270: */
00329                 }
00330             }
00331         }
00332         value = 0.;
00333         i__1 = *m;
00334         for (i__ = 1; i__ <= i__1; ++i__) {
00335 /* Computing MAX */
00336             d__1 = value, d__2 = work[i__];
00337             value = max(d__1,d__2);
00338 /* L280: */
00339         }
00340     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00341 
00342 /*        Find normF(A). */
00343 
00344         if (lsame_(uplo, "U")) {
00345             if (lsame_(diag, "U")) {
00346                 scale = 1.;
00347                 sum = (doublereal) min(*m,*n);
00348                 i__1 = *n;
00349                 for (j = 2; j <= i__1; ++j) {
00350 /* Computing MIN */
00351                     i__3 = *m, i__4 = j - 1;
00352                     i__2 = min(i__3,i__4);
00353                     dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
00354 /* L290: */
00355                 }
00356             } else {
00357                 scale = 0.;
00358                 sum = 1.;
00359                 i__1 = *n;
00360                 for (j = 1; j <= i__1; ++j) {
00361                     i__2 = min(*m,j);
00362                     dlassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
00363 /* L300: */
00364                 }
00365             }
00366         } else {
00367             if (lsame_(diag, "U")) {
00368                 scale = 1.;
00369                 sum = (doublereal) min(*m,*n);
00370                 i__1 = *n;
00371                 for (j = 1; j <= i__1; ++j) {
00372                     i__2 = *m - j;
00373 /* Computing MIN */
00374                     i__3 = *m, i__4 = j + 1;
00375                     dlassq_(&i__2, &a[min(i__3, i__4)+ j * a_dim1], &c__1, &
00376                             scale, &sum);
00377 /* L310: */
00378                 }
00379             } else {
00380                 scale = 0.;
00381                 sum = 1.;
00382                 i__1 = *n;
00383                 for (j = 1; j <= i__1; ++j) {
00384                     i__2 = *m - j + 1;
00385                     dlassq_(&i__2, &a[j + j * a_dim1], &c__1, &scale, &sum);
00386 /* L320: */
00387                 }
00388             }
00389         }
00390         value = scale * sqrt(sum);
00391     }
00392 
00393     ret_val = value;
00394     return ret_val;
00395 
00396 /*     End of DLANTR */
00397 
00398 } /* dlantr_ */


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