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


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