You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sptt01.f 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. *> \brief \b SPTT01
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * SUBROUTINE SPTT01( N, D, E, DF, EF, WORK, RESID )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER N
  15. * REAL RESID
  16. * ..
  17. * .. Array Arguments ..
  18. * REAL D( * ), DF( * ), E( * ), EF( * ), WORK( * )
  19. * ..
  20. *
  21. *
  22. *> \par Purpose:
  23. * =============
  24. *>
  25. *> \verbatim
  26. *>
  27. *> SPTT01 reconstructs a tridiagonal matrix A from its L*D*L'
  28. *> factorization and computes the residual
  29. *> norm(L*D*L' - A) / ( n * norm(A) * EPS ),
  30. *> where EPS is the machine epsilon.
  31. *> \endverbatim
  32. *
  33. * Arguments:
  34. * ==========
  35. *
  36. *> \param[in] N
  37. *> \verbatim
  38. *> N is INTEGTER
  39. *> The order of the matrix A.
  40. *> \endverbatim
  41. *>
  42. *> \param[in] D
  43. *> \verbatim
  44. *> D is REAL array, dimension (N)
  45. *> The n diagonal elements of the tridiagonal matrix A.
  46. *> \endverbatim
  47. *>
  48. *> \param[in] E
  49. *> \verbatim
  50. *> E is REAL array, dimension (N-1)
  51. *> The (n-1) subdiagonal elements of the tridiagonal matrix A.
  52. *> \endverbatim
  53. *>
  54. *> \param[in] DF
  55. *> \verbatim
  56. *> DF is REAL array, dimension (N)
  57. *> The n diagonal elements of the factor L from the L*D*L'
  58. *> factorization of A.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] EF
  62. *> \verbatim
  63. *> EF is REAL array, dimension (N-1)
  64. *> The (n-1) subdiagonal elements of the factor L from the
  65. *> L*D*L' factorization of A.
  66. *> \endverbatim
  67. *>
  68. *> \param[out] WORK
  69. *> \verbatim
  70. *> WORK is REAL array, dimension (2*N)
  71. *> \endverbatim
  72. *>
  73. *> \param[out] RESID
  74. *> \verbatim
  75. *> RESID is REAL
  76. *> norm(L*D*L' - A) / (n * norm(A) * EPS)
  77. *> \endverbatim
  78. *
  79. * Authors:
  80. * ========
  81. *
  82. *> \author Univ. of Tennessee
  83. *> \author Univ. of California Berkeley
  84. *> \author Univ. of Colorado Denver
  85. *> \author NAG Ltd.
  86. *
  87. *> \ingroup single_lin
  88. *
  89. * =====================================================================
  90. SUBROUTINE SPTT01( N, D, E, DF, EF, WORK, RESID )
  91. *
  92. * -- LAPACK test routine --
  93. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  94. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  95. *
  96. * .. Scalar Arguments ..
  97. INTEGER N
  98. REAL RESID
  99. * ..
  100. * .. Array Arguments ..
  101. REAL D( * ), DF( * ), E( * ), EF( * ), WORK( * )
  102. * ..
  103. *
  104. * =====================================================================
  105. *
  106. * .. Parameters ..
  107. REAL ONE, ZERO
  108. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  109. * ..
  110. * .. Local Scalars ..
  111. INTEGER I
  112. REAL ANORM, DE, EPS
  113. * ..
  114. * .. External Functions ..
  115. REAL SLAMCH
  116. EXTERNAL SLAMCH
  117. * ..
  118. * .. Intrinsic Functions ..
  119. INTRINSIC ABS, MAX, REAL
  120. * ..
  121. * .. Executable Statements ..
  122. *
  123. * Quick return if possible
  124. *
  125. IF( N.LE.0 ) THEN
  126. RESID = ZERO
  127. RETURN
  128. END IF
  129. *
  130. EPS = SLAMCH( 'Epsilon' )
  131. *
  132. * Construct the difference L*D*L' - A.
  133. *
  134. WORK( 1 ) = DF( 1 ) - D( 1 )
  135. DO 10 I = 1, N - 1
  136. DE = DF( I )*EF( I )
  137. WORK( N+I ) = DE - E( I )
  138. WORK( 1+I ) = DE*EF( I ) + DF( I+1 ) - D( I+1 )
  139. 10 CONTINUE
  140. *
  141. * Compute the 1-norms of the tridiagonal matrices A and WORK.
  142. *
  143. IF( N.EQ.1 ) THEN
  144. ANORM = D( 1 )
  145. RESID = ABS( WORK( 1 ) )
  146. ELSE
  147. ANORM = MAX( D( 1 )+ABS( E( 1 ) ), D( N )+ABS( E( N-1 ) ) )
  148. RESID = MAX( ABS( WORK( 1 ) )+ABS( WORK( N+1 ) ),
  149. $ ABS( WORK( N ) )+ABS( WORK( 2*N-1 ) ) )
  150. DO 20 I = 2, N - 1
  151. ANORM = MAX( ANORM, D( I )+ABS( E( I ) )+ABS( E( I-1 ) ) )
  152. RESID = MAX( RESID, ABS( WORK( I ) )+ABS( WORK( N+I-1 ) )+
  153. $ ABS( WORK( N+I ) ) )
  154. 20 CONTINUE
  155. END IF
  156. *
  157. * Compute norm(L*D*L' - A) / (n * norm(A) * EPS)
  158. *
  159. IF( ANORM.LE.ZERO ) THEN
  160. IF( RESID.NE.ZERO )
  161. $ RESID = ONE / EPS
  162. ELSE
  163. RESID = ( ( RESID / REAL( N ) ) / ANORM ) / EPS
  164. END IF
  165. *
  166. RETURN
  167. *
  168. * End of SPTT01
  169. *
  170. END