1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
      SUBROUTINE DPTT01NDEDFEFWORKRESID )
*
*  -- LAPACK test routine (version 3.1) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     November 2006
*
*     .. Scalar Arguments ..
      INTEGER            N
      DOUBLE PRECISION   RESID
*     ..
*     .. Array Arguments ..
      DOUBLE PRECISION   D* ), DF* ), E* ), EF* ), WORK* )
*     ..
*
*  Purpose
*  =======
*
*  DPTT01 reconstructs a tridiagonal matrix A from its L*D*L'
*  factorization and computes the residual
*     norm(L*D*L' - A) / ( n * norm(A) * EPS ),
*  where EPS is the machine epsilon.
*
*  Arguments
*  =========
*
*  N       (input) INTEGTER
*          The order of the matrix A.
*
*  D       (input) DOUBLE PRECISION array, dimension (N)
*          The n diagonal elements of the tridiagonal matrix A.
*
*  E       (input) DOUBLE PRECISION array, dimension (N-1)
*          The (n-1) subdiagonal elements of the tridiagonal matrix A.
*
*  DF      (input) DOUBLE PRECISION array, dimension (N)
*          The n diagonal elements of the factor L from the L*D*L'
*          factorization of A.
*
*  EF      (input) DOUBLE PRECISION array, dimension (N-1)
*          The (n-1) subdiagonal elements of the factor L from the
*          L*D*L' factorization of A.
*
*  WORK    (workspace) DOUBLE PRECISION array, dimension (2*N)
*
*  RESID   (output) DOUBLE PRECISION
*          norm(L*D*L' - A) / (n * norm(A) * EPS)
*
*  =====================================================================
*
*     .. Parameters ..
      DOUBLE PRECISION   ONEZERO
      PARAMETER          ( ONE = 1.0D+0ZERO = 0.0D+0 )
*     ..
*     .. Local Scalars ..
      INTEGER            I
      DOUBLE PRECISION   ANORMDEEPS
*     ..
*     .. External Functions ..
      DOUBLE PRECISION   DLAMCH
      EXTERNAL           DLAMCH
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          ABSDBLEMAX
*     ..
*     .. Executable Statements ..
*
*     Quick return if possible
*
      IFN.LE.0 ) THEN
         RESID = ZERO
         RETURN
      END IF
*
      EPS = DLAMCH'Epsilon' )
*
*     Construct the difference L*D*L' - A.
*
      WORK1 ) = DF1 ) - D1 )
      DO 10 I = 1N - 1
         DE = DFI )*EFI )
         WORKN+I ) = DE - EI )
         WORK1+I ) = DE*EFI ) + DFI+1 ) - DI+1 )
   10 CONTINUE
*
*     Compute the 1-norms of the tridiagonal matrices A and WORK.
*
      IFN.EQ.1 ) THEN
         ANORM = D1 )
         RESID = ABSWORK1 ) )
      ELSE
         ANORM = MAXD1 )+ABSE1 ) ), DN )+ABSEN-1 ) ) )
         RESID = MAXABSWORK1 ) )+ABSWORKN+1 ) ),
     $           ABSWORKN ) )+ABSWORK2*N-1 ) ) )
         DO 20 I = 2N - 1
            ANORM = MAXANORMDI )+ABSEI ) )+ABSEI-1 ) ) )
            RESID = MAXRESIDABSWORKI ) )+ABSWORKN+I-1 ) )+
     $              ABSWORKN+I ) ) )
   20    CONTINUE
      END IF
*
*     Compute norm(L*D*L' - A) / (n * norm(A) * EPS)
*
      IFANORM.LE.ZERO ) THEN
         IFRESID.NE.ZERO )
     $      RESID = ONE / EPS
      ELSE
         RESID = ( ( RESID / DBLEN ) ) / ANORM ) / EPS
      END IF
*
      RETURN
*
*     End of DPTT01
*
      END