1 /* ./src_f77/slanst.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
slanst_(char * norm,integer * n,real * d__,real * e,ftnlen norm_len)12 doublereal slanst_(char *norm, integer *n, real *d__, real *e, ftnlen
13 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 /* SLANST 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 symmetric tridiagonal matrix A. */
47
48 /* Description */
49 /* =========== */
50
51 /* SLANST returns the value */
52
53 /* SLANST = ( 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 SLANST as described */
71 /* above. */
72
73 /* N (input) INTEGER */
74 /* The order of the matrix A. N >= 0. When N = 0, SLANST is */
75 /* set to zero. */
76
77 /* D (input) REAL array, dimension (N) */
78 /* The diagonal elements of A. */
79
80 /* E (input) REAL array, dimension (N-1) */
81 /* The (n-1) sub-diagonal or super-diagonal elements of A. */
82
83 /* ===================================================================== */
84
85 /* .. Parameters .. */
86 /* .. */
87 /* .. Local Scalars .. */
88 /* .. */
89 /* .. External Functions .. */
90 /* .. */
91 /* .. External Subroutines .. */
92 /* .. */
93 /* .. Intrinsic Functions .. */
94 /* .. */
95 /* .. Executable Statements .. */
96
97 /* Parameter adjustments */
98 --e;
99 --d__;
100
101 /* Function Body */
102 if (*n <= 0) {
103 anorm = 0.f;
104 } else if (lsame_(norm, "M", (ftnlen)1, (ftnlen)1)) {
105
106 /* Find max(abs(A(i,j))). */
107
108 anorm = (r__1 = d__[*n], dabs(r__1));
109 i__1 = *n - 1;
110 for (i__ = 1; i__ <= i__1; ++i__) {
111 /* Computing MAX */
112 r__2 = anorm, r__3 = (r__1 = d__[i__], dabs(r__1));
113 anorm = dmax(r__2,r__3);
114 /* Computing MAX */
115 r__2 = anorm, r__3 = (r__1 = e[i__], dabs(r__1));
116 anorm = dmax(r__2,r__3);
117 /* L10: */
118 }
119 } else if (lsame_(norm, "O", (ftnlen)1, (ftnlen)1) || *(unsigned char *)
120 norm == '1' || lsame_(norm, "I", (ftnlen)1, (ftnlen)1)) {
121
122 /* Find norm1(A). */
123
124 if (*n == 1) {
125 anorm = dabs(d__[1]);
126 } else {
127 /* Computing MAX */
128 r__3 = dabs(d__[1]) + dabs(e[1]), r__4 = (r__1 = e[*n - 1], dabs(
129 r__1)) + (r__2 = d__[*n], dabs(r__2));
130 anorm = dmax(r__3,r__4);
131 i__1 = *n - 1;
132 for (i__ = 2; i__ <= i__1; ++i__) {
133 /* Computing MAX */
134 r__4 = anorm, r__5 = (r__1 = d__[i__], dabs(r__1)) + (r__2 =
135 e[i__], dabs(r__2)) + (r__3 = e[i__ - 1], dabs(r__3));
136 anorm = dmax(r__4,r__5);
137 /* L20: */
138 }
139 }
140 } else if (lsame_(norm, "F", (ftnlen)1, (ftnlen)1) || lsame_(norm, "E", (
141 ftnlen)1, (ftnlen)1)) {
142
143 /* Find normF(A). */
144
145 scale = 0.f;
146 sum = 1.f;
147 if (*n > 1) {
148 i__1 = *n - 1;
149 slassq_(&i__1, &e[1], &c__1, &scale, &sum);
150 sum *= 2;
151 }
152 slassq_(n, &d__[1], &c__1, &scale, &sum);
153 anorm = scale * sqrt(sum);
154 }
155
156 ret_val = anorm;
157 return ret_val;
158
159 /* End of SLANST */
160
161 } /* slanst_ */
162
163