Update to 2.0.0 tree from current Fremantle build
[opencv] / 3rdparty / lapack / dlanst.c
1 #include "clapack.h"
2
3 /* Table of constant values */
4
5 static integer c__1 = 1;
6
7 doublereal dlanst_(char *norm, integer *n, doublereal *d__, doublereal *e)
8 {
9     /* System generated locals */
10     integer i__1;
11     doublereal ret_val, d__1, d__2, d__3, d__4, d__5;
12
13     /* Builtin functions */
14     double sqrt(doublereal);
15
16     /* Local variables */
17     integer i__;
18     doublereal sum, scale;
19     extern logical lsame_(char *, char *);
20     doublereal anorm;
21     extern /* Subroutine */ int dlassq_(integer *, doublereal *, integer *, 
22             doublereal *, doublereal *);
23
24
25 /*  -- LAPACK auxiliary routine (version 3.1) -- */
26 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
27 /*     November 2006 */
28
29 /*     .. Scalar Arguments .. */
30 /*     .. */
31 /*     .. Array Arguments .. */
32 /*     .. */
33
34 /*  Purpose */
35 /*  ======= */
36
37 /*  DLANST  returns the value of the one norm,  or the Frobenius norm, or */
38 /*  the  infinity norm,  or the  element of  largest absolute value  of a */
39 /*  real symmetric tridiagonal matrix A. */
40
41 /*  Description */
42 /*  =========== */
43
44 /*  DLANST returns the value */
45
46 /*     DLANST = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
47 /*              ( */
48 /*              ( norm1(A),         NORM = '1', 'O' or 'o' */
49 /*              ( */
50 /*              ( normI(A),         NORM = 'I' or 'i' */
51 /*              ( */
52 /*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
53
54 /*  where  norm1  denotes the  one norm of a matrix (maximum column sum), */
55 /*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and */
56 /*  normF  denotes the  Frobenius norm of a matrix (square root of sum of */
57 /*  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm. */
58
59 /*  Arguments */
60 /*  ========= */
61
62 /*  NORM    (input) CHARACTER*1 */
63 /*          Specifies the value to be returned in DLANST as described */
64 /*          above. */
65
66 /*  N       (input) INTEGER */
67 /*          The order of the matrix A.  N >= 0.  When N = 0, DLANST is */
68 /*          set to zero. */
69
70 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
71 /*          The diagonal elements of A. */
72
73 /*  E       (input) DOUBLE PRECISION array, dimension (N-1) */
74 /*          The (n-1) sub-diagonal or super-diagonal elements of A. */
75
76 /*  ===================================================================== */
77
78 /*     .. Parameters .. */
79 /*     .. */
80 /*     .. Local Scalars .. */
81 /*     .. */
82 /*     .. External Functions .. */
83 /*     .. */
84 /*     .. External Subroutines .. */
85 /*     .. */
86 /*     .. Intrinsic Functions .. */
87 /*     .. */
88 /*     .. Executable Statements .. */
89
90     /* Parameter adjustments */
91     --e;
92     --d__;
93
94     /* Function Body */
95     if (*n <= 0) {
96         anorm = 0.;
97     } else if (lsame_(norm, "M")) {
98
99 /*        Find max(abs(A(i,j))). */
100
101         anorm = (d__1 = d__[*n], abs(d__1));
102         i__1 = *n - 1;
103         for (i__ = 1; i__ <= i__1; ++i__) {
104 /* Computing MAX */
105             d__2 = anorm, d__3 = (d__1 = d__[i__], abs(d__1));
106             anorm = max(d__2,d__3);
107 /* Computing MAX */
108             d__2 = anorm, d__3 = (d__1 = e[i__], abs(d__1));
109             anorm = max(d__2,d__3);
110 /* L10: */
111         }
112     } else if (lsame_(norm, "O") || *(unsigned char *)
113             norm == '1' || lsame_(norm, "I")) {
114
115 /*        Find norm1(A). */
116
117         if (*n == 1) {
118             anorm = abs(d__[1]);
119         } else {
120 /* Computing MAX */
121             d__3 = abs(d__[1]) + abs(e[1]), d__4 = (d__1 = e[*n - 1], abs(
122                     d__1)) + (d__2 = d__[*n], abs(d__2));
123             anorm = max(d__3,d__4);
124             i__1 = *n - 1;
125             for (i__ = 2; i__ <= i__1; ++i__) {
126 /* Computing MAX */
127                 d__4 = anorm, d__5 = (d__1 = d__[i__], abs(d__1)) + (d__2 = e[
128                         i__], abs(d__2)) + (d__3 = e[i__ - 1], abs(d__3));
129                 anorm = max(d__4,d__5);
130 /* L20: */
131             }
132         }
133     } else if (lsame_(norm, "F") || lsame_(norm, "E")) {
134
135 /*        Find normF(A). */
136
137         scale = 0.;
138         sum = 1.;
139         if (*n > 1) {
140             i__1 = *n - 1;
141             dlassq_(&i__1, &e[1], &c__1, &scale, &sum);
142             sum *= 2;
143         }
144         dlassq_(n, &d__[1], &c__1, &scale, &sum);
145         anorm = scale * sqrt(sum);
146     }
147
148     ret_val = anorm;
149     return ret_val;
150
151 /*     End of DLANST */
152
153 } /* dlanst_ */