acef655b853c5db3f53899c221001dd673ce7a5d
[platform/upstream/lapack.git] / SRC / clansy.f
1 *> \brief \b CLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a complex symmetric matrix.
2 *
3 *  =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at 
6 *            http://www.netlib.org/lapack/explore-html/ 
7 *
8 *> \htmlonly
9 *> Download CLANSY + dependencies 
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clansy.f"> 
11 *> [TGZ]</a> 
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clansy.f"> 
13 *> [ZIP]</a> 
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clansy.f"> 
15 *> [TXT]</a>
16 *> \endhtmlonly 
17 *
18 *  Definition:
19 *  ===========
20 *
21 *       REAL             FUNCTION CLANSY( NORM, UPLO, N, A, LDA, WORK )
22
23 *       .. Scalar Arguments ..
24 *       CHARACTER          NORM, UPLO
25 *       INTEGER            LDA, N
26 *       ..
27 *       .. Array Arguments ..
28 *       REAL               WORK( * )
29 *       COMPLEX            A( LDA, * )
30 *       ..
31 *  
32 *
33 *> \par Purpose:
34 *  =============
35 *>
36 *> \verbatim
37 *>
38 *> CLANSY  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 *> complex symmetric matrix A.
41 *> \endverbatim
42 *>
43 *> \return CLANSY
44 *> \verbatim
45 *>
46 *>    CLANSY = ( 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 *> \endverbatim
59 *
60 *  Arguments:
61 *  ==========
62 *
63 *> \param[in] NORM
64 *> \verbatim
65 *>          NORM is CHARACTER*1
66 *>          Specifies the value to be returned in CLANSY as described
67 *>          above.
68 *> \endverbatim
69 *>
70 *> \param[in] UPLO
71 *> \verbatim
72 *>          UPLO is CHARACTER*1
73 *>          Specifies whether the upper or lower triangular part of the
74 *>          symmetric matrix A is to be referenced.
75 *>          = 'U':  Upper triangular part of A is referenced
76 *>          = 'L':  Lower triangular part of A is referenced
77 *> \endverbatim
78 *>
79 *> \param[in] N
80 *> \verbatim
81 *>          N is INTEGER
82 *>          The order of the matrix A.  N >= 0.  When N = 0, CLANSY is
83 *>          set to zero.
84 *> \endverbatim
85 *>
86 *> \param[in] A
87 *> \verbatim
88 *>          A is COMPLEX array, dimension (LDA,N)
89 *>          The symmetric matrix A.  If UPLO = 'U', the leading n by n
90 *>          upper triangular part of A contains the upper triangular part
91 *>          of the matrix A, and the strictly lower triangular part of A
92 *>          is not referenced.  If UPLO = 'L', the leading n by n lower
93 *>          triangular part of A contains the lower triangular part of
94 *>          the matrix A, and the strictly upper triangular part of A is
95 *>          not referenced.
96 *> \endverbatim
97 *>
98 *> \param[in] LDA
99 *> \verbatim
100 *>          LDA is INTEGER
101 *>          The leading dimension of the array A.  LDA >= max(N,1).
102 *> \endverbatim
103 *>
104 *> \param[out] WORK
105 *> \verbatim
106 *>          WORK is REAL array, dimension (MAX(1,LWORK)),
107 *>          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
108 *>          WORK is not referenced.
109 *> \endverbatim
110 *
111 *  Authors:
112 *  ========
113 *
114 *> \author Univ. of Tennessee 
115 *> \author Univ. of California Berkeley 
116 *> \author Univ. of Colorado Denver 
117 *> \author NAG Ltd. 
118 *
119 *> \date November 2015
120 *
121 *> \ingroup complexSYauxiliary
122 *
123 *  =====================================================================
124       REAL             FUNCTION CLANSY( NORM, UPLO, N, A, LDA, WORK )
125 *
126 *  -- LAPACK auxiliary routine (version 3.6.0) --
127 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
128 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
129 *     November 2015
130 *
131 *     .. Scalar Arguments ..
132       CHARACTER          NORM, UPLO
133       INTEGER            LDA, N
134 *     ..
135 *     .. Array Arguments ..
136       REAL               WORK( * )
137       COMPLEX            A( LDA, * )
138 *     ..
139 *
140 * =====================================================================
141 *
142 *     .. Parameters ..
143       REAL               ONE, ZERO
144       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
145 *     ..
146 *     .. Local Scalars ..
147       INTEGER            I, J
148       REAL               ABSA, SCALE, SUM, VALUE
149 *     ..
150 *     .. External Functions ..
151       LOGICAL            LSAME, SISNAN
152       EXTERNAL           LSAME, SISNAN
153 *     ..
154 *     .. External Subroutines ..
155       EXTERNAL           CLASSQ
156 *     ..
157 *     .. Intrinsic Functions ..
158       INTRINSIC          ABS, SQRT
159 *     ..
160 *     .. Executable Statements ..
161 *
162       IF( N.EQ.0 ) THEN
163          VALUE = ZERO
164       ELSE IF( LSAME( NORM, 'M' ) ) THEN
165 *
166 *        Find max(abs(A(i,j))).
167 *
168          VALUE = ZERO
169          IF( LSAME( UPLO, 'U' ) ) THEN
170             DO 20 J = 1, N
171                DO 10 I = 1, J
172                   SUM = ABS( A( I, J ) )
173                   IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
174    10          CONTINUE
175    20       CONTINUE
176          ELSE
177             DO 40 J = 1, N
178                DO 30 I = J, N
179                   SUM = ABS( A( I, J ) )
180                   IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
181    30          CONTINUE
182    40       CONTINUE
183          END IF
184       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
185      $         ( NORM.EQ.'1' ) ) THEN
186 *
187 *        Find normI(A) ( = norm1(A), since A is symmetric).
188 *
189          VALUE = ZERO
190          IF( LSAME( UPLO, 'U' ) ) THEN
191             DO 60 J = 1, N
192                SUM = ZERO
193                DO 50 I = 1, J - 1
194                   ABSA = ABS( A( I, J ) )
195                   SUM = SUM + ABSA
196                   WORK( I ) = WORK( I ) + ABSA
197    50          CONTINUE
198                WORK( J ) = SUM + ABS( A( J, J ) )
199    60       CONTINUE
200             DO 70 I = 1, N
201                SUM = WORK( I )
202                IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
203    70       CONTINUE
204          ELSE
205             DO 80 I = 1, N
206                WORK( I ) = ZERO
207    80       CONTINUE
208             DO 100 J = 1, N
209                SUM = WORK( J ) + ABS( A( J, J ) )
210                DO 90 I = J + 1, N
211                   ABSA = ABS( A( I, J ) )
212                   SUM = SUM + ABSA
213                   WORK( I ) = WORK( I ) + ABSA
214    90          CONTINUE
215                IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM
216   100       CONTINUE
217          END IF
218       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
219 *
220 *        Find normF(A).
221 *
222          SCALE = ZERO
223          SUM = ONE
224          IF( LSAME( UPLO, 'U' ) ) THEN
225             DO 110 J = 2, N
226                CALL CLASSQ( J-1, A( 1, J ), 1, SCALE, SUM )
227   110       CONTINUE
228          ELSE
229             DO 120 J = 1, N - 1
230                CALL CLASSQ( N-J, A( J+1, J ), 1, SCALE, SUM )
231   120       CONTINUE
232          END IF
233          SUM = 2*SUM
234          CALL CLASSQ( N, A, LDA+1, SCALE, SUM )
235          VALUE = SCALE*SQRT( SUM )
236       END IF
237 *
238       CLANSY = VALUE
239       RETURN
240 *
241 *     End of CLANSY
242 *
243       END