LAPACK 3.3.0

zlanhe.f

Go to the documentation of this file.
00001       DOUBLE PRECISION FUNCTION ZLANHE( NORM, UPLO, N, A, LDA, WORK )
00002 *
00003 *  -- LAPACK auxiliary routine (version 3.2) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *     November 2006
00007 *
00008 *     .. Scalar Arguments ..
00009       CHARACTER          NORM, UPLO
00010       INTEGER            LDA, N
00011 *     ..
00012 *     .. Array Arguments ..
00013       DOUBLE PRECISION   WORK( * )
00014       COMPLEX*16         A( LDA, * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  ZLANHE  returns the value of the one norm,  or the Frobenius norm, or
00021 *  the  infinity norm,  or the  element of  largest absolute value  of a
00022 *  complex hermitian matrix A.
00023 *
00024 *  Description
00025 *  ===========
00026 *
00027 *  ZLANHE returns the value
00028 *
00029 *     ZLANHE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
00030 *              (
00031 *              ( norm1(A),         NORM = '1', 'O' or 'o'
00032 *              (
00033 *              ( normI(A),         NORM = 'I' or 'i'
00034 *              (
00035 *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
00036 *
00037 *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
00038 *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
00039 *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
00040 *  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
00041 *
00042 *  Arguments
00043 *  =========
00044 *
00045 *  NORM    (input) CHARACTER*1
00046 *          Specifies the value to be returned in ZLANHE as described
00047 *          above.
00048 *
00049 *  UPLO    (input) CHARACTER*1
00050 *          Specifies whether the upper or lower triangular part of the
00051 *          hermitian matrix A is to be referenced.
00052 *          = 'U':  Upper triangular part of A is referenced
00053 *          = 'L':  Lower triangular part of A is referenced
00054 *
00055 *  N       (input) INTEGER
00056 *          The order of the matrix A.  N >= 0.  When N = 0, ZLANHE is
00057 *          set to zero.
00058 *
00059 *  A       (input) COMPLEX*16 array, dimension (LDA,N)
00060 *          The hermitian matrix A.  If UPLO = 'U', the leading n by n
00061 *          upper triangular part of A contains the upper triangular part
00062 *          of the matrix A, and the strictly lower triangular part of A
00063 *          is not referenced.  If UPLO = 'L', the leading n by n lower
00064 *          triangular part of A contains the lower triangular part of
00065 *          the matrix A, and the strictly upper triangular part of A is
00066 *          not referenced. Note that the imaginary parts of the diagonal
00067 *          elements need not be set and are assumed to be zero.
00068 *
00069 *  LDA     (input) INTEGER
00070 *          The leading dimension of the array A.  LDA >= max(N,1).
00071 *
00072 *  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
00073 *          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
00074 *          WORK is not referenced.
00075 *
00076 * =====================================================================
00077 *
00078 *     .. Parameters ..
00079       DOUBLE PRECISION   ONE, ZERO
00080       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00081 *     ..
00082 *     .. Local Scalars ..
00083       INTEGER            I, J
00084       DOUBLE PRECISION   ABSA, SCALE, SUM, VALUE
00085 *     ..
00086 *     .. External Functions ..
00087       LOGICAL            LSAME
00088       EXTERNAL           LSAME
00089 *     ..
00090 *     .. External Subroutines ..
00091       EXTERNAL           ZLASSQ
00092 *     ..
00093 *     .. Intrinsic Functions ..
00094       INTRINSIC          ABS, DBLE, MAX, SQRT
00095 *     ..
00096 *     .. Executable Statements ..
00097 *
00098       IF( N.EQ.0 ) THEN
00099          VALUE = ZERO
00100       ELSE IF( LSAME( NORM, 'M' ) ) THEN
00101 *
00102 *        Find max(abs(A(i,j))).
00103 *
00104          VALUE = ZERO
00105          IF( LSAME( UPLO, 'U' ) ) THEN
00106             DO 20 J = 1, N
00107                DO 10 I = 1, J - 1
00108                   VALUE = MAX( VALUE, ABS( A( I, J ) ) )
00109    10          CONTINUE
00110                VALUE = MAX( VALUE, ABS( DBLE( A( J, J ) ) ) )
00111    20       CONTINUE
00112          ELSE
00113             DO 40 J = 1, N
00114                VALUE = MAX( VALUE, ABS( DBLE( A( J, J ) ) ) )
00115                DO 30 I = J + 1, N
00116                   VALUE = MAX( VALUE, ABS( A( I, J ) ) )
00117    30          CONTINUE
00118    40       CONTINUE
00119          END IF
00120       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
00121      $         ( NORM.EQ.'1' ) ) THEN
00122 *
00123 *        Find normI(A) ( = norm1(A), since A is hermitian).
00124 *
00125          VALUE = ZERO
00126          IF( LSAME( UPLO, 'U' ) ) THEN
00127             DO 60 J = 1, N
00128                SUM = ZERO
00129                DO 50 I = 1, J - 1
00130                   ABSA = ABS( A( I, J ) )
00131                   SUM = SUM + ABSA
00132                   WORK( I ) = WORK( I ) + ABSA
00133    50          CONTINUE
00134                WORK( J ) = SUM + ABS( DBLE( A( J, J ) ) )
00135    60       CONTINUE
00136             DO 70 I = 1, N
00137                VALUE = MAX( VALUE, WORK( I ) )
00138    70       CONTINUE
00139          ELSE
00140             DO 80 I = 1, N
00141                WORK( I ) = ZERO
00142    80       CONTINUE
00143             DO 100 J = 1, N
00144                SUM = WORK( J ) + ABS( DBLE( A( J, J ) ) )
00145                DO 90 I = J + 1, N
00146                   ABSA = ABS( A( I, J ) )
00147                   SUM = SUM + ABSA
00148                   WORK( I ) = WORK( I ) + ABSA
00149    90          CONTINUE
00150                VALUE = MAX( VALUE, SUM )
00151   100       CONTINUE
00152          END IF
00153       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
00154 *
00155 *        Find normF(A).
00156 *
00157          SCALE = ZERO
00158          SUM = ONE
00159          IF( LSAME( UPLO, 'U' ) ) THEN
00160             DO 110 J = 2, N
00161                CALL ZLASSQ( J-1, A( 1, J ), 1, SCALE, SUM )
00162   110       CONTINUE
00163          ELSE
00164             DO 120 J = 1, N - 1
00165                CALL ZLASSQ( N-J, A( J+1, J ), 1, SCALE, SUM )
00166   120       CONTINUE
00167          END IF
00168          SUM = 2*SUM
00169          DO 130 I = 1, N
00170             IF( DBLE( A( I, I ) ).NE.ZERO ) THEN
00171                ABSA = ABS( DBLE( A( I, I ) ) )
00172                IF( SCALE.LT.ABSA ) THEN
00173                   SUM = ONE + SUM*( SCALE / ABSA )**2
00174                   SCALE = ABSA
00175                ELSE
00176                   SUM = SUM + ( ABSA / SCALE )**2
00177                END IF
00178             END IF
00179   130    CONTINUE
00180          VALUE = SCALE*SQRT( SUM )
00181       END IF
00182 *
00183       ZLANHE = VALUE
00184       RETURN
00185 *
00186 *     End of ZLANHE
00187 *
00188       END
 All Files Functions