001:       DOUBLE PRECISION FUNCTION ZLANSY( NORM, UPLO, N, A, LDA, WORK )
002: *
003: *  -- LAPACK auxiliary routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       CHARACTER          NORM, UPLO
010:       INTEGER            LDA, N
011: *     ..
012: *     .. Array Arguments ..
013:       DOUBLE PRECISION   WORK( * )
014:       COMPLEX*16         A( LDA, * )
015: *     ..
016: *
017: *  Purpose
018: *  =======
019: *
020: *  ZLANSY  returns the value of the one norm,  or the Frobenius norm, or
021: *  the  infinity norm,  or the  element of  largest absolute value  of a
022: *  complex symmetric matrix A.
023: *
024: *  Description
025: *  ===========
026: *
027: *  ZLANSY returns the value
028: *
029: *     ZLANSY = ( max(abs(A(i,j))), NORM = 'M' or 'm'
030: *              (
031: *              ( norm1(A),         NORM = '1', 'O' or 'o'
032: *              (
033: *              ( normI(A),         NORM = 'I' or 'i'
034: *              (
035: *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
036: *
037: *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
038: *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
039: *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
040: *  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
041: *
042: *  Arguments
043: *  =========
044: *
045: *  NORM    (input) CHARACTER*1
046: *          Specifies the value to be returned in ZLANSY as described
047: *          above.
048: *
049: *  UPLO    (input) CHARACTER*1
050: *          Specifies whether the upper or lower triangular part of the
051: *          symmetric matrix A is to be referenced.
052: *          = 'U':  Upper triangular part of A is referenced
053: *          = 'L':  Lower triangular part of A is referenced
054: *
055: *  N       (input) INTEGER
056: *          The order of the matrix A.  N >= 0.  When N = 0, ZLANSY is
057: *          set to zero.
058: *
059: *  A       (input) COMPLEX*16 array, dimension (LDA,N)
060: *          The symmetric matrix A.  If UPLO = 'U', the leading n by n
061: *          upper triangular part of A contains the upper triangular part
062: *          of the matrix A, and the strictly lower triangular part of A
063: *          is not referenced.  If UPLO = 'L', the leading n by n lower
064: *          triangular part of A contains the lower triangular part of
065: *          the matrix A, and the strictly upper triangular part of A is
066: *          not referenced.
067: *
068: *  LDA     (input) INTEGER
069: *          The leading dimension of the array A.  LDA >= max(N,1).
070: *
071: *  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
072: *          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
073: *          WORK is not referenced.
074: *
075: * =====================================================================
076: *
077: *     .. Parameters ..
078:       DOUBLE PRECISION   ONE, ZERO
079:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
080: *     ..
081: *     .. Local Scalars ..
082:       INTEGER            I, J
083:       DOUBLE PRECISION   ABSA, SCALE, SUM, VALUE
084: *     ..
085: *     .. External Functions ..
086:       LOGICAL            LSAME
087:       EXTERNAL           LSAME
088: *     ..
089: *     .. External Subroutines ..
090:       EXTERNAL           ZLASSQ
091: *     ..
092: *     .. Intrinsic Functions ..
093:       INTRINSIC          ABS, MAX, SQRT
094: *     ..
095: *     .. Executable Statements ..
096: *
097:       IF( N.EQ.0 ) THEN
098:          VALUE = ZERO
099:       ELSE IF( LSAME( NORM, 'M' ) ) THEN
100: *
101: *        Find max(abs(A(i,j))).
102: *
103:          VALUE = ZERO
104:          IF( LSAME( UPLO, 'U' ) ) THEN
105:             DO 20 J = 1, N
106:                DO 10 I = 1, J
107:                   VALUE = MAX( VALUE, ABS( A( I, J ) ) )
108:    10          CONTINUE
109:    20       CONTINUE
110:          ELSE
111:             DO 40 J = 1, N
112:                DO 30 I = J, N
113:                   VALUE = MAX( VALUE, ABS( A( I, J ) ) )
114:    30          CONTINUE
115:    40       CONTINUE
116:          END IF
117:       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
118:      $         ( NORM.EQ.'1' ) ) THEN
119: *
120: *        Find normI(A) ( = norm1(A), since A is symmetric).
121: *
122:          VALUE = ZERO
123:          IF( LSAME( UPLO, 'U' ) ) THEN
124:             DO 60 J = 1, N
125:                SUM = ZERO
126:                DO 50 I = 1, J - 1
127:                   ABSA = ABS( A( I, J ) )
128:                   SUM = SUM + ABSA
129:                   WORK( I ) = WORK( I ) + ABSA
130:    50          CONTINUE
131:                WORK( J ) = SUM + ABS( A( J, J ) )
132:    60       CONTINUE
133:             DO 70 I = 1, N
134:                VALUE = MAX( VALUE, WORK( I ) )
135:    70       CONTINUE
136:          ELSE
137:             DO 80 I = 1, N
138:                WORK( I ) = ZERO
139:    80       CONTINUE
140:             DO 100 J = 1, N
141:                SUM = WORK( J ) + ABS( A( J, J ) )
142:                DO 90 I = J + 1, N
143:                   ABSA = ABS( A( I, J ) )
144:                   SUM = SUM + ABSA
145:                   WORK( I ) = WORK( I ) + ABSA
146:    90          CONTINUE
147:                VALUE = MAX( VALUE, SUM )
148:   100       CONTINUE
149:          END IF
150:       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
151: *
152: *        Find normF(A).
153: *
154:          SCALE = ZERO
155:          SUM = ONE
156:          IF( LSAME( UPLO, 'U' ) ) THEN
157:             DO 110 J = 2, N
158:                CALL ZLASSQ( J-1, A( 1, J ), 1, SCALE, SUM )
159:   110       CONTINUE
160:          ELSE
161:             DO 120 J = 1, N - 1
162:                CALL ZLASSQ( N-J, A( J+1, J ), 1, SCALE, SUM )
163:   120       CONTINUE
164:          END IF
165:          SUM = 2*SUM
166:          CALL ZLASSQ( N, A, LDA+1, SCALE, SUM )
167:          VALUE = SCALE*SQRT( SUM )
168:       END IF
169: *
170:       ZLANSY = VALUE
171:       RETURN
172: *
173: *     End of ZLANSY
174: *
175:       END
176: