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.

sppt02.f 5.3 kB

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