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.

sptt02.f 4.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. *> \brief \b SPTT02
  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 SPTT02( N, NRHS, D, E, X, LDX, B, LDB, RESID )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER LDB, LDX, N, NRHS
  15. * REAL RESID
  16. * ..
  17. * .. Array Arguments ..
  18. * REAL B( LDB, * ), D( * ), E( * ), X( LDX, * )
  19. * ..
  20. *
  21. *
  22. *> \par Purpose:
  23. * =============
  24. *>
  25. *> \verbatim
  26. *>
  27. *> SPTT02 computes the residual for the solution to a symmetric
  28. *> tridiagonal system of equations:
  29. *> RESID = norm(B - A*X) / (norm(A) * norm(X) * EPS),
  30. *> where EPS is the machine epsilon.
  31. *> \endverbatim
  32. *
  33. * Arguments:
  34. * ==========
  35. *
  36. *> \param[in] N
  37. *> \verbatim
  38. *> N is INTEGER
  39. *> The order of the matrix A.
  40. *> \endverbatim
  41. *>
  42. *> \param[in] NRHS
  43. *> \verbatim
  44. *> NRHS is INTEGER
  45. *> The number of right hand sides, i.e., the number of columns
  46. *> of the matrices B and X. NRHS >= 0.
  47. *> \endverbatim
  48. *>
  49. *> \param[in] D
  50. *> \verbatim
  51. *> D is REAL array, dimension (N)
  52. *> The n diagonal elements of the tridiagonal matrix A.
  53. *> \endverbatim
  54. *>
  55. *> \param[in] E
  56. *> \verbatim
  57. *> E is REAL array, dimension (N-1)
  58. *> The (n-1) subdiagonal elements of the tridiagonal matrix A.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] X
  62. *> \verbatim
  63. *> X is REAL array, dimension (LDX,NRHS)
  64. *> The n by nrhs matrix of solution vectors X.
  65. *> \endverbatim
  66. *>
  67. *> \param[in] LDX
  68. *> \verbatim
  69. *> LDX is INTEGER
  70. *> The leading dimension of the array X. LDX >= max(1,N).
  71. *> \endverbatim
  72. *>
  73. *> \param[in,out] B
  74. *> \verbatim
  75. *> B is REAL array, dimension (LDB,NRHS)
  76. *> On entry, the n by nrhs matrix of right hand side vectors B.
  77. *> On exit, B is overwritten with the difference B - A*X.
  78. *> \endverbatim
  79. *>
  80. *> \param[in] LDB
  81. *> \verbatim
  82. *> LDB is INTEGER
  83. *> The leading dimension of the array B. LDB >= max(1,N).
  84. *> \endverbatim
  85. *>
  86. *> \param[out] RESID
  87. *> \verbatim
  88. *> RESID is REAL
  89. *> norm(B - A*X) / (norm(A) * norm(X) * EPS)
  90. *> \endverbatim
  91. *
  92. * Authors:
  93. * ========
  94. *
  95. *> \author Univ. of Tennessee
  96. *> \author Univ. of California Berkeley
  97. *> \author Univ. of Colorado Denver
  98. *> \author NAG Ltd.
  99. *
  100. *> \ingroup single_lin
  101. *
  102. * =====================================================================
  103. SUBROUTINE SPTT02( N, NRHS, D, E, X, LDX, B, LDB, RESID )
  104. *
  105. * -- LAPACK test routine --
  106. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  107. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  108. *
  109. * .. Scalar Arguments ..
  110. INTEGER LDB, LDX, N, NRHS
  111. REAL RESID
  112. * ..
  113. * .. Array Arguments ..
  114. REAL B( LDB, * ), D( * ), E( * ), X( LDX, * )
  115. * ..
  116. *
  117. * =====================================================================
  118. *
  119. * .. Parameters ..
  120. REAL ONE, ZERO
  121. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  122. * ..
  123. * .. Local Scalars ..
  124. INTEGER J
  125. REAL ANORM, BNORM, EPS, XNORM
  126. * ..
  127. * .. External Functions ..
  128. REAL SASUM, SLAMCH, SLANST
  129. EXTERNAL SASUM, SLAMCH, SLANST
  130. * ..
  131. * .. Intrinsic Functions ..
  132. INTRINSIC MAX
  133. * ..
  134. * .. External Subroutines ..
  135. EXTERNAL SLAPTM
  136. * ..
  137. * .. Executable Statements ..
  138. *
  139. * Quick return if possible
  140. *
  141. IF( N.LE.0 ) THEN
  142. RESID = ZERO
  143. RETURN
  144. END IF
  145. *
  146. * Compute the 1-norm of the tridiagonal matrix A.
  147. *
  148. ANORM = SLANST( '1', N, D, E )
  149. *
  150. * Exit with RESID = 1/EPS if ANORM = 0.
  151. *
  152. EPS = SLAMCH( 'Epsilon' )
  153. IF( ANORM.LE.ZERO ) THEN
  154. RESID = ONE / EPS
  155. RETURN
  156. END IF
  157. *
  158. * Compute B - A*X.
  159. *
  160. CALL SLAPTM( N, NRHS, -ONE, D, E, X, LDX, ONE, B, LDB )
  161. *
  162. * Compute the maximum over the number of right hand sides of
  163. * norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
  164. *
  165. RESID = ZERO
  166. DO 10 J = 1, NRHS
  167. BNORM = SASUM( N, B( 1, J ), 1 )
  168. XNORM = SASUM( N, X( 1, J ), 1 )
  169. IF( XNORM.LE.ZERO ) THEN
  170. RESID = ONE / EPS
  171. ELSE
  172. RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
  173. END IF
  174. 10 CONTINUE
  175. *
  176. RETURN
  177. *
  178. * End of SPTT02
  179. *
  180. END