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.

spot02.f 5.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. *> \brief \b SPOT02
  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 SPOT02( UPLO, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK,
  12. * RESID )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER UPLO
  16. * INTEGER LDA, LDB, LDX, N, NRHS
  17. * REAL RESID
  18. * ..
  19. * .. Array Arguments ..
  20. * REAL A( LDA, * ), B( LDB, * ), RWORK( * ),
  21. * $ X( LDX, * )
  22. * ..
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> SPOT02 computes the residual for the solution of a symmetric system
  31. *> of linear equations A*x = b:
  32. *>
  33. *> RESID = norm(B - A*X) / ( norm(A) * norm(X) * EPS ),
  34. *>
  35. *> where EPS is the machine epsilon.
  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 (LDA,N)
  66. *> The original symmetric matrix A.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] LDA
  70. *> \verbatim
  71. *> LDA is INTEGER
  72. *> The leading dimension of the array A. LDA >= max(1,N)
  73. *> \endverbatim
  74. *>
  75. *> \param[in] X
  76. *> \verbatim
  77. *> X is REAL array, dimension (LDX,NRHS)
  78. *> The computed solution vectors for the system of linear
  79. *> equations.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] LDX
  83. *> \verbatim
  84. *> LDX is INTEGER
  85. *> The leading dimension of the array X. LDX >= max(1,N).
  86. *> \endverbatim
  87. *>
  88. *> \param[in,out] B
  89. *> \verbatim
  90. *> B is REAL array, dimension (LDB,NRHS)
  91. *> On entry, the right hand side vectors for the system of
  92. *> linear equations.
  93. *> On exit, B is overwritten with the difference B - A*X.
  94. *> \endverbatim
  95. *>
  96. *> \param[in] LDB
  97. *> \verbatim
  98. *> LDB is INTEGER
  99. *> The leading dimension of the array B. LDB >= max(1,N).
  100. *> \endverbatim
  101. *>
  102. *> \param[out] RWORK
  103. *> \verbatim
  104. *> RWORK is REAL array, dimension (N)
  105. *> \endverbatim
  106. *>
  107. *> \param[out] RESID
  108. *> \verbatim
  109. *> RESID is REAL
  110. *> The maximum over the number of right hand sides of
  111. *> norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
  112. *> \endverbatim
  113. *
  114. * Authors:
  115. * ========
  116. *
  117. *> \author Univ. of Tennessee
  118. *> \author Univ. of California Berkeley
  119. *> \author Univ. of Colorado Denver
  120. *> \author NAG Ltd.
  121. *
  122. *> \ingroup single_lin
  123. *
  124. * =====================================================================
  125. SUBROUTINE SPOT02( UPLO, N, NRHS, A, LDA, X, LDX, B, LDB, RWORK,
  126. $ RESID )
  127. *
  128. * -- LAPACK test routine --
  129. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  130. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  131. *
  132. * .. Scalar Arguments ..
  133. CHARACTER UPLO
  134. INTEGER LDA, LDB, LDX, N, NRHS
  135. REAL RESID
  136. * ..
  137. * .. Array Arguments ..
  138. REAL A( LDA, * ), B( LDB, * ), RWORK( * ),
  139. $ X( LDX, * )
  140. * ..
  141. *
  142. * =====================================================================
  143. *
  144. * .. Parameters ..
  145. REAL ZERO, ONE
  146. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  147. * ..
  148. * .. Local Scalars ..
  149. INTEGER J
  150. REAL ANORM, BNORM, EPS, XNORM
  151. * ..
  152. * .. External Functions ..
  153. REAL SASUM, SLAMCH, SLANSY
  154. EXTERNAL SASUM, SLAMCH, SLANSY
  155. * ..
  156. * .. External Subroutines ..
  157. EXTERNAL SSYMM
  158. * ..
  159. * .. Intrinsic Functions ..
  160. INTRINSIC MAX
  161. * ..
  162. * .. Executable Statements ..
  163. *
  164. * Quick exit if N = 0 or NRHS = 0.
  165. *
  166. IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
  167. RESID = ZERO
  168. RETURN
  169. END IF
  170. *
  171. * Exit with RESID = 1/EPS if ANORM = 0.
  172. *
  173. EPS = SLAMCH( 'Epsilon' )
  174. ANORM = SLANSY( '1', UPLO, N, A, LDA, RWORK )
  175. IF( ANORM.LE.ZERO ) THEN
  176. RESID = ONE / EPS
  177. RETURN
  178. END IF
  179. *
  180. * Compute B - A*X
  181. *
  182. CALL SSYMM( 'Left', UPLO, N, NRHS, -ONE, A, LDA, X, LDX, ONE, B,
  183. $ LDB )
  184. *
  185. * Compute the maximum over the number of right hand sides of
  186. * norm( B - A*X ) / ( norm(A) * norm(X) * EPS ) .
  187. *
  188. RESID = ZERO
  189. DO 10 J = 1, NRHS
  190. BNORM = SASUM( N, B( 1, J ), 1 )
  191. XNORM = SASUM( N, X( 1, J ), 1 )
  192. IF( XNORM.LE.ZERO ) THEN
  193. RESID = ONE / EPS
  194. ELSE
  195. RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )
  196. END IF
  197. 10 CONTINUE
  198. *
  199. RETURN
  200. *
  201. * End of SPOT02
  202. *
  203. END