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.

cget07.f 8.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. *> \brief \b CGET07
  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 CGET07( TRANS, N, NRHS, A, LDA, B, LDB, X, LDX, XACT,
  12. * LDXACT, FERR, CHKFERR, BERR, RESLTS )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER TRANS
  16. * LOGICAL CHKFERR
  17. * INTEGER LDA, LDB, LDX, LDXACT, N, NRHS
  18. * ..
  19. * .. Array Arguments ..
  20. * REAL BERR( * ), FERR( * ), RESLTS( * )
  21. * COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * ),
  22. * $ XACT( LDXACT, * )
  23. * ..
  24. *
  25. *
  26. *> \par Purpose:
  27. * =============
  28. *>
  29. *> \verbatim
  30. *>
  31. *> CGET07 tests the error bounds from iterative refinement for the
  32. *> computed solution to a system of equations op(A)*X = B, where A is a
  33. *> general n by n matrix and op(A) = A or A**T, depending on TRANS.
  34. *>
  35. *> RESLTS(1) = test of the error bound
  36. *> = norm(X - XACT) / ( norm(X) * FERR )
  37. *>
  38. *> A large value is returned if this ratio is not less than one.
  39. *>
  40. *> RESLTS(2) = residual from the iterative refinement routine
  41. *> = the maximum of BERR / ( (n+1)*EPS + (*) ), where
  42. *> (*) = (n+1)*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i )
  43. *> \endverbatim
  44. *
  45. * Arguments:
  46. * ==========
  47. *
  48. *> \param[in] TRANS
  49. *> \verbatim
  50. *> TRANS is CHARACTER*1
  51. *> Specifies the form of the system of equations.
  52. *> = 'N': A * X = B (No transpose)
  53. *> = 'T': A**T * X = B (Transpose)
  54. *> = 'C': A**H * X = B (Conjugate transpose = Transpose)
  55. *> \endverbatim
  56. *>
  57. *> \param[in] N
  58. *> \verbatim
  59. *> N is INTEGER
  60. *> The number of rows of the matrices X and XACT. N >= 0.
  61. *> \endverbatim
  62. *>
  63. *> \param[in] NRHS
  64. *> \verbatim
  65. *> NRHS is INTEGER
  66. *> The number of columns of the matrices X and XACT. NRHS >= 0.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] A
  70. *> \verbatim
  71. *> A is COMPLEX array, dimension (LDA,N)
  72. *> The original n by n matrix A.
  73. *> \endverbatim
  74. *>
  75. *> \param[in] LDA
  76. *> \verbatim
  77. *> LDA is INTEGER
  78. *> The leading dimension of the array A. LDA >= max(1,N).
  79. *> \endverbatim
  80. *>
  81. *> \param[in] B
  82. *> \verbatim
  83. *> B is COMPLEX array, dimension (LDB,NRHS)
  84. *> The right hand side vectors for the system of linear
  85. *> equations.
  86. *> \endverbatim
  87. *>
  88. *> \param[in] LDB
  89. *> \verbatim
  90. *> LDB is INTEGER
  91. *> The leading dimension of the array B. LDB >= max(1,N).
  92. *> \endverbatim
  93. *>
  94. *> \param[in] X
  95. *> \verbatim
  96. *> X is COMPLEX array, dimension (LDX,NRHS)
  97. *> The computed solution vectors. Each vector is stored as a
  98. *> column of the matrix X.
  99. *> \endverbatim
  100. *>
  101. *> \param[in] LDX
  102. *> \verbatim
  103. *> LDX is INTEGER
  104. *> The leading dimension of the array X. LDX >= max(1,N).
  105. *> \endverbatim
  106. *>
  107. *> \param[in] XACT
  108. *> \verbatim
  109. *> XACT is COMPLEX array, dimension (LDX,NRHS)
  110. *> The exact solution vectors. Each vector is stored as a
  111. *> column of the matrix XACT.
  112. *> \endverbatim
  113. *>
  114. *> \param[in] LDXACT
  115. *> \verbatim
  116. *> LDXACT is INTEGER
  117. *> The leading dimension of the array XACT. LDXACT >= max(1,N).
  118. *> \endverbatim
  119. *>
  120. *> \param[in] FERR
  121. *> \verbatim
  122. *> FERR is REAL array, dimension (NRHS)
  123. *> The estimated forward error bounds for each solution vector
  124. *> X. If XTRUE is the true solution, FERR bounds the magnitude
  125. *> of the largest entry in (X - XTRUE) divided by the magnitude
  126. *> of the largest entry in X.
  127. *> \endverbatim
  128. *>
  129. *> \param[in] CHKFERR
  130. *> \verbatim
  131. *> CHKFERR is LOGICAL
  132. *> Set to .TRUE. to check FERR, .FALSE. not to check FERR.
  133. *> When the test system is ill-conditioned, the "true"
  134. *> solution in XACT may be incorrect.
  135. *> \endverbatim
  136. *>
  137. *> \param[in] BERR
  138. *> \verbatim
  139. *> BERR is REAL array, dimension (NRHS)
  140. *> The componentwise relative backward error of each solution
  141. *> vector (i.e., the smallest relative change in any entry of A
  142. *> or B that makes X an exact solution).
  143. *> \endverbatim
  144. *>
  145. *> \param[out] RESLTS
  146. *> \verbatim
  147. *> RESLTS is REAL array, dimension (2)
  148. *> The maximum over the NRHS solution vectors of the ratios:
  149. *> RESLTS(1) = norm(X - XACT) / ( norm(X) * FERR )
  150. *> RESLTS(2) = BERR / ( (n+1)*EPS + (*) )
  151. *> \endverbatim
  152. *
  153. * Authors:
  154. * ========
  155. *
  156. *> \author Univ. of Tennessee
  157. *> \author Univ. of California Berkeley
  158. *> \author Univ. of Colorado Denver
  159. *> \author NAG Ltd.
  160. *
  161. *> \date December 2016
  162. *
  163. *> \ingroup complex_lin
  164. *
  165. * =====================================================================
  166. SUBROUTINE CGET07( TRANS, N, NRHS, A, LDA, B, LDB, X, LDX, XACT,
  167. $ LDXACT, FERR, CHKFERR, BERR, RESLTS )
  168. *
  169. * -- LAPACK test routine (version 3.7.0) --
  170. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  171. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  172. * December 2016
  173. *
  174. * .. Scalar Arguments ..
  175. CHARACTER TRANS
  176. LOGICAL CHKFERR
  177. INTEGER LDA, LDB, LDX, LDXACT, N, NRHS
  178. * ..
  179. * .. Array Arguments ..
  180. REAL BERR( * ), FERR( * ), RESLTS( * )
  181. COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * ),
  182. $ XACT( LDXACT, * )
  183. * ..
  184. *
  185. * =====================================================================
  186. *
  187. * .. Parameters ..
  188. REAL ZERO, ONE
  189. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  190. * ..
  191. * .. Local Scalars ..
  192. LOGICAL NOTRAN
  193. INTEGER I, IMAX, J, K
  194. REAL AXBI, DIFF, EPS, ERRBND, OVFL, TMP, UNFL, XNORM
  195. COMPLEX ZDUM
  196. * ..
  197. * .. External Functions ..
  198. LOGICAL LSAME
  199. INTEGER ICAMAX
  200. REAL SLAMCH
  201. EXTERNAL LSAME, ICAMAX, SLAMCH
  202. * ..
  203. * .. Intrinsic Functions ..
  204. INTRINSIC ABS, AIMAG, MAX, MIN, REAL
  205. * ..
  206. * .. Statement Functions ..
  207. REAL CABS1
  208. * ..
  209. * .. Statement Function definitions ..
  210. CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
  211. * ..
  212. * .. Executable Statements ..
  213. *
  214. * Quick exit if N = 0 or NRHS = 0.
  215. *
  216. IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
  217. RESLTS( 1 ) = ZERO
  218. RESLTS( 2 ) = ZERO
  219. RETURN
  220. END IF
  221. *
  222. EPS = SLAMCH( 'Epsilon' )
  223. UNFL = SLAMCH( 'Safe minimum' )
  224. OVFL = ONE / UNFL
  225. NOTRAN = LSAME( TRANS, 'N' )
  226. *
  227. * Test 1: Compute the maximum of
  228. * norm(X - XACT) / ( norm(X) * FERR )
  229. * over all the vectors X and XACT using the infinity-norm.
  230. *
  231. ERRBND = ZERO
  232. IF( CHKFERR ) THEN
  233. DO 30 J = 1, NRHS
  234. IMAX = ICAMAX( N, X( 1, J ), 1 )
  235. XNORM = MAX( CABS1( X( IMAX, J ) ), UNFL )
  236. DIFF = ZERO
  237. DO 10 I = 1, N
  238. DIFF = MAX( DIFF, CABS1( X( I, J )-XACT( I, J ) ) )
  239. 10 CONTINUE
  240. *
  241. IF( XNORM.GT.ONE ) THEN
  242. GO TO 20
  243. ELSE IF( DIFF.LE.OVFL*XNORM ) THEN
  244. GO TO 20
  245. ELSE
  246. ERRBND = ONE / EPS
  247. GO TO 30
  248. END IF
  249. *
  250. 20 CONTINUE
  251. IF( DIFF / XNORM.LE.FERR( J ) ) THEN
  252. ERRBND = MAX( ERRBND, ( DIFF / XNORM ) / FERR( J ) )
  253. ELSE
  254. ERRBND = ONE / EPS
  255. END IF
  256. 30 CONTINUE
  257. END IF
  258. RESLTS( 1 ) = ERRBND
  259. *
  260. * Test 2: Compute the maximum of BERR / ( (n+1)*EPS + (*) ), where
  261. * (*) = (n+1)*UNFL / (min_i (abs(op(A))*abs(X) +abs(b))_i )
  262. *
  263. DO 70 K = 1, NRHS
  264. DO 60 I = 1, N
  265. TMP = CABS1( B( I, K ) )
  266. IF( NOTRAN ) THEN
  267. DO 40 J = 1, N
  268. TMP = TMP + CABS1( A( I, J ) )*CABS1( X( J, K ) )
  269. 40 CONTINUE
  270. ELSE
  271. DO 50 J = 1, N
  272. TMP = TMP + CABS1( A( J, I ) )*CABS1( X( J, K ) )
  273. 50 CONTINUE
  274. END IF
  275. IF( I.EQ.1 ) THEN
  276. AXBI = TMP
  277. ELSE
  278. AXBI = MIN( AXBI, TMP )
  279. END IF
  280. 60 CONTINUE
  281. TMP = BERR( K ) / ( ( N+1 )*EPS+( N+1 )*UNFL /
  282. $ MAX( AXBI, ( N+1 )*UNFL ) )
  283. IF( K.EQ.1 ) THEN
  284. RESLTS( 2 ) = TMP
  285. ELSE
  286. RESLTS( 2 ) = MAX( RESLTS( 2 ), TMP )
  287. END IF
  288. 70 CONTINUE
  289. *
  290. RETURN
  291. *
  292. * End of CGET07
  293. *
  294. END