LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
clanhe.f
Go to the documentation of this file.
00001 *> \brief \b CLANHE
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download CLANHE + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clanhe.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clanhe.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clanhe.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       REAL             FUNCTION CLANHE( NORM, UPLO, N, A, LDA, WORK )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       CHARACTER          NORM, UPLO
00025 *       INTEGER            LDA, N
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       REAL               WORK( * )
00029 *       COMPLEX            A( LDA, * )
00030 *       ..
00031 *  
00032 *
00033 *> \par Purpose:
00034 *  =============
00035 *>
00036 *> \verbatim
00037 *>
00038 *> CLANHE  returns the value of the one norm,  or the Frobenius norm, or
00039 *> the  infinity norm,  or the  element of  largest absolute value  of a
00040 *> complex hermitian matrix A.
00041 *> \endverbatim
00042 *>
00043 *> \return CLANHE
00044 *> \verbatim
00045 *>
00046 *>    CLANHE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
00047 *>             (
00048 *>             ( norm1(A),         NORM = '1', 'O' or 'o'
00049 *>             (
00050 *>             ( normI(A),         NORM = 'I' or 'i'
00051 *>             (
00052 *>             ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
00053 *>
00054 *> where  norm1  denotes the  one norm of a matrix (maximum column sum),
00055 *> normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
00056 *> normF  denotes the  Frobenius norm of a matrix (square root of sum of
00057 *> squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
00058 *> \endverbatim
00059 *
00060 *  Arguments:
00061 *  ==========
00062 *
00063 *> \param[in] NORM
00064 *> \verbatim
00065 *>          NORM is CHARACTER*1
00066 *>          Specifies the value to be returned in CLANHE as described
00067 *>          above.
00068 *> \endverbatim
00069 *>
00070 *> \param[in] UPLO
00071 *> \verbatim
00072 *>          UPLO is CHARACTER*1
00073 *>          Specifies whether the upper or lower triangular part of the
00074 *>          hermitian matrix A is to be referenced.
00075 *>          = 'U':  Upper triangular part of A is referenced
00076 *>          = 'L':  Lower triangular part of A is referenced
00077 *> \endverbatim
00078 *>
00079 *> \param[in] N
00080 *> \verbatim
00081 *>          N is INTEGER
00082 *>          The order of the matrix A.  N >= 0.  When N = 0, CLANHE is
00083 *>          set to zero.
00084 *> \endverbatim
00085 *>
00086 *> \param[in] A
00087 *> \verbatim
00088 *>          A is COMPLEX array, dimension (LDA,N)
00089 *>          The hermitian matrix A.  If UPLO = 'U', the leading n by n
00090 *>          upper triangular part of A contains the upper triangular part
00091 *>          of the matrix A, and the strictly lower triangular part of A
00092 *>          is not referenced.  If UPLO = 'L', the leading n by n lower
00093 *>          triangular part of A contains the lower triangular part of
00094 *>          the matrix A, and the strictly upper triangular part of A is
00095 *>          not referenced. Note that the imaginary parts of the diagonal
00096 *>          elements need not be set and are assumed to be zero.
00097 *> \endverbatim
00098 *>
00099 *> \param[in] LDA
00100 *> \verbatim
00101 *>          LDA is INTEGER
00102 *>          The leading dimension of the array A.  LDA >= max(N,1).
00103 *> \endverbatim
00104 *>
00105 *> \param[out] WORK
00106 *> \verbatim
00107 *>          WORK is REAL array, dimension (MAX(1,LWORK)),
00108 *>          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
00109 *>          WORK is not referenced.
00110 *> \endverbatim
00111 *
00112 *  Authors:
00113 *  ========
00114 *
00115 *> \author Univ. of Tennessee 
00116 *> \author Univ. of California Berkeley 
00117 *> \author Univ. of Colorado Denver 
00118 *> \author NAG Ltd. 
00119 *
00120 *> \date November 2011
00121 *
00122 *> \ingroup complexHEauxiliary
00123 *
00124 *  =====================================================================
00125       REAL             FUNCTION CLANHE( NORM, UPLO, N, A, LDA, WORK )
00126 *
00127 *  -- LAPACK auxiliary routine (version 3.4.0) --
00128 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00129 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00130 *     November 2011
00131 *
00132 *     .. Scalar Arguments ..
00133       CHARACTER          NORM, UPLO
00134       INTEGER            LDA, N
00135 *     ..
00136 *     .. Array Arguments ..
00137       REAL               WORK( * )
00138       COMPLEX            A( LDA, * )
00139 *     ..
00140 *
00141 * =====================================================================
00142 *
00143 *     .. Parameters ..
00144       REAL               ONE, ZERO
00145       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00146 *     ..
00147 *     .. Local Scalars ..
00148       INTEGER            I, J
00149       REAL               ABSA, SCALE, SUM, VALUE
00150 *     ..
00151 *     .. External Functions ..
00152       LOGICAL            LSAME
00153       EXTERNAL           LSAME
00154 *     ..
00155 *     .. External Subroutines ..
00156       EXTERNAL           CLASSQ
00157 *     ..
00158 *     .. Intrinsic Functions ..
00159       INTRINSIC          ABS, MAX, REAL, SQRT
00160 *     ..
00161 *     .. Executable Statements ..
00162 *
00163       IF( N.EQ.0 ) THEN
00164          VALUE = ZERO
00165       ELSE IF( LSAME( NORM, 'M' ) ) THEN
00166 *
00167 *        Find max(abs(A(i,j))).
00168 *
00169          VALUE = ZERO
00170          IF( LSAME( UPLO, 'U' ) ) THEN
00171             DO 20 J = 1, N
00172                DO 10 I = 1, J - 1
00173                   VALUE = MAX( VALUE, ABS( A( I, J ) ) )
00174    10          CONTINUE
00175                VALUE = MAX( VALUE, ABS( REAL( A( J, J ) ) ) )
00176    20       CONTINUE
00177          ELSE
00178             DO 40 J = 1, N
00179                VALUE = MAX( VALUE, ABS( REAL( A( J, J ) ) ) )
00180                DO 30 I = J + 1, N
00181                   VALUE = MAX( VALUE, ABS( A( I, J ) ) )
00182    30          CONTINUE
00183    40       CONTINUE
00184          END IF
00185       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
00186      $         ( NORM.EQ.'1' ) ) THEN
00187 *
00188 *        Find normI(A) ( = norm1(A), since A is hermitian).
00189 *
00190          VALUE = ZERO
00191          IF( LSAME( UPLO, 'U' ) ) THEN
00192             DO 60 J = 1, N
00193                SUM = ZERO
00194                DO 50 I = 1, J - 1
00195                   ABSA = ABS( A( I, J ) )
00196                   SUM = SUM + ABSA
00197                   WORK( I ) = WORK( I ) + ABSA
00198    50          CONTINUE
00199                WORK( J ) = SUM + ABS( REAL( A( J, J ) ) )
00200    60       CONTINUE
00201             DO 70 I = 1, N
00202                VALUE = MAX( VALUE, WORK( I ) )
00203    70       CONTINUE
00204          ELSE
00205             DO 80 I = 1, N
00206                WORK( I ) = ZERO
00207    80       CONTINUE
00208             DO 100 J = 1, N
00209                SUM = WORK( J ) + ABS( REAL( A( J, J ) ) )
00210                DO 90 I = J + 1, N
00211                   ABSA = ABS( A( I, J ) )
00212                   SUM = SUM + ABSA
00213                   WORK( I ) = WORK( I ) + ABSA
00214    90          CONTINUE
00215                VALUE = MAX( VALUE, SUM )
00216   100       CONTINUE
00217          END IF
00218       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
00219 *
00220 *        Find normF(A).
00221 *
00222          SCALE = ZERO
00223          SUM = ONE
00224          IF( LSAME( UPLO, 'U' ) ) THEN
00225             DO 110 J = 2, N
00226                CALL CLASSQ( J-1, A( 1, J ), 1, SCALE, SUM )
00227   110       CONTINUE
00228          ELSE
00229             DO 120 J = 1, N - 1
00230                CALL CLASSQ( N-J, A( J+1, J ), 1, SCALE, SUM )
00231   120       CONTINUE
00232          END IF
00233          SUM = 2*SUM
00234          DO 130 I = 1, N
00235             IF( REAL( A( I, I ) ).NE.ZERO ) THEN
00236                ABSA = ABS( REAL( A( I, I ) ) )
00237                IF( SCALE.LT.ABSA ) THEN
00238                   SUM = ONE + SUM*( SCALE / ABSA )**2
00239                   SCALE = ABSA
00240                ELSE
00241                   SUM = SUM + ( ABSA / SCALE )**2
00242                END IF
00243             END IF
00244   130    CONTINUE
00245          VALUE = SCALE*SQRT( SUM )
00246       END IF
00247 *
00248       CLANHE = VALUE
00249       RETURN
00250 *
00251 *     End of CLANHE
00252 *
00253       END
 All Files Functions