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.

cgbt02.f 7.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. *> \brief \b CGBT02
  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 CGBT02( TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B,
  12. * LDB, RWORK, RESID )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER TRANS
  16. * INTEGER KL, KU, LDA, LDB, LDX, M, N, NRHS
  17. * REAL RESID
  18. * ..
  19. * .. Array Arguments ..
  20. * REAL RWORK( * )
  21. * COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * )
  22. * ..
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> CGBT02 computes the residual for a solution of a banded system of
  31. *> equations op(A)*X = B:
  32. *> RESID = norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ),
  33. *> where op(A) = A, A**T, or A**H, depending on TRANS, and EPS is the
  34. *> machine epsilon.
  35. *> \endverbatim
  36. *
  37. * Arguments:
  38. * ==========
  39. *
  40. *> \param[in] TRANS
  41. *> \verbatim
  42. *> TRANS is CHARACTER*1
  43. *> Specifies the form of the system of equations:
  44. *> = 'N': A * X = B (No transpose)
  45. *> = 'T': A**T * X = B (Transpose)
  46. *> = 'C': A**H * X = B (Conjugate transpose)
  47. *> \endverbatim
  48. *>
  49. *> \param[in] M
  50. *> \verbatim
  51. *> M is INTEGER
  52. *> The number of rows of the matrix A. M >= 0.
  53. *> \endverbatim
  54. *>
  55. *> \param[in] N
  56. *> \verbatim
  57. *> N is INTEGER
  58. *> The number of columns of the matrix A. N >= 0.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] KL
  62. *> \verbatim
  63. *> KL is INTEGER
  64. *> The number of subdiagonals within the band of A. KL >= 0.
  65. *> \endverbatim
  66. *>
  67. *> \param[in] KU
  68. *> \verbatim
  69. *> KU is INTEGER
  70. *> The number of superdiagonals within the band of A. KU >= 0.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] NRHS
  74. *> \verbatim
  75. *> NRHS is INTEGER
  76. *> The number of columns of B. NRHS >= 0.
  77. *> \endverbatim
  78. *>
  79. *> \param[in] A
  80. *> \verbatim
  81. *> A is COMPLEX array, dimension (LDA,N)
  82. *> The original matrix A in band storage, stored in rows 1 to
  83. *> KL+KU+1.
  84. *> \endverbatim
  85. *>
  86. *> \param[in] LDA
  87. *> \verbatim
  88. *> LDA is INTEGER
  89. *> The leading dimension of the array A. LDA >= max(1,KL+KU+1).
  90. *> \endverbatim
  91. *>
  92. *> \param[in] X
  93. *> \verbatim
  94. *> X is COMPLEX array, dimension (LDX,NRHS)
  95. *> The computed solution vectors for the system of linear
  96. *> equations.
  97. *> \endverbatim
  98. *>
  99. *> \param[in] LDX
  100. *> \verbatim
  101. *> LDX is INTEGER
  102. *> The leading dimension of the array X. If TRANS = 'N',
  103. *> LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M).
  104. *> \endverbatim
  105. *>
  106. *> \param[in,out] B
  107. *> \verbatim
  108. *> B is COMPLEX array, dimension (LDB,NRHS)
  109. *> On entry, the right hand side vectors for the system of
  110. *> linear equations.
  111. *> On exit, B is overwritten with the difference B - A*X.
  112. *> \endverbatim
  113. *>
  114. *> \param[in] LDB
  115. *> \verbatim
  116. *> LDB is INTEGER
  117. *> The leading dimension of the array B. IF TRANS = 'N',
  118. *> LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
  119. *> \endverbatim
  120. *>
  121. *> \param[out] RWORK
  122. *> \verbatim
  123. *> RWORK is REAL array, dimension (MAX(1,LRWORK)),
  124. *> where LRWORK >= M when TRANS = 'T' or 'C'; otherwise, RWORK
  125. *> is not referenced.
  126. *> \endverbatim
  127. *
  128. *> \param[out] RESID
  129. *> \verbatim
  130. *> RESID is REAL
  131. *> The maximum over the number of right hand sides of
  132. *> norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ).
  133. *> \endverbatim
  134. *
  135. * Authors:
  136. * ========
  137. *
  138. *> \author Univ. of Tennessee
  139. *> \author Univ. of California Berkeley
  140. *> \author Univ. of Colorado Denver
  141. *> \author NAG Ltd.
  142. *
  143. *> \ingroup complex_lin
  144. *
  145. * =====================================================================
  146. SUBROUTINE CGBT02( TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B,
  147. $ LDB, RWORK, RESID )
  148. *
  149. * -- LAPACK test routine --
  150. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  151. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  152. *
  153. * .. Scalar Arguments ..
  154. CHARACTER TRANS
  155. INTEGER KL, KU, LDA, LDB, LDX, M, N, NRHS
  156. REAL RESID
  157. * ..
  158. * .. Array Arguments ..
  159. REAL RWORK( * )
  160. COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * )
  161. * ..
  162. *
  163. * =====================================================================
  164. *
  165. * .. Parameters ..
  166. REAL ZERO, ONE
  167. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  168. COMPLEX CONE
  169. PARAMETER ( CONE = ( 1.0E+0, 0.0E+0 ) )
  170. * ..
  171. * .. Local Scalars ..
  172. INTEGER I1, I2, J, KD, N1
  173. REAL ANORM, BNORM, EPS, TEMP, XNORM
  174. COMPLEX CDUM
  175. * ..
  176. * .. External Functions ..
  177. LOGICAL LSAME, SISNAN
  178. REAL SCASUM, SLAMCH
  179. EXTERNAL LSAME, SCASUM, SISNAN, SLAMCH
  180. * ..
  181. * .. External Subroutines ..
  182. EXTERNAL CGBMV
  183. * ..
  184. * .. Statement Functions ..
  185. REAL CABS1
  186. * ..
  187. * .. Intrinsic Functions ..
  188. INTRINSIC ABS, AIMAG, MAX, MIN, REAL
  189. * ..
  190. * .. Statement Function definitions ..
  191. CABS1( CDUM ) = ABS( REAL( CDUM ) ) + ABS( AIMAG( CDUM ) )
  192. * ..
  193. * .. Executable Statements ..
  194. *
  195. * Quick return if N = 0 pr NRHS = 0
  196. *
  197. IF( M.LE.0 .OR. N.LE.0 .OR. NRHS.LE.0 ) THEN
  198. RESID = ZERO
  199. RETURN
  200. END IF
  201. *
  202. * Exit with RESID = 1/EPS if ANORM = 0.
  203. *
  204. EPS = SLAMCH( 'Epsilon' )
  205. ANORM = ZERO
  206. IF( LSAME( TRANS, 'N' ) ) THEN
  207. *
  208. * Find norm1(A).
  209. *
  210. KD = KU + 1
  211. DO 10 J = 1, N
  212. I1 = MAX( KD+1-J, 1 )
  213. I2 = MIN( KD+M-J, KL+KD )
  214. IF( I2.GE.I1 ) THEN
  215. TEMP = SCASUM( I2-I1+1, A( I1, J ), 1 )
  216. IF( ANORM.LT.TEMP .OR. SISNAN( TEMP ) ) ANORM = TEMP
  217. END IF
  218. 10 CONTINUE
  219. ELSE
  220. *
  221. * Find normI(A).
  222. *
  223. DO 12 I1 = 1, M
  224. RWORK( I1 ) = ZERO
  225. 12 CONTINUE
  226. DO 16 J = 1, N
  227. KD = KU + 1 - J
  228. DO 14 I1 = MAX( 1, J-KU ), MIN( M, J+KL )
  229. RWORK( I1 ) = RWORK( I1 ) + CABS1( A( KD+I1, J ) )
  230. 14 CONTINUE
  231. 16 CONTINUE
  232. DO 18 I1 = 1, M
  233. TEMP = RWORK( I1 )
  234. IF( ANORM.LT.TEMP .OR. SISNAN( TEMP ) ) ANORM = TEMP
  235. 18 CONTINUE
  236. END IF
  237. IF( ANORM.LE.ZERO ) THEN
  238. RESID = ONE / EPS
  239. RETURN
  240. END IF
  241. *
  242. IF( LSAME( TRANS, 'T' ) .OR. LSAME( TRANS, 'C' ) ) THEN
  243. N1 = N
  244. ELSE
  245. N1 = M
  246. END IF
  247. *
  248. * Compute B - op(A)*X
  249. *
  250. DO 20 J = 1, NRHS
  251. CALL CGBMV( TRANS, M, N, KL, KU, -CONE, A, LDA, X( 1, J ), 1,
  252. $ CONE, B( 1, J ), 1 )
  253. 20 CONTINUE
  254. *
  255. * Compute the maximum over the number of right hand sides of
  256. * norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ).
  257. *
  258. RESID = ZERO
  259. DO 30 J = 1, NRHS
  260. BNORM = SCASUM( N1, B( 1, J ), 1 )
  261. XNORM = SCASUM( N1, X( 1, J ), 1 )
  262. IF( XNORM.LE.ZERO ) THEN
  263. RESID = ONE / EPS
  264. ELSE
  265. RESID = MAX( RESID, ( ( BNORM/ANORM )/XNORM )/EPS )
  266. END IF
  267. 30 CONTINUE
  268. *
  269. RETURN
  270. *
  271. * End of CGBT02
  272. *
  273. END