3 /* Table of constant values */
5 static integer c__1 = 1;
7 doublereal slansy_(char *norm, char *uplo, integer *n, real *a, integer *lda,
10 /* System generated locals */
11 integer a_dim1, a_offset, i__1, i__2;
12 real ret_val, r__1, r__2, r__3;
14 /* Builtin functions */
15 double sqrt(doublereal);
19 real sum, absa, scale;
20 extern logical lsame_(char *, char *);
22 extern /* Subroutine */ int slassq_(integer *, real *, integer *, real *,
26 /* -- LAPACK auxiliary routine (version 3.1) -- */
27 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
30 /* .. Scalar Arguments .. */
32 /* .. Array Arguments .. */
38 /* SLANSY returns the value of the one norm, or the Frobenius norm, or */
39 /* the infinity norm, or the element of largest absolute value of a */
40 /* real symmetric matrix A. */
45 /* SLANSY returns the value */
47 /* SLANSY = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
49 /* ( norm1(A), NORM = '1', 'O' or 'o' */
51 /* ( normI(A), NORM = 'I' or 'i' */
53 /* ( normF(A), NORM = 'F', 'f', 'E' or 'e' */
55 /* where norm1 denotes the one norm of a matrix (maximum column sum), */
56 /* normI denotes the infinity norm of a matrix (maximum row sum) and */
57 /* normF denotes the Frobenius norm of a matrix (square root of sum of */
58 /* squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. */
63 /* NORM (input) CHARACTER*1 */
64 /* Specifies the value to be returned in SLANSY as described */
67 /* UPLO (input) CHARACTER*1 */
68 /* Specifies whether the upper or lower triangular part of the */
69 /* symmetric matrix A is to be referenced. */
70 /* = 'U': Upper triangular part of A is referenced */
71 /* = 'L': Lower triangular part of A is referenced */
73 /* N (input) INTEGER */
74 /* The order of the matrix A. N >= 0. When N = 0, SLANSY is */
77 /* A (input) REAL array, dimension (LDA,N) */
78 /* The symmetric matrix A. If UPLO = 'U', the leading n by n */
79 /* upper triangular part of A contains the upper triangular part */
80 /* of the matrix A, and the strictly lower triangular part of A */
81 /* is not referenced. If UPLO = 'L', the leading n by n lower */
82 /* triangular part of A contains the lower triangular part of */
83 /* the matrix A, and the strictly upper triangular part of A is */
86 /* LDA (input) INTEGER */
87 /* The leading dimension of the array A. LDA >= max(N,1). */
89 /* WORK (workspace) REAL array, dimension (MAX(1,LWORK)), */
90 /* where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, */
91 /* WORK is not referenced. */
93 /* ===================================================================== */
95 /* .. Parameters .. */
97 /* .. Local Scalars .. */
99 /* .. External Subroutines .. */
101 /* .. External Functions .. */
103 /* .. Intrinsic Functions .. */
105 /* .. Executable Statements .. */
107 /* Parameter adjustments */
109 a_offset = 1 + a_dim1;
116 } else if (lsame_(norm, "M")) {
118 /* Find max(abs(A(i,j))). */
121 if (lsame_(uplo, "U")) {
123 for (j = 1; j <= i__1; ++j) {
125 for (i__ = 1; i__ <= i__2; ++i__) {
127 r__2 = value, r__3 = (r__1 = a[i__ + j * a_dim1], dabs(
129 value = dmax(r__2,r__3);
136 for (j = 1; j <= i__1; ++j) {
138 for (i__ = j; i__ <= i__2; ++i__) {
140 r__2 = value, r__3 = (r__1 = a[i__ + j * a_dim1], dabs(
142 value = dmax(r__2,r__3);
148 } else if (lsame_(norm, "I") || lsame_(norm, "O") || *(unsigned char *)norm == '1') {
150 /* Find normI(A) ( = norm1(A), since A is symmetric). */
153 if (lsame_(uplo, "U")) {
155 for (j = 1; j <= i__1; ++j) {
158 for (i__ = 1; i__ <= i__2; ++i__) {
159 absa = (r__1 = a[i__ + j * a_dim1], dabs(r__1));
164 work[j] = sum + (r__1 = a[j + j * a_dim1], dabs(r__1));
168 for (i__ = 1; i__ <= i__1; ++i__) {
170 r__1 = value, r__2 = work[i__];
171 value = dmax(r__1,r__2);
176 for (i__ = 1; i__ <= i__1; ++i__) {
181 for (j = 1; j <= i__1; ++j) {
182 sum = work[j] + (r__1 = a[j + j * a_dim1], dabs(r__1));
184 for (i__ = j + 1; i__ <= i__2; ++i__) {
185 absa = (r__1 = a[i__ + j * a_dim1], dabs(r__1));
190 value = dmax(value,sum);
194 } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
200 if (lsame_(uplo, "U")) {
202 for (j = 2; j <= i__1; ++j) {
204 slassq_(&i__2, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
209 for (j = 1; j <= i__1; ++j) {
211 slassq_(&i__2, &a[j + 1 + j * a_dim1], &c__1, &scale, &sum);
217 slassq_(n, &a[a_offset], &i__1, &scale, &sum);
218 value = scale * sqrt(sum);