```001:       DOUBLE PRECISION FUNCTION DLANST( NORM, N, D, E )
002: *
003: *  -- LAPACK auxiliary routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       CHARACTER          NORM
010:       INTEGER            N
011: *     ..
012: *     .. Array Arguments ..
013:       DOUBLE PRECISION   D( * ), E( * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  DLANST  returns the value of the one norm,  or the Frobenius norm, or
020: *  the  infinity norm,  or the  element of  largest absolute value  of a
021: *  real symmetric tridiagonal matrix A.
022: *
023: *  Description
024: *  ===========
025: *
026: *  DLANST returns the value
027: *
028: *     DLANST = ( max(abs(A(i,j))), NORM = 'M' or 'm'
029: *              (
030: *              ( norm1(A),         NORM = '1', 'O' or 'o'
031: *              (
032: *              ( normI(A),         NORM = 'I' or 'i'
033: *              (
034: *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
035: *
036: *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
037: *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
038: *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
039: *  squares).  Note that  max(abs(A(i,j)))  is not a consistent matrix norm.
040: *
041: *  Arguments
042: *  =========
043: *
044: *  NORM    (input) CHARACTER*1
045: *          Specifies the value to be returned in DLANST as described
046: *          above.
047: *
048: *  N       (input) INTEGER
049: *          The order of the matrix A.  N >= 0.  When N = 0, DLANST is
050: *          set to zero.
051: *
052: *  D       (input) DOUBLE PRECISION array, dimension (N)
053: *          The diagonal elements of A.
054: *
055: *  E       (input) DOUBLE PRECISION array, dimension (N-1)
056: *          The (n-1) sub-diagonal or super-diagonal elements of A.
057: *
058: *  =====================================================================
059: *
060: *     .. Parameters ..
061:       DOUBLE PRECISION   ONE, ZERO
062:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
063: *     ..
064: *     .. Local Scalars ..
065:       INTEGER            I
066:       DOUBLE PRECISION   ANORM, SCALE, SUM
067: *     ..
068: *     .. External Functions ..
069:       LOGICAL            LSAME
070:       EXTERNAL           LSAME
071: *     ..
072: *     .. External Subroutines ..
073:       EXTERNAL           DLASSQ
074: *     ..
075: *     .. Intrinsic Functions ..
076:       INTRINSIC          ABS, MAX, SQRT
077: *     ..
078: *     .. Executable Statements ..
079: *
080:       IF( N.LE.0 ) THEN
081:          ANORM = ZERO
082:       ELSE IF( LSAME( NORM, 'M' ) ) THEN
083: *
084: *        Find max(abs(A(i,j))).
085: *
086:          ANORM = ABS( D( N ) )
087:          DO 10 I = 1, N - 1
088:             ANORM = MAX( ANORM, ABS( D( I ) ) )
089:             ANORM = MAX( ANORM, ABS( E( I ) ) )
090:    10    CONTINUE
091:       ELSE IF( LSAME( NORM, 'O' ) .OR. NORM.EQ.'1' .OR.
092:      \$         LSAME( NORM, 'I' ) ) THEN
093: *
094: *        Find norm1(A).
095: *
096:          IF( N.EQ.1 ) THEN
097:             ANORM = ABS( D( 1 ) )
098:          ELSE
099:             ANORM = MAX( ABS( D( 1 ) )+ABS( E( 1 ) ),
100:      \$              ABS( E( N-1 ) )+ABS( D( N ) ) )
101:             DO 20 I = 2, N - 1
102:                ANORM = MAX( ANORM, ABS( D( I ) )+ABS( E( I ) )+
103:      \$                 ABS( E( I-1 ) ) )
104:    20       CONTINUE
105:          END IF
106:       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
107: *
108: *        Find normF(A).
109: *
110:          SCALE = ZERO
111:          SUM = ONE
112:          IF( N.GT.1 ) THEN
113:             CALL DLASSQ( N-1, E, 1, SCALE, SUM )
114:             SUM = 2*SUM
115:          END IF
116:          CALL DLASSQ( N, D, 1, SCALE, SUM )
117:          ANORM = SCALE*SQRT( SUM )
118:       END IF
119: *
120:       DLANST = ANORM
121:       RETURN
122: *
123: *     End of DLANST
124: *
125:       END
126: ```