dlansp.c
Go to the documentation of this file.
00001 /* dlansp.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 dlansp_(char *norm, char *uplo, integer *n, doublereal *ap, 
00021         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, absa, scale;
00033     extern logical lsame_(char *, char *);
00034     doublereal value;
00035     extern /* Subroutine */ int dlassq_(integer *, doublereal *, 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 /*  DLANSP  returns the value of the one norm,  or the Frobenius norm, or */
00052 /*  the  infinity norm,  or the  element of  largest absolute value  of a */
00053 /*  real symmetric matrix A,  supplied in packed form. */
00054 
00055 /*  Description */
00056 /*  =========== */
00057 
00058 /*  DLANSP returns the value */
00059 
00060 /*     DLANSP = ( 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 DLANSP as described */
00078 /*          above. */
00079 
00080 /*  UPLO    (input) CHARACTER*1 */
00081 /*          Specifies whether the upper or lower triangular part of the */
00082 /*          symmetric matrix A is supplied. */
00083 /*          = 'U':  Upper triangular part of A is supplied */
00084 /*          = 'L':  Lower triangular part of A is supplied */
00085 
00086 /*  N       (input) INTEGER */
00087 /*          The order of the matrix A.  N >= 0.  When N = 0, DLANSP is */
00088 /*          set to zero. */
00089 
00090 /*  AP      (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00091 /*          The upper or lower triangle of the symmetric matrix A, packed */
00092 /*          columnwise in a linear array.  The j-th column of A is stored */
00093 /*          in the array AP as follows: */
00094 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
00095 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
00096 
00097 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)), */
00098 /*          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
00099 /*          WORK is not referenced. */
00100 
00101 /* ===================================================================== */
00102 
00103 /*     .. Parameters .. */
00104 /*     .. */
00105 /*     .. Local Scalars .. */
00106 /*     .. */
00107 /*     .. External Subroutines .. */
00108 /*     .. */
00109 /*     .. External Functions .. */
00110 /*     .. */
00111 /*     .. Intrinsic Functions .. */
00112 /*     .. */
00113 /*     .. Executable Statements .. */
00114 
00115     /* Parameter adjustments */
00116     --work;
00117     --ap;
00118 
00119     /* Function Body */
00120     if (*n == 0) {
00121         value = 0.;
00122     } else if (lsame_(norm, "M")) {
00123 
00124 /*        Find max(abs(A(i,j))). */
00125 
00126         value = 0.;
00127         if (lsame_(uplo, "U")) {
00128             k = 1;
00129             i__1 = *n;
00130             for (j = 1; j <= i__1; ++j) {
00131                 i__2 = k + j - 1;
00132                 for (i__ = k; i__ <= i__2; ++i__) {
00133 /* Computing MAX */
00134                     d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1));
00135                     value = max(d__2,d__3);
00136 /* L10: */
00137                 }
00138                 k += j;
00139 /* L20: */
00140             }
00141         } else {
00142             k = 1;
00143             i__1 = *n;
00144             for (j = 1; j <= i__1; ++j) {
00145                 i__2 = k + *n - j;
00146                 for (i__ = k; i__ <= i__2; ++i__) {
00147 /* Computing MAX */
00148                     d__2 = value, d__3 = (d__1 = ap[i__], abs(d__1));
00149                     value = max(d__2,d__3);
00150 /* L30: */
00151                 }
00152                 k = k + *n - j + 1;
00153 /* L40: */
00154             }
00155         }
00156     } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
00157 
00158 /*        Find normI(A) ( = norm1(A), since A is symmetric). */
00159 
00160         value = 0.;
00161         k = 1;
00162         if (lsame_(uplo, "U")) {
00163             i__1 = *n;
00164             for (j = 1; j <= i__1; ++j) {
00165                 sum = 0.;
00166                 i__2 = j - 1;
00167                 for (i__ = 1; i__ <= i__2; ++i__) {
00168                     absa = (d__1 = ap[k], abs(d__1));
00169                     sum += absa;
00170                     work[i__] += absa;
00171                     ++k;
00172 /* L50: */
00173                 }
00174                 work[j] = sum + (d__1 = ap[k], abs(d__1));
00175                 ++k;
00176 /* L60: */
00177             }
00178             i__1 = *n;
00179             for (i__ = 1; i__ <= i__1; ++i__) {
00180 /* Computing MAX */
00181                 d__1 = value, d__2 = work[i__];
00182                 value = max(d__1,d__2);
00183 /* L70: */
00184             }
00185         } else {
00186             i__1 = *n;
00187             for (i__ = 1; i__ <= i__1; ++i__) {
00188                 work[i__] = 0.;
00189 /* L80: */
00190             }
00191             i__1 = *n;
00192             for (j = 1; j <= i__1; ++j) {
00193                 sum = work[j] + (d__1 = ap[k], abs(d__1));
00194                 ++k;
00195                 i__2 = *n;
00196                 for (i__ = j + 1; i__ <= i__2; ++i__) {
00197                     absa = (d__1 = ap[k], abs(d__1));
00198                     sum += absa;
00199                     work[i__] += absa;
00200                     ++k;
00201 /* L90: */
00202                 }
00203                 value = max(value,sum);
00204 /* L100: */
00205             }
00206         }
00207     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00208 
00209 /*        Find normF(A). */
00210 
00211         scale = 0.;
00212         sum = 1.;
00213         k = 2;
00214         if (lsame_(uplo, "U")) {
00215             i__1 = *n;
00216             for (j = 2; j <= i__1; ++j) {
00217                 i__2 = j - 1;
00218                 dlassq_(&i__2, &ap[k], &c__1, &scale, &sum);
00219                 k += j;
00220 /* L110: */
00221             }
00222         } else {
00223             i__1 = *n - 1;
00224             for (j = 1; j <= i__1; ++j) {
00225                 i__2 = *n - j;
00226                 dlassq_(&i__2, &ap[k], &c__1, &scale, &sum);
00227                 k = k + *n - j + 1;
00228 /* L120: */
00229             }
00230         }
00231         sum *= 2;
00232         k = 1;
00233         i__1 = *n;
00234         for (i__ = 1; i__ <= i__1; ++i__) {
00235             if (ap[k] != 0.) {
00236                 absa = (d__1 = ap[k], abs(d__1));
00237                 if (scale < absa) {
00238 /* Computing 2nd power */
00239                     d__1 = scale / absa;
00240                     sum = sum * (d__1 * d__1) + 1.;
00241                     scale = absa;
00242                 } else {
00243 /* Computing 2nd power */
00244                     d__1 = absa / scale;
00245                     sum += d__1 * d__1;
00246                 }
00247             }
00248             if (lsame_(uplo, "U")) {
00249                 k = k + i__ + 1;
00250             } else {
00251                 k = k + *n - i__ + 1;
00252             }
00253 /* L130: */
00254         }
00255         value = scale * sqrt(sum);
00256     }
00257 
00258     ret_val = value;
00259     return ret_val;
00260 
00261 /*     End of DLANSP */
00262 
00263 } /* dlansp_ */


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