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.

ztrt03.f 8.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. *> \brief \b ZTRT03
  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 ZTRT03( UPLO, TRANS, DIAG, N, NRHS, A, LDA, SCALE,
  12. * CNORM, TSCAL, X, LDX, B, LDB, WORK, RESID )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER DIAG, TRANS, UPLO
  16. * INTEGER LDA, LDB, LDX, N, NRHS
  17. * DOUBLE PRECISION RESID, SCALE, TSCAL
  18. * ..
  19. * .. Array Arguments ..
  20. * DOUBLE PRECISION CNORM( * )
  21. * COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * ),
  22. * $ X( LDX, * )
  23. * ..
  24. *
  25. *
  26. *> \par Purpose:
  27. * =============
  28. *>
  29. *> \verbatim
  30. *>
  31. *> ZTRT03 computes the residual for the solution to a scaled triangular
  32. *> system of equations A*x = s*b, A**T *x = s*b, or A**H *x = s*b.
  33. *> Here A is a triangular matrix, A**T denotes the transpose of A, A**H
  34. *> denotes the conjugate transpose of A, s is a scalar, and x and b are
  35. *> N by NRHS matrices. The test ratio is the maximum over the number of
  36. *> right hand sides of
  37. *> norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ),
  38. *> where op(A) denotes A, A**T, or A**H, and EPS is the machine epsilon.
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] UPLO
  45. *> \verbatim
  46. *> UPLO is CHARACTER*1
  47. *> Specifies whether the matrix A is upper or lower triangular.
  48. *> = 'U': Upper triangular
  49. *> = 'L': Lower triangular
  50. *> \endverbatim
  51. *>
  52. *> \param[in] TRANS
  53. *> \verbatim
  54. *> TRANS is CHARACTER*1
  55. *> Specifies the operation applied to A.
  56. *> = 'N': A *x = s*b (No transpose)
  57. *> = 'T': A**T *x = s*b (Transpose)
  58. *> = 'C': A**H *x = s*b (Conjugate transpose)
  59. *> \endverbatim
  60. *>
  61. *> \param[in] DIAG
  62. *> \verbatim
  63. *> DIAG is CHARACTER*1
  64. *> Specifies whether or not the matrix A is unit triangular.
  65. *> = 'N': Non-unit triangular
  66. *> = 'U': Unit triangular
  67. *> \endverbatim
  68. *>
  69. *> \param[in] N
  70. *> \verbatim
  71. *> N is INTEGER
  72. *> The order of the matrix A. N >= 0.
  73. *> \endverbatim
  74. *>
  75. *> \param[in] NRHS
  76. *> \verbatim
  77. *> NRHS is INTEGER
  78. *> The number of right hand sides, i.e., the number of columns
  79. *> of the matrices X and B. NRHS >= 0.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] A
  83. *> \verbatim
  84. *> A is COMPLEX*16 array, dimension (LDA,N)
  85. *> The triangular matrix A. If UPLO = 'U', the leading n by n
  86. *> upper triangular part of the array A contains the upper
  87. *> triangular matrix, and the strictly lower triangular part of
  88. *> A is not referenced. If UPLO = 'L', the leading n by n lower
  89. *> triangular part of the array A contains the lower triangular
  90. *> matrix, and the strictly upper triangular part of A is not
  91. *> referenced. If DIAG = 'U', the diagonal elements of A are
  92. *> also not referenced and are assumed to be 1.
  93. *> \endverbatim
  94. *>
  95. *> \param[in] LDA
  96. *> \verbatim
  97. *> LDA is INTEGER
  98. *> The leading dimension of the array A. LDA >= max(1,N).
  99. *> \endverbatim
  100. *>
  101. *> \param[in] SCALE
  102. *> \verbatim
  103. *> SCALE is DOUBLE PRECISION
  104. *> The scaling factor s used in solving the triangular system.
  105. *> \endverbatim
  106. *>
  107. *> \param[in] CNORM
  108. *> \verbatim
  109. *> CNORM is DOUBLE PRECISION array, dimension (N)
  110. *> The 1-norms of the columns of A, not counting the diagonal.
  111. *> \endverbatim
  112. *>
  113. *> \param[in] TSCAL
  114. *> \verbatim
  115. *> TSCAL is DOUBLE PRECISION
  116. *> The scaling factor used in computing the 1-norms in CNORM.
  117. *> CNORM actually contains the column norms of TSCAL*A.
  118. *> \endverbatim
  119. *>
  120. *> \param[in] X
  121. *> \verbatim
  122. *> X is COMPLEX*16 array, dimension (LDX,NRHS)
  123. *> The computed solution vectors for the system of linear
  124. *> equations.
  125. *> \endverbatim
  126. *>
  127. *> \param[in] LDX
  128. *> \verbatim
  129. *> LDX is INTEGER
  130. *> The leading dimension of the array X. LDX >= max(1,N).
  131. *> \endverbatim
  132. *>
  133. *> \param[in] B
  134. *> \verbatim
  135. *> B is COMPLEX*16 array, dimension (LDB,NRHS)
  136. *> The right hand side vectors for the system of linear
  137. *> equations.
  138. *> \endverbatim
  139. *>
  140. *> \param[in] LDB
  141. *> \verbatim
  142. *> LDB is INTEGER
  143. *> The leading dimension of the array B. LDB >= max(1,N).
  144. *> \endverbatim
  145. *>
  146. *> \param[out] WORK
  147. *> \verbatim
  148. *> WORK is COMPLEX*16 array, dimension (N)
  149. *> \endverbatim
  150. *>
  151. *> \param[out] RESID
  152. *> \verbatim
  153. *> RESID is DOUBLE PRECISION
  154. *> The maximum over the number of right hand sides of
  155. *> norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
  156. *> \endverbatim
  157. *
  158. * Authors:
  159. * ========
  160. *
  161. *> \author Univ. of Tennessee
  162. *> \author Univ. of California Berkeley
  163. *> \author Univ. of Colorado Denver
  164. *> \author NAG Ltd.
  165. *
  166. *> \ingroup complex16_lin
  167. *
  168. * =====================================================================
  169. SUBROUTINE ZTRT03( UPLO, TRANS, DIAG, N, NRHS, A, LDA, SCALE,
  170. $ CNORM, TSCAL, X, LDX, B, LDB, WORK, RESID )
  171. *
  172. * -- LAPACK test routine --
  173. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  174. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  175. *
  176. * .. Scalar Arguments ..
  177. CHARACTER DIAG, TRANS, UPLO
  178. INTEGER LDA, LDB, LDX, N, NRHS
  179. DOUBLE PRECISION RESID, SCALE, TSCAL
  180. * ..
  181. * .. Array Arguments ..
  182. DOUBLE PRECISION CNORM( * )
  183. COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * ),
  184. $ X( LDX, * )
  185. * ..
  186. *
  187. * =====================================================================
  188. *
  189. * .. Parameters ..
  190. DOUBLE PRECISION ONE, ZERO
  191. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  192. * ..
  193. * .. Local Scalars ..
  194. INTEGER IX, J
  195. DOUBLE PRECISION EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL
  196. * ..
  197. * .. External Functions ..
  198. LOGICAL LSAME
  199. INTEGER IZAMAX
  200. DOUBLE PRECISION DLAMCH
  201. EXTERNAL LSAME, IZAMAX, DLAMCH
  202. * ..
  203. * .. External Subroutines ..
  204. EXTERNAL ZAXPY, ZCOPY, ZDSCAL, ZTRMV
  205. * ..
  206. * .. Intrinsic Functions ..
  207. INTRINSIC ABS, DBLE, DCMPLX, MAX
  208. * ..
  209. * .. Executable Statements ..
  210. *
  211. * Quick exit if N = 0
  212. *
  213. IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
  214. RESID = ZERO
  215. RETURN
  216. END IF
  217. EPS = DLAMCH( 'Epsilon' )
  218. SMLNUM = DLAMCH( 'Safe minimum' )
  219. *
  220. * Compute the norm of the triangular matrix A using the column
  221. * norms already computed by ZLATRS.
  222. *
  223. TNORM = ZERO
  224. IF( LSAME( DIAG, 'N' ) ) THEN
  225. DO 10 J = 1, N
  226. TNORM = MAX( TNORM, TSCAL*ABS( A( J, J ) )+CNORM( J ) )
  227. 10 CONTINUE
  228. ELSE
  229. DO 20 J = 1, N
  230. TNORM = MAX( TNORM, TSCAL+CNORM( J ) )
  231. 20 CONTINUE
  232. END IF
  233. *
  234. * Compute the maximum over the number of right hand sides of
  235. * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
  236. *
  237. RESID = ZERO
  238. DO 30 J = 1, NRHS
  239. CALL ZCOPY( N, X( 1, J ), 1, WORK, 1 )
  240. IX = IZAMAX( N, WORK, 1 )
  241. XNORM = MAX( ONE, ABS( X( IX, J ) ) )
  242. XSCAL = ( ONE / XNORM ) / DBLE( N )
  243. CALL ZDSCAL( N, XSCAL, WORK, 1 )
  244. CALL ZTRMV( UPLO, TRANS, DIAG, N, A, LDA, WORK, 1 )
  245. CALL ZAXPY( N, DCMPLX( -SCALE*XSCAL ), B( 1, J ), 1, WORK, 1 )
  246. IX = IZAMAX( N, WORK, 1 )
  247. ERR = TSCAL*ABS( WORK( IX ) )
  248. IX = IZAMAX( N, X( 1, J ), 1 )
  249. XNORM = ABS( X( IX, J ) )
  250. IF( ERR*SMLNUM.LE.XNORM ) THEN
  251. IF( XNORM.GT.ZERO )
  252. $ ERR = ERR / XNORM
  253. ELSE
  254. IF( ERR.GT.ZERO )
  255. $ ERR = ONE / EPS
  256. END IF
  257. IF( ERR*SMLNUM.LE.TNORM ) THEN
  258. IF( TNORM.GT.ZERO )
  259. $ ERR = ERR / TNORM
  260. ELSE
  261. IF( ERR.GT.ZERO )
  262. $ ERR = ONE / EPS
  263. END IF
  264. RESID = MAX( RESID, ERR )
  265. 30 CONTINUE
  266. *
  267. RETURN
  268. *
  269. * End of ZTRT03
  270. *
  271. END