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.

sgtcon.f 6.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. *> \brief \b SGTCON
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download SGTCON + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgtcon.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgtcon.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgtcon.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE SGTCON( NORM, N, DL, D, DU, DU2, IPIV, ANORM, RCOND,
  22. * WORK, IWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER NORM
  26. * INTEGER INFO, N
  27. * REAL ANORM, RCOND
  28. * ..
  29. * .. Array Arguments ..
  30. * INTEGER IPIV( * ), IWORK( * )
  31. * REAL D( * ), DL( * ), DU( * ), DU2( * ), WORK( * )
  32. * ..
  33. *
  34. *
  35. *> \par Purpose:
  36. * =============
  37. *>
  38. *> \verbatim
  39. *>
  40. *> SGTCON estimates the reciprocal of the condition number of a real
  41. *> tridiagonal matrix A using the LU factorization as computed by
  42. *> SGTTRF.
  43. *>
  44. *> An estimate is obtained for norm(inv(A)), and the reciprocal of the
  45. *> condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
  46. *> \endverbatim
  47. *
  48. * Arguments:
  49. * ==========
  50. *
  51. *> \param[in] NORM
  52. *> \verbatim
  53. *> NORM is CHARACTER*1
  54. *> Specifies whether the 1-norm condition number or the
  55. *> infinity-norm condition number is required:
  56. *> = '1' or 'O': 1-norm;
  57. *> = 'I': Infinity-norm.
  58. *> \endverbatim
  59. *>
  60. *> \param[in] N
  61. *> \verbatim
  62. *> N is INTEGER
  63. *> The order of the matrix A. N >= 0.
  64. *> \endverbatim
  65. *>
  66. *> \param[in] DL
  67. *> \verbatim
  68. *> DL is REAL array, dimension (N-1)
  69. *> The (n-1) multipliers that define the matrix L from the
  70. *> LU factorization of A as computed by SGTTRF.
  71. *> \endverbatim
  72. *>
  73. *> \param[in] D
  74. *> \verbatim
  75. *> D is REAL array, dimension (N)
  76. *> The n diagonal elements of the upper triangular matrix U from
  77. *> the LU factorization of A.
  78. *> \endverbatim
  79. *>
  80. *> \param[in] DU
  81. *> \verbatim
  82. *> DU is REAL array, dimension (N-1)
  83. *> The (n-1) elements of the first superdiagonal of U.
  84. *> \endverbatim
  85. *>
  86. *> \param[in] DU2
  87. *> \verbatim
  88. *> DU2 is REAL array, dimension (N-2)
  89. *> The (n-2) elements of the second superdiagonal of U.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] IPIV
  93. *> \verbatim
  94. *> IPIV is INTEGER array, dimension (N)
  95. *> The pivot indices; for 1 <= i <= n, row i of the matrix was
  96. *> interchanged with row IPIV(i). IPIV(i) will always be either
  97. *> i or i+1; IPIV(i) = i indicates a row interchange was not
  98. *> required.
  99. *> \endverbatim
  100. *>
  101. *> \param[in] ANORM
  102. *> \verbatim
  103. *> ANORM is REAL
  104. *> If NORM = '1' or 'O', the 1-norm of the original matrix A.
  105. *> If NORM = 'I', the infinity-norm of the original matrix A.
  106. *> \endverbatim
  107. *>
  108. *> \param[out] RCOND
  109. *> \verbatim
  110. *> RCOND is REAL
  111. *> The reciprocal of the condition number of the matrix A,
  112. *> computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
  113. *> estimate of the 1-norm of inv(A) computed in this routine.
  114. *> \endverbatim
  115. *>
  116. *> \param[out] WORK
  117. *> \verbatim
  118. *> WORK is REAL array, dimension (2*N)
  119. *> \endverbatim
  120. *>
  121. *> \param[out] IWORK
  122. *> \verbatim
  123. *> IWORK is INTEGER array, dimension (N)
  124. *> \endverbatim
  125. *>
  126. *> \param[out] INFO
  127. *> \verbatim
  128. *> INFO is INTEGER
  129. *> = 0: successful exit
  130. *> < 0: if INFO = -i, the i-th argument had an illegal value
  131. *> \endverbatim
  132. *
  133. * Authors:
  134. * ========
  135. *
  136. *> \author Univ. of Tennessee
  137. *> \author Univ. of California Berkeley
  138. *> \author Univ. of Colorado Denver
  139. *> \author NAG Ltd.
  140. *
  141. *> \ingroup realGTcomputational
  142. *
  143. * =====================================================================
  144. SUBROUTINE SGTCON( NORM, N, DL, D, DU, DU2, IPIV, ANORM, RCOND,
  145. $ WORK, IWORK, INFO )
  146. *
  147. * -- LAPACK computational routine --
  148. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  149. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  150. *
  151. * .. Scalar Arguments ..
  152. CHARACTER NORM
  153. INTEGER INFO, N
  154. REAL ANORM, RCOND
  155. * ..
  156. * .. Array Arguments ..
  157. INTEGER IPIV( * ), IWORK( * )
  158. REAL D( * ), DL( * ), DU( * ), DU2( * ), WORK( * )
  159. * ..
  160. *
  161. * =====================================================================
  162. *
  163. * .. Parameters ..
  164. REAL ONE, ZERO
  165. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  166. * ..
  167. * .. Local Scalars ..
  168. LOGICAL ONENRM
  169. INTEGER I, KASE, KASE1
  170. REAL AINVNM
  171. * ..
  172. * .. Local Arrays ..
  173. INTEGER ISAVE( 3 )
  174. * ..
  175. * .. External Functions ..
  176. LOGICAL LSAME
  177. EXTERNAL LSAME
  178. * ..
  179. * .. External Subroutines ..
  180. EXTERNAL SGTTRS, SLACN2, XERBLA
  181. * ..
  182. * .. Executable Statements ..
  183. *
  184. * Test the input arguments.
  185. *
  186. INFO = 0
  187. ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' )
  188. IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN
  189. INFO = -1
  190. ELSE IF( N.LT.0 ) THEN
  191. INFO = -2
  192. ELSE IF( ANORM.LT.ZERO ) THEN
  193. INFO = -8
  194. END IF
  195. IF( INFO.NE.0 ) THEN
  196. CALL XERBLA( 'SGTCON', -INFO )
  197. RETURN
  198. END IF
  199. *
  200. * Quick return if possible
  201. *
  202. RCOND = ZERO
  203. IF( N.EQ.0 ) THEN
  204. RCOND = ONE
  205. RETURN
  206. ELSE IF( ANORM.EQ.ZERO ) THEN
  207. RETURN
  208. END IF
  209. *
  210. * Check that D(1:N) is non-zero.
  211. *
  212. DO 10 I = 1, N
  213. IF( D( I ).EQ.ZERO )
  214. $ RETURN
  215. 10 CONTINUE
  216. *
  217. AINVNM = ZERO
  218. IF( ONENRM ) THEN
  219. KASE1 = 1
  220. ELSE
  221. KASE1 = 2
  222. END IF
  223. KASE = 0
  224. 20 CONTINUE
  225. CALL SLACN2( N, WORK( N+1 ), WORK, IWORK, AINVNM, KASE, ISAVE )
  226. IF( KASE.NE.0 ) THEN
  227. IF( KASE.EQ.KASE1 ) THEN
  228. *
  229. * Multiply by inv(U)*inv(L).
  230. *
  231. CALL SGTTRS( 'No transpose', N, 1, DL, D, DU, DU2, IPIV,
  232. $ WORK, N, INFO )
  233. ELSE
  234. *
  235. * Multiply by inv(L**T)*inv(U**T).
  236. *
  237. CALL SGTTRS( 'Transpose', N, 1, DL, D, DU, DU2, IPIV, WORK,
  238. $ N, INFO )
  239. END IF
  240. GO TO 20
  241. END IF
  242. *
  243. * Compute the estimate of the reciprocal condition number.
  244. *
  245. IF( AINVNM.NE.ZERO )
  246. $ RCOND = ( ONE / AINVNM ) / ANORM
  247. *
  248. RETURN
  249. *
  250. * End of SGTCON
  251. *
  252. END