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.

ztrcon.f 8.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. *> \brief \b ZTRCON
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download ZTRCON + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrcon.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrcon.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrcon.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE ZTRCON( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK,
  22. * RWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER DIAG, NORM, UPLO
  26. * INTEGER INFO, LDA, N
  27. * DOUBLE PRECISION RCOND
  28. * ..
  29. * .. Array Arguments ..
  30. * DOUBLE PRECISION RWORK( * )
  31. * COMPLEX*16 A( LDA, * ), WORK( * )
  32. * ..
  33. *
  34. *
  35. *> \par Purpose:
  36. * =============
  37. *>
  38. *> \verbatim
  39. *>
  40. *> ZTRCON estimates the reciprocal of the condition number of a
  41. *> triangular matrix A, in either the 1-norm or the infinity-norm.
  42. *>
  43. *> The norm of A is computed and an estimate is obtained for
  44. *> norm(inv(A)), then the reciprocal of the condition number is
  45. *> computed as
  46. *> RCOND = 1 / ( norm(A) * norm(inv(A)) ).
  47. *> \endverbatim
  48. *
  49. * Arguments:
  50. * ==========
  51. *
  52. *> \param[in] NORM
  53. *> \verbatim
  54. *> NORM is CHARACTER*1
  55. *> Specifies whether the 1-norm condition number or the
  56. *> infinity-norm condition number is required:
  57. *> = '1' or 'O': 1-norm;
  58. *> = 'I': Infinity-norm.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] UPLO
  62. *> \verbatim
  63. *> UPLO is CHARACTER*1
  64. *> = 'U': A is upper triangular;
  65. *> = 'L': A is lower triangular.
  66. *> \endverbatim
  67. *>
  68. *> \param[in] DIAG
  69. *> \verbatim
  70. *> DIAG is CHARACTER*1
  71. *> = 'N': A is non-unit triangular;
  72. *> = 'U': A is unit triangular.
  73. *> \endverbatim
  74. *>
  75. *> \param[in] N
  76. *> \verbatim
  77. *> N is INTEGER
  78. *> The order of the matrix A. N >= 0.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] A
  82. *> \verbatim
  83. *> A is COMPLEX*16 array, dimension (LDA,N)
  84. *> The triangular matrix A. If UPLO = 'U', the leading N-by-N
  85. *> upper triangular part of the array A contains the upper
  86. *> triangular matrix, and the strictly lower triangular part of
  87. *> A is not referenced. If UPLO = 'L', the leading N-by-N lower
  88. *> triangular part of the array A contains the lower triangular
  89. *> matrix, and the strictly upper triangular part of A is not
  90. *> referenced. If DIAG = 'U', the diagonal elements of A are
  91. *> also not referenced and are assumed to be 1.
  92. *> \endverbatim
  93. *>
  94. *> \param[in] LDA
  95. *> \verbatim
  96. *> LDA is INTEGER
  97. *> The leading dimension of the array A. LDA >= max(1,N).
  98. *> \endverbatim
  99. *>
  100. *> \param[out] RCOND
  101. *> \verbatim
  102. *> RCOND is DOUBLE PRECISION
  103. *> The reciprocal of the condition number of the matrix A,
  104. *> computed as RCOND = 1/(norm(A) * norm(inv(A))).
  105. *> \endverbatim
  106. *>
  107. *> \param[out] WORK
  108. *> \verbatim
  109. *> WORK is COMPLEX*16 array, dimension (2*N)
  110. *> \endverbatim
  111. *>
  112. *> \param[out] RWORK
  113. *> \verbatim
  114. *> RWORK is DOUBLE PRECISION array, dimension (N)
  115. *> \endverbatim
  116. *>
  117. *> \param[out] INFO
  118. *> \verbatim
  119. *> INFO is INTEGER
  120. *> = 0: successful exit
  121. *> < 0: if INFO = -i, the i-th argument had an illegal value
  122. *> \endverbatim
  123. *
  124. * Authors:
  125. * ========
  126. *
  127. *> \author Univ. of Tennessee
  128. *> \author Univ. of California Berkeley
  129. *> \author Univ. of Colorado Denver
  130. *> \author NAG Ltd.
  131. *
  132. *> \date December 2016
  133. *
  134. *> \ingroup complex16OTHERcomputational
  135. *
  136. * =====================================================================
  137. SUBROUTINE ZTRCON( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK,
  138. $ RWORK, INFO )
  139. *
  140. * -- LAPACK computational routine (version 3.7.0) --
  141. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  142. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  143. * December 2016
  144. *
  145. * .. Scalar Arguments ..
  146. CHARACTER DIAG, NORM, UPLO
  147. INTEGER INFO, LDA, N
  148. DOUBLE PRECISION RCOND
  149. * ..
  150. * .. Array Arguments ..
  151. DOUBLE PRECISION RWORK( * )
  152. COMPLEX*16 A( LDA, * ), WORK( * )
  153. * ..
  154. *
  155. * =====================================================================
  156. *
  157. * .. Parameters ..
  158. DOUBLE PRECISION ONE, ZERO
  159. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  160. * ..
  161. * .. Local Scalars ..
  162. LOGICAL NOUNIT, ONENRM, UPPER
  163. CHARACTER NORMIN
  164. INTEGER IX, KASE, KASE1
  165. DOUBLE PRECISION AINVNM, ANORM, SCALE, SMLNUM, XNORM
  166. COMPLEX*16 ZDUM
  167. * ..
  168. * .. Local Arrays ..
  169. INTEGER ISAVE( 3 )
  170. * ..
  171. * .. External Functions ..
  172. LOGICAL LSAME
  173. INTEGER IZAMAX
  174. DOUBLE PRECISION DLAMCH, ZLANTR
  175. EXTERNAL LSAME, IZAMAX, DLAMCH, ZLANTR
  176. * ..
  177. * .. External Subroutines ..
  178. EXTERNAL XERBLA, ZDRSCL, ZLACN2, ZLATRS
  179. * ..
  180. * .. Intrinsic Functions ..
  181. INTRINSIC ABS, DBLE, DIMAG, MAX
  182. * ..
  183. * .. Statement Functions ..
  184. DOUBLE PRECISION CABS1
  185. * ..
  186. * .. Statement Function definitions ..
  187. CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
  188. * ..
  189. * .. Executable Statements ..
  190. *
  191. * Test the input parameters.
  192. *
  193. INFO = 0
  194. UPPER = LSAME( UPLO, 'U' )
  195. ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )
  196. NOUNIT = LSAME( DIAG, 'N' )
  197. *
  198. IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN
  199. INFO = -1
  200. ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  201. INFO = -2
  202. ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
  203. INFO = -3
  204. ELSE IF( N.LT.0 ) THEN
  205. INFO = -4
  206. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  207. INFO = -6
  208. END IF
  209. IF( INFO.NE.0 ) THEN
  210. CALL XERBLA( 'ZTRCON', -INFO )
  211. RETURN
  212. END IF
  213. *
  214. * Quick return if possible
  215. *
  216. IF( N.EQ.0 ) THEN
  217. RCOND = ONE
  218. RETURN
  219. END IF
  220. *
  221. RCOND = ZERO
  222. SMLNUM = DLAMCH( 'Safe minimum' )*DBLE( MAX( 1, N ) )
  223. *
  224. * Compute the norm of the triangular matrix A.
  225. *
  226. ANORM = ZLANTR( NORM, UPLO, DIAG, N, N, A, LDA, RWORK )
  227. *
  228. * Continue only if ANORM > 0.
  229. *
  230. IF( ANORM.GT.ZERO ) THEN
  231. *
  232. * Estimate the norm of the inverse of A.
  233. *
  234. AINVNM = ZERO
  235. NORMIN = 'N'
  236. IF( ONENRM ) THEN
  237. KASE1 = 1
  238. ELSE
  239. KASE1 = 2
  240. END IF
  241. KASE = 0
  242. 10 CONTINUE
  243. CALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE )
  244. IF( KASE.NE.0 ) THEN
  245. IF( KASE.EQ.KASE1 ) THEN
  246. *
  247. * Multiply by inv(A).
  248. *
  249. CALL ZLATRS( UPLO, 'No transpose', DIAG, NORMIN, N, A,
  250. $ LDA, WORK, SCALE, RWORK, INFO )
  251. ELSE
  252. *
  253. * Multiply by inv(A**H).
  254. *
  255. CALL ZLATRS( UPLO, 'Conjugate transpose', DIAG, NORMIN,
  256. $ N, A, LDA, WORK, SCALE, RWORK, INFO )
  257. END IF
  258. NORMIN = 'Y'
  259. *
  260. * Multiply by 1/SCALE if doing so will not cause overflow.
  261. *
  262. IF( SCALE.NE.ONE ) THEN
  263. IX = IZAMAX( N, WORK, 1 )
  264. XNORM = CABS1( WORK( IX ) )
  265. IF( SCALE.LT.XNORM*SMLNUM .OR. SCALE.EQ.ZERO )
  266. $ GO TO 20
  267. CALL ZDRSCL( N, SCALE, WORK, 1 )
  268. END IF
  269. GO TO 10
  270. END IF
  271. *
  272. * Compute the estimate of the reciprocal condition number.
  273. *
  274. IF( AINVNM.NE.ZERO )
  275. $ RCOND = ( ONE / ANORM ) / AINVNM
  276. END IF
  277. *
  278. 20 CONTINUE
  279. RETURN
  280. *
  281. * End of ZTRCON
  282. *
  283. END