LAPACK 3.3.0

dlansp.f

Go to the documentation of this file.
00001       DOUBLE PRECISION FUNCTION DLANSP( 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       DOUBLE PRECISION   AP( * ), WORK( * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  DLANSP  returns the value of the one norm,  or the Frobenius norm, or
00020 *  the  infinity norm,  or the  element of  largest absolute value  of a
00021 *  real symmetric matrix A,  supplied in packed form.
00022 *
00023 *  Description
00024 *  ===========
00025 *
00026 *  DLANSP returns the value
00027 *
00028 *     DLANSP = ( max(abs(A(i,j))), NORM = 'M' or 'm'
00029 *              (
00030 *              ( norm1(A),         NORM = '1', 'O' or 'o'
00031 *              (
00032 *              ( normI(A),         NORM = 'I' or 'i'
00033 *              (
00034 *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
00035 *
00036 *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
00037 *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
00038 *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
00039 *  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
00040 *
00041 *  Arguments
00042 *  =========
00043 *
00044 *  NORM    (input) CHARACTER*1
00045 *          Specifies the value to be returned in DLANSP as described
00046 *          above.
00047 *
00048 *  UPLO    (input) CHARACTER*1
00049 *          Specifies whether the upper or lower triangular part of the
00050 *          symmetric matrix A is supplied.
00051 *          = 'U':  Upper triangular part of A is supplied
00052 *          = 'L':  Lower triangular part of A is supplied
00053 *
00054 *  N       (input) INTEGER
00055 *          The order of the matrix A.  N >= 0.  When N = 0, DLANSP is
00056 *          set to zero.
00057 *
00058 *  AP      (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
00059 *          The upper or lower triangle of the symmetric matrix A, packed
00060 *          columnwise in a linear array.  The j-th column of A is stored
00061 *          in the array AP as follows:
00062 *          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
00063 *          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
00064 *
00065 *  WORK    (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
00066 *          where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
00067 *          WORK is not referenced.
00068 *
00069 * =====================================================================
00070 *
00071 *     .. Parameters ..
00072       DOUBLE PRECISION   ONE, ZERO
00073       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
00074 *     ..
00075 *     .. Local Scalars ..
00076       INTEGER            I, J, K
00077       DOUBLE PRECISION   ABSA, SCALE, SUM, VALUE
00078 *     ..
00079 *     .. External Subroutines ..
00080       EXTERNAL           DLASSQ
00081 *     ..
00082 *     .. External Functions ..
00083       LOGICAL            LSAME
00084       EXTERNAL           LSAME
00085 *     ..
00086 *     .. Intrinsic Functions ..
00087       INTRINSIC          ABS, MAX, SQRT
00088 *     ..
00089 *     .. Executable Statements ..
00090 *
00091       IF( N.EQ.0 ) THEN
00092          VALUE = ZERO
00093       ELSE IF( LSAME( NORM, 'M' ) ) THEN
00094 *
00095 *        Find max(abs(A(i,j))).
00096 *
00097          VALUE = ZERO
00098          IF( LSAME( UPLO, 'U' ) ) THEN
00099             K = 1
00100             DO 20 J = 1, N
00101                DO 10 I = K, K + J - 1
00102                   VALUE = MAX( VALUE, ABS( AP( I ) ) )
00103    10          CONTINUE
00104                K = K + J
00105    20       CONTINUE
00106          ELSE
00107             K = 1
00108             DO 40 J = 1, N
00109                DO 30 I = K, K + N - J
00110                   VALUE = MAX( VALUE, ABS( AP( I ) ) )
00111    30          CONTINUE
00112                K = K + N - J + 1
00113    40       CONTINUE
00114          END IF
00115       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
00116      $         ( NORM.EQ.'1' ) ) THEN
00117 *
00118 *        Find normI(A) ( = norm1(A), since A is symmetric).
00119 *
00120          VALUE = ZERO
00121          K = 1
00122          IF( LSAME( UPLO, 'U' ) ) THEN
00123             DO 60 J = 1, N
00124                SUM = ZERO
00125                DO 50 I = 1, J - 1
00126                   ABSA = ABS( AP( K ) )
00127                   SUM = SUM + ABSA
00128                   WORK( I ) = WORK( I ) + ABSA
00129                   K = K + 1
00130    50          CONTINUE
00131                WORK( J ) = SUM + ABS( AP( K ) )
00132                K = K + 1
00133    60       CONTINUE
00134             DO 70 I = 1, N
00135                VALUE = MAX( VALUE, WORK( I ) )
00136    70       CONTINUE
00137          ELSE
00138             DO 80 I = 1, N
00139                WORK( I ) = ZERO
00140    80       CONTINUE
00141             DO 100 J = 1, N
00142                SUM = WORK( J ) + ABS( AP( K ) )
00143                K = K + 1
00144                DO 90 I = J + 1, N
00145                   ABSA = ABS( AP( K ) )
00146                   SUM = SUM + ABSA
00147                   WORK( I ) = WORK( I ) + ABSA
00148                   K = K + 1
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          K = 2
00160          IF( LSAME( UPLO, 'U' ) ) THEN
00161             DO 110 J = 2, N
00162                CALL DLASSQ( J-1, AP( K ), 1, SCALE, SUM )
00163                K = K + J
00164   110       CONTINUE
00165          ELSE
00166             DO 120 J = 1, N - 1
00167                CALL DLASSQ( N-J, AP( K ), 1, SCALE, SUM )
00168                K = K + N - J + 1
00169   120       CONTINUE
00170          END IF
00171          SUM = 2*SUM
00172          K = 1
00173          DO 130 I = 1, N
00174             IF( AP( K ).NE.ZERO ) THEN
00175                ABSA = ABS( AP( K ) )
00176                IF( SCALE.LT.ABSA ) THEN
00177                   SUM = ONE + SUM*( SCALE / ABSA )**2
00178                   SCALE = ABSA
00179                ELSE
00180                   SUM = SUM + ( ABSA / SCALE )**2
00181                END IF
00182             END IF
00183             IF( LSAME( UPLO, 'U' ) ) THEN
00184                K = K + I + 1
00185             ELSE
00186                K = K + N - I + 1
00187             END IF
00188   130    CONTINUE
00189          VALUE = SCALE*SQRT( SUM )
00190       END IF
00191 *
00192       DLANSP = VALUE
00193       RETURN
00194 *
00195 *     End of DLANSP
00196 *
00197       END
 All Files Functions