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.

cunt03.f 8.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. *> \brief \b CUNT03
  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 CUNT03( RC, MU, MV, N, K, U, LDU, V, LDV, WORK, LWORK,
  12. * RWORK, RESULT, INFO )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER*( * ) RC
  16. * INTEGER INFO, K, LDU, LDV, LWORK, MU, MV, N
  17. * REAL RESULT
  18. * ..
  19. * .. Array Arguments ..
  20. * REAL RWORK( * )
  21. * COMPLEX U( LDU, * ), V( LDV, * ), WORK( * )
  22. * ..
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> CUNT03 compares two unitary matrices U and V to see if their
  31. *> corresponding rows or columns span the same spaces. The rows are
  32. *> checked if RC = 'R', and the columns are checked if RC = 'C'.
  33. *>
  34. *> RESULT is the maximum of
  35. *>
  36. *> | V*V' - I | / ( MV ulp ), if RC = 'R', or
  37. *>
  38. *> | V'*V - I | / ( MV ulp ), if RC = 'C',
  39. *>
  40. *> and the maximum over rows (or columns) 1 to K of
  41. *>
  42. *> | U(i) - S*V(i) |/ ( N ulp )
  43. *>
  44. *> where abs(S) = 1 (chosen to minimize the expression), U(i) is the
  45. *> i-th row (column) of U, and V(i) is the i-th row (column) of V.
  46. *> \endverbatim
  47. *
  48. * Arguments:
  49. * ==========
  50. *
  51. *> \param[in] RC
  52. *> \verbatim
  53. *> RC is CHARACTER*1
  54. *> If RC = 'R' the rows of U and V are to be compared.
  55. *> If RC = 'C' the columns of U and V are to be compared.
  56. *> \endverbatim
  57. *>
  58. *> \param[in] MU
  59. *> \verbatim
  60. *> MU is INTEGER
  61. *> The number of rows of U if RC = 'R', and the number of
  62. *> columns if RC = 'C'. If MU = 0 CUNT03 does nothing.
  63. *> MU must be at least zero.
  64. *> \endverbatim
  65. *>
  66. *> \param[in] MV
  67. *> \verbatim
  68. *> MV is INTEGER
  69. *> The number of rows of V if RC = 'R', and the number of
  70. *> columns if RC = 'C'. If MV = 0 CUNT03 does nothing.
  71. *> MV must be at least zero.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] N
  75. *> \verbatim
  76. *> N is INTEGER
  77. *> If RC = 'R', the number of columns in the matrices U and V,
  78. *> and if RC = 'C', the number of rows in U and V. If N = 0
  79. *> CUNT03 does nothing. N must be at least zero.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] K
  83. *> \verbatim
  84. *> K is INTEGER
  85. *> The number of rows or columns of U and V to compare.
  86. *> 0 <= K <= max(MU,MV).
  87. *> \endverbatim
  88. *>
  89. *> \param[in] U
  90. *> \verbatim
  91. *> U is COMPLEX array, dimension (LDU,N)
  92. *> The first matrix to compare. If RC = 'R', U is MU by N, and
  93. *> if RC = 'C', U is N by MU.
  94. *> \endverbatim
  95. *>
  96. *> \param[in] LDU
  97. *> \verbatim
  98. *> LDU is INTEGER
  99. *> The leading dimension of U. If RC = 'R', LDU >= max(1,MU),
  100. *> and if RC = 'C', LDU >= max(1,N).
  101. *> \endverbatim
  102. *>
  103. *> \param[in] V
  104. *> \verbatim
  105. *> V is COMPLEX array, dimension (LDV,N)
  106. *> The second matrix to compare. If RC = 'R', V is MV by N, and
  107. *> if RC = 'C', V is N by MV.
  108. *> \endverbatim
  109. *>
  110. *> \param[in] LDV
  111. *> \verbatim
  112. *> LDV is INTEGER
  113. *> The leading dimension of V. If RC = 'R', LDV >= max(1,MV),
  114. *> and if RC = 'C', LDV >= max(1,N).
  115. *> \endverbatim
  116. *>
  117. *> \param[out] WORK
  118. *> \verbatim
  119. *> WORK is COMPLEX array, dimension (LWORK)
  120. *> \endverbatim
  121. *>
  122. *> \param[in] LWORK
  123. *> \verbatim
  124. *> LWORK is INTEGER
  125. *> The length of the array WORK. For best performance, LWORK
  126. *> should be at least N*N if RC = 'C' or M*M if RC = 'R', but
  127. *> the tests will be done even if LWORK is 0.
  128. *> \endverbatim
  129. *>
  130. *> \param[out] RWORK
  131. *> \verbatim
  132. *> RWORK is REAL array, dimension (max(MV,N))
  133. *> \endverbatim
  134. *>
  135. *> \param[out] RESULT
  136. *> \verbatim
  137. *> RESULT is REAL
  138. *> The value computed by the test described above. RESULT is
  139. *> limited to 1/ulp to avoid overflow.
  140. *> \endverbatim
  141. *>
  142. *> \param[out] INFO
  143. *> \verbatim
  144. *> INFO is INTEGER
  145. *> 0 indicates a successful exit
  146. *> -k indicates the k-th parameter had an illegal value
  147. *> \endverbatim
  148. *
  149. * Authors:
  150. * ========
  151. *
  152. *> \author Univ. of Tennessee
  153. *> \author Univ. of California Berkeley
  154. *> \author Univ. of Colorado Denver
  155. *> \author NAG Ltd.
  156. *
  157. *> \date December 2016
  158. *
  159. *> \ingroup complex_eig
  160. *
  161. * =====================================================================
  162. SUBROUTINE CUNT03( RC, MU, MV, N, K, U, LDU, V, LDV, WORK, LWORK,
  163. $ RWORK, RESULT, INFO )
  164. *
  165. * -- LAPACK test routine (version 3.7.0) --
  166. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  167. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  168. * December 2016
  169. *
  170. * .. Scalar Arguments ..
  171. CHARACTER*( * ) RC
  172. INTEGER INFO, K, LDU, LDV, LWORK, MU, MV, N
  173. REAL RESULT
  174. * ..
  175. * .. Array Arguments ..
  176. REAL RWORK( * )
  177. COMPLEX U( LDU, * ), V( LDV, * ), WORK( * )
  178. * ..
  179. *
  180. * =====================================================================
  181. *
  182. *
  183. * .. Parameters ..
  184. REAL ZERO, ONE
  185. PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
  186. * ..
  187. * .. Local Scalars ..
  188. INTEGER I, IRC, J, LMX
  189. REAL RES1, RES2, ULP
  190. COMPLEX S, SU, SV
  191. * ..
  192. * .. External Functions ..
  193. LOGICAL LSAME
  194. INTEGER ICAMAX
  195. REAL SLAMCH
  196. EXTERNAL LSAME, ICAMAX, SLAMCH
  197. * ..
  198. * .. Intrinsic Functions ..
  199. INTRINSIC ABS, CMPLX, MAX, MIN, REAL
  200. * ..
  201. * .. External Subroutines ..
  202. EXTERNAL CUNT01, XERBLA
  203. * ..
  204. * .. Executable Statements ..
  205. *
  206. * Check inputs
  207. *
  208. INFO = 0
  209. IF( LSAME( RC, 'R' ) ) THEN
  210. IRC = 0
  211. ELSE IF( LSAME( RC, 'C' ) ) THEN
  212. IRC = 1
  213. ELSE
  214. IRC = -1
  215. END IF
  216. IF( IRC.EQ.-1 ) THEN
  217. INFO = -1
  218. ELSE IF( MU.LT.0 ) THEN
  219. INFO = -2
  220. ELSE IF( MV.LT.0 ) THEN
  221. INFO = -3
  222. ELSE IF( N.LT.0 ) THEN
  223. INFO = -4
  224. ELSE IF( K.LT.0 .OR. K.GT.MAX( MU, MV ) ) THEN
  225. INFO = -5
  226. ELSE IF( ( IRC.EQ.0 .AND. LDU.LT.MAX( 1, MU ) ) .OR.
  227. $ ( IRC.EQ.1 .AND. LDU.LT.MAX( 1, N ) ) ) THEN
  228. INFO = -7
  229. ELSE IF( ( IRC.EQ.0 .AND. LDV.LT.MAX( 1, MV ) ) .OR.
  230. $ ( IRC.EQ.1 .AND. LDV.LT.MAX( 1, N ) ) ) THEN
  231. INFO = -9
  232. END IF
  233. IF( INFO.NE.0 ) THEN
  234. CALL XERBLA( 'CUNT03', -INFO )
  235. RETURN
  236. END IF
  237. *
  238. * Initialize result
  239. *
  240. RESULT = ZERO
  241. IF( MU.EQ.0 .OR. MV.EQ.0 .OR. N.EQ.0 )
  242. $ RETURN
  243. *
  244. * Machine constants
  245. *
  246. ULP = SLAMCH( 'Precision' )
  247. *
  248. IF( IRC.EQ.0 ) THEN
  249. *
  250. * Compare rows
  251. *
  252. RES1 = ZERO
  253. DO 20 I = 1, K
  254. LMX = ICAMAX( N, U( I, 1 ), LDU )
  255. IF( V( I, LMX ).EQ.CMPLX( ZERO ) ) THEN
  256. SV = ONE
  257. ELSE
  258. SV = ABS( V( I, LMX ) ) / V( I, LMX )
  259. END IF
  260. IF( U( I, LMX ).EQ.CMPLX( ZERO ) ) THEN
  261. SU = ONE
  262. ELSE
  263. SU = ABS( U( I, LMX ) ) / U( I, LMX )
  264. END IF
  265. S = SV / SU
  266. DO 10 J = 1, N
  267. RES1 = MAX( RES1, ABS( U( I, J )-S*V( I, J ) ) )
  268. 10 CONTINUE
  269. 20 CONTINUE
  270. RES1 = RES1 / ( REAL( N )*ULP )
  271. *
  272. * Compute orthogonality of rows of V.
  273. *
  274. CALL CUNT01( 'Rows', MV, N, V, LDV, WORK, LWORK, RWORK, RES2 )
  275. *
  276. ELSE
  277. *
  278. * Compare columns
  279. *
  280. RES1 = ZERO
  281. DO 40 I = 1, K
  282. LMX = ICAMAX( N, U( 1, I ), 1 )
  283. IF( V( LMX, I ).EQ.CMPLX( ZERO ) ) THEN
  284. SV = ONE
  285. ELSE
  286. SV = ABS( V( LMX, I ) ) / V( LMX, I )
  287. END IF
  288. IF( U( LMX, I ).EQ.CMPLX( ZERO ) ) THEN
  289. SU = ONE
  290. ELSE
  291. SU = ABS( U( LMX, I ) ) / U( LMX, I )
  292. END IF
  293. S = SV / SU
  294. DO 30 J = 1, N
  295. RES1 = MAX( RES1, ABS( U( J, I )-S*V( J, I ) ) )
  296. 30 CONTINUE
  297. 40 CONTINUE
  298. RES1 = RES1 / ( REAL( N )*ULP )
  299. *
  300. * Compute orthogonality of columns of V.
  301. *
  302. CALL CUNT01( 'Columns', N, MV, V, LDV, WORK, LWORK, RWORK,
  303. $ RES2 )
  304. END IF
  305. *
  306. RESULT = MIN( MAX( RES1, RES2 ), ONE / ULP )
  307. RETURN
  308. *
  309. * End of CUNT03
  310. *
  311. END