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.

ctrexc.f 6.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. *> \brief \b CTREXC
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CTREXC + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctrexc.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctrexc.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctrexc.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CTREXC( COMPQ, N, T, LDT, Q, LDQ, IFST, ILST, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER COMPQ
  25. * INTEGER IFST, ILST, INFO, LDQ, LDT, N
  26. * ..
  27. * .. Array Arguments ..
  28. * COMPLEX Q( LDQ, * ), T( LDT, * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> CTREXC reorders the Schur factorization of a complex matrix
  38. *> A = Q*T*Q**H, so that the diagonal element of T with row index IFST
  39. *> is moved to row ILST.
  40. *>
  41. *> The Schur form T is reordered by a unitary similarity transformation
  42. *> Z**H*T*Z, and optionally the matrix Q of Schur vectors is updated by
  43. *> postmultplying it with Z.
  44. *> \endverbatim
  45. *
  46. * Arguments:
  47. * ==========
  48. *
  49. *> \param[in] COMPQ
  50. *> \verbatim
  51. *> COMPQ is CHARACTER*1
  52. *> = 'V': update the matrix Q of Schur vectors;
  53. *> = 'N': do not update Q.
  54. *> \endverbatim
  55. *>
  56. *> \param[in] N
  57. *> \verbatim
  58. *> N is INTEGER
  59. *> The order of the matrix T. N >= 0.
  60. *> If N == 0 arguments ILST and IFST may be any value.
  61. *> \endverbatim
  62. *>
  63. *> \param[in,out] T
  64. *> \verbatim
  65. *> T is COMPLEX array, dimension (LDT,N)
  66. *> On entry, the upper triangular matrix T.
  67. *> On exit, the reordered upper triangular matrix.
  68. *> \endverbatim
  69. *>
  70. *> \param[in] LDT
  71. *> \verbatim
  72. *> LDT is INTEGER
  73. *> The leading dimension of the array T. LDT >= max(1,N).
  74. *> \endverbatim
  75. *>
  76. *> \param[in,out] Q
  77. *> \verbatim
  78. *> Q is COMPLEX array, dimension (LDQ,N)
  79. *> On entry, if COMPQ = 'V', the matrix Q of Schur vectors.
  80. *> On exit, if COMPQ = 'V', Q has been postmultiplied by the
  81. *> unitary transformation matrix Z which reorders T.
  82. *> If COMPQ = 'N', Q is not referenced.
  83. *> \endverbatim
  84. *>
  85. *> \param[in] LDQ
  86. *> \verbatim
  87. *> LDQ is INTEGER
  88. *> The leading dimension of the array Q. LDQ >= 1, and if
  89. *> COMPQ = 'V', LDQ >= max(1,N).
  90. *> \endverbatim
  91. *>
  92. *> \param[in] IFST
  93. *> \verbatim
  94. *> IFST is INTEGER
  95. *> \endverbatim
  96. *>
  97. *> \param[in] ILST
  98. *> \verbatim
  99. *> ILST is INTEGER
  100. *>
  101. *> Specify the reordering of the diagonal elements of T:
  102. *> The element with row index IFST is moved to row ILST by a
  103. *> sequence of transpositions between adjacent elements.
  104. *> 1 <= IFST <= N; 1 <= ILST <= N.
  105. *> \endverbatim
  106. *>
  107. *> \param[out] INFO
  108. *> \verbatim
  109. *> INFO is INTEGER
  110. *> = 0: successful exit
  111. *> < 0: if INFO = -i, the i-th argument had an illegal value
  112. *> \endverbatim
  113. *
  114. * Authors:
  115. * ========
  116. *
  117. *> \author Univ. of Tennessee
  118. *> \author Univ. of California Berkeley
  119. *> \author Univ. of Colorado Denver
  120. *> \author NAG Ltd.
  121. *
  122. *> \date December 2016
  123. *
  124. *> \ingroup complexOTHERcomputational
  125. *
  126. * =====================================================================
  127. SUBROUTINE CTREXC( COMPQ, N, T, LDT, Q, LDQ, IFST, ILST, INFO )
  128. *
  129. * -- LAPACK computational routine (version 3.7.0) --
  130. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  131. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  132. * December 2016
  133. *
  134. * .. Scalar Arguments ..
  135. CHARACTER COMPQ
  136. INTEGER IFST, ILST, INFO, LDQ, LDT, N
  137. * ..
  138. * .. Array Arguments ..
  139. COMPLEX Q( LDQ, * ), T( LDT, * )
  140. * ..
  141. *
  142. * =====================================================================
  143. *
  144. * .. Local Scalars ..
  145. LOGICAL WANTQ
  146. INTEGER K, M1, M2, M3
  147. REAL CS
  148. COMPLEX SN, T11, T22, TEMP
  149. * ..
  150. * .. External Functions ..
  151. LOGICAL LSAME
  152. EXTERNAL LSAME
  153. * ..
  154. * .. External Subroutines ..
  155. EXTERNAL CLARTG, CROT, XERBLA
  156. * ..
  157. * .. Intrinsic Functions ..
  158. INTRINSIC CONJG, MAX
  159. * ..
  160. * .. Executable Statements ..
  161. *
  162. * Decode and test the input parameters.
  163. *
  164. INFO = 0
  165. WANTQ = LSAME( COMPQ, 'V' )
  166. IF( .NOT.LSAME( COMPQ, 'N' ) .AND. .NOT.WANTQ ) THEN
  167. INFO = -1
  168. ELSE IF( N.LT.0 ) THEN
  169. INFO = -2
  170. ELSE IF( LDT.LT.MAX( 1, N ) ) THEN
  171. INFO = -4
  172. ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.MAX( 1, N ) ) ) THEN
  173. INFO = -6
  174. ELSE IF(( IFST.LT.1 .OR. IFST.GT.N ).AND.( N.GT.0 )) THEN
  175. INFO = -7
  176. ELSE IF(( ILST.LT.1 .OR. ILST.GT.N ).AND.( N.GT.0 )) THEN
  177. INFO = -8
  178. END IF
  179. IF( INFO.NE.0 ) THEN
  180. CALL XERBLA( 'CTREXC', -INFO )
  181. RETURN
  182. END IF
  183. *
  184. * Quick return if possible
  185. *
  186. IF( N.LE.1 .OR. IFST.EQ.ILST )
  187. $ RETURN
  188. *
  189. IF( IFST.LT.ILST ) THEN
  190. *
  191. * Move the IFST-th diagonal element forward down the diagonal.
  192. *
  193. M1 = 0
  194. M2 = -1
  195. M3 = 1
  196. ELSE
  197. *
  198. * Move the IFST-th diagonal element backward up the diagonal.
  199. *
  200. M1 = -1
  201. M2 = 0
  202. M3 = -1
  203. END IF
  204. *
  205. DO 10 K = IFST + M1, ILST + M2, M3
  206. *
  207. * Interchange the k-th and (k+1)-th diagonal elements.
  208. *
  209. T11 = T( K, K )
  210. T22 = T( K+1, K+1 )
  211. *
  212. * Determine the transformation to perform the interchange.
  213. *
  214. CALL CLARTG( T( K, K+1 ), T22-T11, CS, SN, TEMP )
  215. *
  216. * Apply transformation to the matrix T.
  217. *
  218. IF( K+2.LE.N )
  219. $ CALL CROT( N-K-1, T( K, K+2 ), LDT, T( K+1, K+2 ), LDT, CS,
  220. $ SN )
  221. CALL CROT( K-1, T( 1, K ), 1, T( 1, K+1 ), 1, CS, CONJG( SN ) )
  222. *
  223. T( K, K ) = T22
  224. T( K+1, K+1 ) = T11
  225. *
  226. IF( WANTQ ) THEN
  227. *
  228. * Accumulate transformation in the matrix Q.
  229. *
  230. CALL CROT( N, Q( 1, K ), 1, Q( 1, K+1 ), 1, CS,
  231. $ CONJG( SN ) )
  232. END IF
  233. *
  234. 10 CONTINUE
  235. *
  236. RETURN
  237. *
  238. * End of CTREXC
  239. *
  240. END