LAPACK 3.3.1
Linear Algebra PACKage

clansp.f

Go to the documentation of this file.
00001       REAL             FUNCTION CLANSP( NORM, UPLO, N, AP, 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            N
00011 *     ..
00012 *     .. Array Arguments ..
00013       REAL               WORK( * )
00014       COMPLEX            AP( * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  CLANSP  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 symmetric matrix A,  supplied in packed form.
00023 *
00024 *  Description
00025 *  ===========
00026 *
00027 *  CLANSP returns the value
00028 *
00029 *     CLANSP = ( 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 CLANSP as described
00047 *          above.
00048 *
00049 *  UPLO    (input) CHARACTER*1
00050 *          Specifies whether the upper or lower triangular part of the
00051 *          symmetric matrix A is supplied.
00052 *          = 'U':  Upper triangular part of A is supplied
00053 *          = 'L':  Lower triangular part of A is supplied
00054 *
00055 *  N       (input) INTEGER
00056 *          The order of the matrix A.  N >= 0.  When N = 0, CLANSP is
00057 *          set to zero.
00058 *
00059 *  AP      (input) COMPLEX array, dimension (N*(N+1)/2)
00060 *          The upper or lower triangle of the symmetric matrix A, packed
00061 *          columnwise in a linear array.  The j-th column of A is stored
00062 *          in the array AP as follows:
00063 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00064 *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
00065 *
00066 *  WORK    (workspace) REAL array, dimension (MAX(1,LWORK)),
00067 *          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
00068 *          WORK is not referenced.
00069 *
00070 * =====================================================================
00071 *
00072 *     .. Parameters ..
00073       REAL               ONE, ZERO
00074       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00075 *     ..
00076 *     .. Local Scalars ..
00077       INTEGER            I, J, K
00078       REAL               ABSA, SCALE, SUM, VALUE
00079 *     ..
00080 *     .. External Functions ..
00081       LOGICAL            LSAME
00082       EXTERNAL           LSAME
00083 *     ..
00084 *     .. External Subroutines ..
00085       EXTERNAL           CLASSQ
00086 *     ..
00087 *     .. Intrinsic Functions ..
00088       INTRINSIC          ABS, AIMAG, MAX, REAL, SQRT
00089 *     ..
00090 *     .. Executable Statements ..
00091 *
00092       IF( N.EQ.0 ) THEN
00093          VALUE = ZERO
00094       ELSE IF( LSAME( NORM, 'M' ) ) THEN
00095 *
00096 *        Find max(abs(A(i,j))).
00097 *
00098          VALUE = ZERO
00099          IF( LSAME( UPLO, 'U' ) ) THEN
00100             K = 1
00101             DO 20 J = 1, N
00102                DO 10 I = K, K + J - 1
00103                   VALUE = MAX( VALUE, ABS( AP( I ) ) )
00104    10          CONTINUE
00105                K = K + J
00106    20       CONTINUE
00107          ELSE
00108             K = 1
00109             DO 40 J = 1, N
00110                DO 30 I = K, K + N - J
00111                   VALUE = MAX( VALUE, ABS( AP( I ) ) )
00112    30          CONTINUE
00113                K = K + N - J + 1
00114    40       CONTINUE
00115          END IF
00116       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
00117      $         ( NORM.EQ.'1' ) ) THEN
00118 *
00119 *        Find normI(A) ( = norm1(A), since A is symmetric).
00120 *
00121          VALUE = ZERO
00122          K = 1
00123          IF( LSAME( UPLO, 'U' ) ) THEN
00124             DO 60 J = 1, N
00125                SUM = ZERO
00126                DO 50 I = 1, J - 1
00127                   ABSA = ABS( AP( K ) )
00128                   SUM = SUM + ABSA
00129                   WORK( I ) = WORK( I ) + ABSA
00130                   K = K + 1
00131    50          CONTINUE
00132                WORK( J ) = SUM + ABS( AP( K ) )
00133                K = K + 1
00134    60       CONTINUE
00135             DO 70 I = 1, N
00136                VALUE = MAX( VALUE, WORK( I ) )
00137    70       CONTINUE
00138          ELSE
00139             DO 80 I = 1, N
00140                WORK( I ) = ZERO
00141    80       CONTINUE
00142             DO 100 J = 1, N
00143                SUM = WORK( J ) + ABS( AP( K ) )
00144                K = K + 1
00145                DO 90 I = J + 1, N
00146                   ABSA = ABS( AP( K ) )
00147                   SUM = SUM + ABSA
00148                   WORK( I ) = WORK( I ) + ABSA
00149                   K = K + 1
00150    90          CONTINUE
00151                VALUE = MAX( VALUE, SUM )
00152   100       CONTINUE
00153          END IF
00154       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
00155 *
00156 *        Find normF(A).
00157 *
00158          SCALE = ZERO
00159          SUM = ONE
00160          K = 2
00161          IF( LSAME( UPLO, 'U' ) ) THEN
00162             DO 110 J = 2, N
00163                CALL CLASSQ( J-1, AP( K ), 1, SCALE, SUM )
00164                K = K + J
00165   110       CONTINUE
00166          ELSE
00167             DO 120 J = 1, N - 1
00168                CALL CLASSQ( N-J, AP( K ), 1, SCALE, SUM )
00169                K = K + N - J + 1
00170   120       CONTINUE
00171          END IF
00172          SUM = 2*SUM
00173          K = 1
00174          DO 130 I = 1, N
00175             IF( REAL( AP( K ) ).NE.ZERO ) THEN
00176                ABSA = ABS( REAL( AP( K ) ) )
00177                IF( SCALE.LT.ABSA ) THEN
00178                   SUM = ONE + SUM*( SCALE / ABSA )**2
00179                   SCALE = ABSA
00180                ELSE
00181                   SUM = SUM + ( ABSA / SCALE )**2
00182                END IF
00183             END IF
00184             IF( AIMAG( AP( K ) ).NE.ZERO ) THEN
00185                ABSA = ABS( AIMAG( AP( K ) ) )
00186                IF( SCALE.LT.ABSA ) THEN
00187                   SUM = ONE + SUM*( SCALE / ABSA )**2
00188                   SCALE = ABSA
00189                ELSE
00190                   SUM = SUM + ( ABSA / SCALE )**2
00191                END IF
00192             END IF
00193             IF( LSAME( UPLO, 'U' ) ) THEN
00194                K = K + I + 1
00195             ELSE
00196                K = K + N - I + 1
00197             END IF
00198   130    CONTINUE
00199          VALUE = SCALE*SQRT( SUM )
00200       END IF
00201 *
00202       CLANSP = VALUE
00203       RETURN
00204 *
00205 *     End of CLANSP
00206 *
00207       END
 All Files Functions