slangt.c
Go to the documentation of this file.
00001 /* slangt.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 slangt_(char *norm, integer *n, real *dl, real *d__, real *du)
00021 {
00022     /* System generated locals */
00023     integer i__1;
00024     real ret_val, r__1, r__2, r__3, r__4, r__5;
00025 
00026     /* Builtin functions */
00027     double sqrt(doublereal);
00028 
00029     /* Local variables */
00030     integer i__;
00031     real sum, scale;
00032     extern logical lsame_(char *, char *);
00033     real anorm;
00034     extern /* Subroutine */ int slassq_(integer *, real *, integer *, real *, 
00035             real *);
00036 
00037 
00038 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00039 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00040 /*     November 2006 */
00041 
00042 /*     .. Scalar Arguments .. */
00043 /*     .. */
00044 /*     .. Array Arguments .. */
00045 /*     .. */
00046 
00047 /*  Purpose */
00048 /*  ======= */
00049 
00050 /*  SLANGT  returns the value of the one norm,  or the Frobenius norm, or */
00051 /*  the  infinity norm,  or the  element of  largest absolute value  of a */
00052 /*  real tridiagonal matrix A. */
00053 
00054 /*  Description */
00055 /*  =========== */
00056 
00057 /*  SLANGT returns the value */
00058 
00059 /*     SLANGT = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
00060 /*              ( */
00061 /*              ( norm1(A),         NORM = '1', 'O' or 'o' */
00062 /*              ( */
00063 /*              ( normI(A),         NORM = 'I' or 'i' */
00064 /*              ( */
00065 /*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
00066 
00067 /*  where  norm1  denotes the  one norm of a matrix (maximum column sum), */
00068 /*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
00069 /*  normF  denotes the  Frobenius norm of a matrix (square root of sum of */
00070 /*  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm. */
00071 
00072 /*  Arguments */
00073 /*  ========= */
00074 
00075 /*  NORM    (input) CHARACTER*1 */
00076 /*          Specifies the value to be returned in SLANGT as described */
00077 /*          above. */
00078 
00079 /*  N       (input) INTEGER */
00080 /*          The order of the matrix A.  N >= 0.  When N = 0, SLANGT is */
00081 /*          set to zero. */
00082 
00083 /*  DL      (input) REAL array, dimension (N-1) */
00084 /*          The (n-1) sub-diagonal elements of A. */
00085 
00086 /*  D       (input) REAL array, dimension (N) */
00087 /*          The diagonal elements of A. */
00088 
00089 /*  DU      (input) REAL array, dimension (N-1) */
00090 /*          The (n-1) super-diagonal elements of A. */
00091 
00092 /*  ===================================================================== */
00093 
00094 /*     .. Parameters .. */
00095 /*     .. */
00096 /*     .. Local Scalars .. */
00097 /*     .. */
00098 /*     .. External Functions .. */
00099 /*     .. */
00100 /*     .. External Subroutines .. */
00101 /*     .. */
00102 /*     .. Intrinsic Functions .. */
00103 /*     .. */
00104 /*     .. Executable Statements .. */
00105 
00106     /* Parameter adjustments */
00107     --du;
00108     --d__;
00109     --dl;
00110 
00111     /* Function Body */
00112     if (*n <= 0) {
00113         anorm = 0.f;
00114     } else if (lsame_(norm, "M")) {
00115 
00116 /*        Find max(abs(A(i,j))). */
00117 
00118         anorm = (r__1 = d__[*n], dabs(r__1));
00119         i__1 = *n - 1;
00120         for (i__ = 1; i__ <= i__1; ++i__) {
00121 /* Computing MAX */
00122             r__2 = anorm, r__3 = (r__1 = dl[i__], dabs(r__1));
00123             anorm = dmax(r__2,r__3);
00124 /* Computing MAX */
00125             r__2 = anorm, r__3 = (r__1 = d__[i__], dabs(r__1));
00126             anorm = dmax(r__2,r__3);
00127 /* Computing MAX */
00128             r__2 = anorm, r__3 = (r__1 = du[i__], dabs(r__1));
00129             anorm = dmax(r__2,r__3);
00130 /* L10: */
00131         }
00132     } else if (lsame_(norm, "O") || *(unsigned char *)
00133             norm == '1') {
00134 
00135 /*        Find norm1(A). */
00136 
00137         if (*n == 1) {
00138             anorm = dabs(d__[1]);
00139         } else {
00140 /* Computing MAX */
00141             r__3 = dabs(d__[1]) + dabs(dl[1]), r__4 = (r__1 = d__[*n], dabs(
00142                     r__1)) + (r__2 = du[*n - 1], dabs(r__2));
00143             anorm = dmax(r__3,r__4);
00144             i__1 = *n - 1;
00145             for (i__ = 2; i__ <= i__1; ++i__) {
00146 /* Computing MAX */
00147                 r__4 = anorm, r__5 = (r__1 = d__[i__], dabs(r__1)) + (r__2 = 
00148                         dl[i__], dabs(r__2)) + (r__3 = du[i__ - 1], dabs(r__3)
00149                         );
00150                 anorm = dmax(r__4,r__5);
00151 /* L20: */
00152             }
00153         }
00154     } else if (lsame_(norm, "I")) {
00155 
00156 /*        Find normI(A). */
00157 
00158         if (*n == 1) {
00159             anorm = dabs(d__[1]);
00160         } else {
00161 /* Computing MAX */
00162             r__3 = dabs(d__[1]) + dabs(du[1]), r__4 = (r__1 = d__[*n], dabs(
00163                     r__1)) + (r__2 = dl[*n - 1], dabs(r__2));
00164             anorm = dmax(r__3,r__4);
00165             i__1 = *n - 1;
00166             for (i__ = 2; i__ <= i__1; ++i__) {
00167 /* Computing MAX */
00168                 r__4 = anorm, r__5 = (r__1 = d__[i__], dabs(r__1)) + (r__2 = 
00169                         du[i__], dabs(r__2)) + (r__3 = dl[i__ - 1], dabs(r__3)
00170                         );
00171                 anorm = dmax(r__4,r__5);
00172 /* L30: */
00173             }
00174         }
00175     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
00176 
00177 /*        Find normF(A). */
00178 
00179         scale = 0.f;
00180         sum = 1.f;
00181         slassq_(n, &d__[1], &c__1, &scale, &sum);
00182         if (*n > 1) {
00183             i__1 = *n - 1;
00184             slassq_(&i__1, &dl[1], &c__1, &scale, &sum);
00185             i__1 = *n - 1;
00186             slassq_(&i__1, &du[1], &c__1, &scale, &sum);
00187         }
00188         anorm = scale * sqrt(sum);
00189     }
00190 
00191     ret_val = anorm;
00192     return ret_val;
00193 
00194 /*     End of SLANGT */
00195 
00196 } /* slangt_ */


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