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