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.

cptt02.f 5.0 kB

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