1 /* ./src_f77/slangt.f -- translated by f2c (version 20030320).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include <punc/vf2c.h>
7 
8 /* Table of constant values */
9 
10 static integer c__1 = 1;
11 
slangt_(char * norm,integer * n,real * dl,real * d__,real * du,ftnlen norm_len)12 doublereal slangt_(char *norm, integer *n, real *dl, real *d__, real *du,
13 	ftnlen norm_len)
14 {
15     /* System generated locals */
16     integer i__1;
17     real ret_val, r__1, r__2, r__3, r__4, r__5;
18 
19     /* Builtin functions */
20     double sqrt(doublereal);
21 
22     /* Local variables */
23     static integer i__;
24     static real sum, scale;
25     extern logical lsame_(char *, char *, ftnlen, ftnlen);
26     static real anorm;
27     extern /* Subroutine */ int slassq_(integer *, real *, integer *, real *,
28 	    real *);
29 
30 
31 /*  -- LAPACK auxiliary routine (version 3.0) -- */
32 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
33 /*     Courant Institute, Argonne National Lab, and Rice University */
34 /*     February 29, 1992 */
35 
36 /*     .. Scalar Arguments .. */
37 /*     .. */
38 /*     .. Array Arguments .. */
39 /*     .. */
40 
41 /*  Purpose */
42 /*  ======= */
43 
44 /*  SLANGT  returns the value of the one norm,  or the Frobenius norm, or */
45 /*  the  infinity norm,  or the  element of  largest absolute value  of a */
46 /*  real tridiagonal matrix A. */
47 
48 /*  Description */
49 /*  =========== */
50 
51 /*  SLANGT returns the value */
52 
53 /*     SLANGT = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
54 /*              ( */
55 /*              ( norm1(A),         NORM = '1', 'O' or 'o' */
56 /*              ( */
57 /*              ( normI(A),         NORM = 'I' or 'i' */
58 /*              ( */
59 /*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
60 
61 /*  where  norm1  denotes the  one norm of a matrix (maximum column sum), */
62 /*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
63 /*  normF  denotes the  Frobenius norm of a matrix (square root of sum of */
64 /*  squares).  Note that  max(abs(A(i,j)))  is not a  matrix norm. */
65 
66 /*  Arguments */
67 /*  ========= */
68 
69 /*  NORM    (input) CHARACTER*1 */
70 /*          Specifies the value to be returned in SLANGT as described */
71 /*          above. */
72 
73 /*  N       (input) INTEGER */
74 /*          The order of the matrix A.  N >= 0.  When N = 0, SLANGT is */
75 /*          set to zero. */
76 
77 /*  DL      (input) REAL array, dimension (N-1) */
78 /*          The (n-1) sub-diagonal elements of A. */
79 
80 /*  D       (input) REAL array, dimension (N) */
81 /*          The diagonal elements of A. */
82 
83 /*  DU      (input) REAL array, dimension (N-1) */
84 /*          The (n-1) super-diagonal elements of A. */
85 
86 /*  ===================================================================== */
87 
88 /*     .. Parameters .. */
89 /*     .. */
90 /*     .. Local Scalars .. */
91 /*     .. */
92 /*     .. External Functions .. */
93 /*     .. */
94 /*     .. External Subroutines .. */
95 /*     .. */
96 /*     .. Intrinsic Functions .. */
97 /*     .. */
98 /*     .. Executable Statements .. */
99 
100     /* Parameter adjustments */
101     --du;
102     --d__;
103     --dl;
104 
105     /* Function Body */
106     if (*n <= 0) {
107 	anorm = 0.f;
108     } else if (lsame_(norm, "M", (ftnlen)1, (ftnlen)1)) {
109 
110 /*        Find max(abs(A(i,j))). */
111 
112 	anorm = (r__1 = d__[*n], dabs(r__1));
113 	i__1 = *n - 1;
114 	for (i__ = 1; i__ <= i__1; ++i__) {
115 /* Computing MAX */
116 	    r__2 = anorm, r__3 = (r__1 = dl[i__], dabs(r__1));
117 	    anorm = dmax(r__2,r__3);
118 /* Computing MAX */
119 	    r__2 = anorm, r__3 = (r__1 = d__[i__], dabs(r__1));
120 	    anorm = dmax(r__2,r__3);
121 /* Computing MAX */
122 	    r__2 = anorm, r__3 = (r__1 = du[i__], dabs(r__1));
123 	    anorm = dmax(r__2,r__3);
124 /* L10: */
125 	}
126     } else if (lsame_(norm, "O", (ftnlen)1, (ftnlen)1) || *(unsigned char *)
127 	    norm == '1') {
128 
129 /*        Find norm1(A). */
130 
131 	if (*n == 1) {
132 	    anorm = dabs(d__[1]);
133 	} else {
134 /* Computing MAX */
135 	    r__3 = dabs(d__[1]) + dabs(dl[1]), r__4 = (r__1 = d__[*n], dabs(
136 		    r__1)) + (r__2 = du[*n - 1], dabs(r__2));
137 	    anorm = dmax(r__3,r__4);
138 	    i__1 = *n - 1;
139 	    for (i__ = 2; i__ <= i__1; ++i__) {
140 /* Computing MAX */
141 		r__4 = anorm, r__5 = (r__1 = d__[i__], dabs(r__1)) + (r__2 =
142 			dl[i__], dabs(r__2)) + (r__3 = du[i__ - 1], dabs(r__3)
143 			);
144 		anorm = dmax(r__4,r__5);
145 /* L20: */
146 	    }
147 	}
148     } else if (lsame_(norm, "I", (ftnlen)1, (ftnlen)1)) {
149 
150 /*        Find normI(A). */
151 
152 	if (*n == 1) {
153 	    anorm = dabs(d__[1]);
154 	} else {
155 /* Computing MAX */
156 	    r__3 = dabs(d__[1]) + dabs(du[1]), r__4 = (r__1 = d__[*n], dabs(
157 		    r__1)) + (r__2 = dl[*n - 1], dabs(r__2));
158 	    anorm = dmax(r__3,r__4);
159 	    i__1 = *n - 1;
160 	    for (i__ = 2; i__ <= i__1; ++i__) {
161 /* Computing MAX */
162 		r__4 = anorm, r__5 = (r__1 = d__[i__], dabs(r__1)) + (r__2 =
163 			du[i__], dabs(r__2)) + (r__3 = dl[i__ - 1], dabs(r__3)
164 			);
165 		anorm = dmax(r__4,r__5);
166 /* L30: */
167 	    }
168 	}
169     } else if (lsame_(norm, "F", (ftnlen)1, (ftnlen)1) || lsame_(norm, "E", (
170 	    ftnlen)1, (ftnlen)1)) {
171 
172 /*        Find normF(A). */
173 
174 	scale = 0.f;
175 	sum = 1.f;
176 	slassq_(n, &d__[1], &c__1, &scale, &sum);
177 	if (*n > 1) {
178 	    i__1 = *n - 1;
179 	    slassq_(&i__1, &dl[1], &c__1, &scale, &sum);
180 	    i__1 = *n - 1;
181 	    slassq_(&i__1, &du[1], &c__1, &scale, &sum);
182 	}
183 	anorm = scale * sqrt(sum);
184     }
185 
186     ret_val = anorm;
187     return ret_val;
188 
189 /*     End of SLANGT */
190 
191 } /* slangt_ */
192 
193