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.

chpgvx.f 13 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. *> \brief \b CHPGVX
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CHPGVX + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chpgvx.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chpgvx.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chpgvx.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CHPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
  22. * IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
  23. * IWORK, IFAIL, INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * CHARACTER JOBZ, RANGE, UPLO
  27. * INTEGER IL, INFO, ITYPE, IU, LDZ, M, N
  28. * REAL ABSTOL, VL, VU
  29. * ..
  30. * .. Array Arguments ..
  31. * INTEGER IFAIL( * ), IWORK( * )
  32. * REAL RWORK( * ), W( * )
  33. * COMPLEX AP( * ), BP( * ), WORK( * ), Z( LDZ, * )
  34. * ..
  35. *
  36. *
  37. *> \par Purpose:
  38. * =============
  39. *>
  40. *> \verbatim
  41. *>
  42. *> CHPGVX computes selected eigenvalues and, optionally, eigenvectors
  43. *> of a complex generalized Hermitian-definite eigenproblem, of the form
  44. *> A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and
  45. *> B are assumed to be Hermitian, stored in packed format, and B is also
  46. *> positive definite. Eigenvalues and eigenvectors can be selected by
  47. *> specifying either a range of values or a range of indices for the
  48. *> desired eigenvalues.
  49. *> \endverbatim
  50. *
  51. * Arguments:
  52. * ==========
  53. *
  54. *> \param[in] ITYPE
  55. *> \verbatim
  56. *> ITYPE is INTEGER
  57. *> Specifies the problem type to be solved:
  58. *> = 1: A*x = (lambda)*B*x
  59. *> = 2: A*B*x = (lambda)*x
  60. *> = 3: B*A*x = (lambda)*x
  61. *> \endverbatim
  62. *>
  63. *> \param[in] JOBZ
  64. *> \verbatim
  65. *> JOBZ is CHARACTER*1
  66. *> = 'N': Compute eigenvalues only;
  67. *> = 'V': Compute eigenvalues and eigenvectors.
  68. *> \endverbatim
  69. *>
  70. *> \param[in] RANGE
  71. *> \verbatim
  72. *> RANGE is CHARACTER*1
  73. *> = 'A': all eigenvalues will be found;
  74. *> = 'V': all eigenvalues in the half-open interval (VL,VU]
  75. *> will be found;
  76. *> = 'I': the IL-th through IU-th eigenvalues will be found.
  77. *> \endverbatim
  78. *>
  79. *> \param[in] UPLO
  80. *> \verbatim
  81. *> UPLO is CHARACTER*1
  82. *> = 'U': Upper triangles of A and B are stored;
  83. *> = 'L': Lower triangles of A and B are stored.
  84. *> \endverbatim
  85. *>
  86. *> \param[in] N
  87. *> \verbatim
  88. *> N is INTEGER
  89. *> The order of the matrices A and B. N >= 0.
  90. *> \endverbatim
  91. *>
  92. *> \param[in,out] AP
  93. *> \verbatim
  94. *> AP is COMPLEX array, dimension (N*(N+1)/2)
  95. *> On entry, the upper or lower triangle of the Hermitian matrix
  96. *> A, packed columnwise in a linear array. The j-th column of A
  97. *> is stored in the array AP as follows:
  98. *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  99. *> if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  100. *>
  101. *> On exit, the contents of AP are destroyed.
  102. *> \endverbatim
  103. *>
  104. *> \param[in,out] BP
  105. *> \verbatim
  106. *> BP is COMPLEX array, dimension (N*(N+1)/2)
  107. *> On entry, the upper or lower triangle of the Hermitian matrix
  108. *> B, packed columnwise in a linear array. The j-th column of B
  109. *> is stored in the array BP as follows:
  110. *> if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
  111. *> if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
  112. *>
  113. *> On exit, the triangular factor U or L from the Cholesky
  114. *> factorization B = U**H*U or B = L*L**H, in the same storage
  115. *> format as B.
  116. *> \endverbatim
  117. *>
  118. *> \param[in] VL
  119. *> \verbatim
  120. *> VL is REAL
  121. *>
  122. *> If RANGE='V', the lower bound of the interval to
  123. *> be searched for eigenvalues. VL < VU.
  124. *> Not referenced if RANGE = 'A' or 'I'.
  125. *> \endverbatim
  126. *>
  127. *> \param[in] VU
  128. *> \verbatim
  129. *> VU is REAL
  130. *>
  131. *> If RANGE='V', the upper bound of the interval to
  132. *> be searched for eigenvalues. VL < VU.
  133. *> Not referenced if RANGE = 'A' or 'I'.
  134. *> \endverbatim
  135. *>
  136. *> \param[in] IL
  137. *> \verbatim
  138. *> IL is INTEGER
  139. *>
  140. *> If RANGE='I', the index of the
  141. *> smallest eigenvalue to be returned.
  142. *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  143. *> Not referenced if RANGE = 'A' or 'V'.
  144. *> \endverbatim
  145. *>
  146. *> \param[in] IU
  147. *> \verbatim
  148. *> IU is INTEGER
  149. *>
  150. *> If RANGE='I', the index of the
  151. *> largest eigenvalue to be returned.
  152. *> 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  153. *> Not referenced if RANGE = 'A' or 'V'.
  154. *> \endverbatim
  155. *>
  156. *> \param[in] ABSTOL
  157. *> \verbatim
  158. *> ABSTOL is REAL
  159. *> The absolute error tolerance for the eigenvalues.
  160. *> An approximate eigenvalue is accepted as converged
  161. *> when it is determined to lie in an interval [a,b]
  162. *> of width less than or equal to
  163. *>
  164. *> ABSTOL + EPS * max( |a|,|b| ) ,
  165. *>
  166. *> where EPS is the machine precision. If ABSTOL is less than
  167. *> or equal to zero, then EPS*|T| will be used in its place,
  168. *> where |T| is the 1-norm of the tridiagonal matrix obtained
  169. *> by reducing AP to tridiagonal form.
  170. *>
  171. *> Eigenvalues will be computed most accurately when ABSTOL is
  172. *> set to twice the underflow threshold 2*SLAMCH('S'), not zero.
  173. *> If this routine returns with INFO>0, indicating that some
  174. *> eigenvectors did not converge, try setting ABSTOL to
  175. *> 2*SLAMCH('S').
  176. *> \endverbatim
  177. *>
  178. *> \param[out] M
  179. *> \verbatim
  180. *> M is INTEGER
  181. *> The total number of eigenvalues found. 0 <= M <= N.
  182. *> If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  183. *> \endverbatim
  184. *>
  185. *> \param[out] W
  186. *> \verbatim
  187. *> W is REAL array, dimension (N)
  188. *> On normal exit, the first M elements contain the selected
  189. *> eigenvalues in ascending order.
  190. *> \endverbatim
  191. *>
  192. *> \param[out] Z
  193. *> \verbatim
  194. *> Z is COMPLEX array, dimension (LDZ, N)
  195. *> If JOBZ = 'N', then Z is not referenced.
  196. *> If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  197. *> contain the orthonormal eigenvectors of the matrix A
  198. *> corresponding to the selected eigenvalues, with the i-th
  199. *> column of Z holding the eigenvector associated with W(i).
  200. *> The eigenvectors are normalized as follows:
  201. *> if ITYPE = 1 or 2, Z**H*B*Z = I;
  202. *> if ITYPE = 3, Z**H*inv(B)*Z = I.
  203. *>
  204. *> If an eigenvector fails to converge, then that column of Z
  205. *> contains the latest approximation to the eigenvector, and the
  206. *> index of the eigenvector is returned in IFAIL.
  207. *> Note: the user must ensure that at least max(1,M) columns are
  208. *> supplied in the array Z; if RANGE = 'V', the exact value of M
  209. *> is not known in advance and an upper bound must be used.
  210. *> \endverbatim
  211. *>
  212. *> \param[in] LDZ
  213. *> \verbatim
  214. *> LDZ is INTEGER
  215. *> The leading dimension of the array Z. LDZ >= 1, and if
  216. *> JOBZ = 'V', LDZ >= max(1,N).
  217. *> \endverbatim
  218. *>
  219. *> \param[out] WORK
  220. *> \verbatim
  221. *> WORK is COMPLEX array, dimension (2*N)
  222. *> \endverbatim
  223. *>
  224. *> \param[out] RWORK
  225. *> \verbatim
  226. *> RWORK is REAL array, dimension (7*N)
  227. *> \endverbatim
  228. *>
  229. *> \param[out] IWORK
  230. *> \verbatim
  231. *> IWORK is INTEGER array, dimension (5*N)
  232. *> \endverbatim
  233. *>
  234. *> \param[out] IFAIL
  235. *> \verbatim
  236. *> IFAIL is INTEGER array, dimension (N)
  237. *> If JOBZ = 'V', then if INFO = 0, the first M elements of
  238. *> IFAIL are zero. If INFO > 0, then IFAIL contains the
  239. *> indices of the eigenvectors that failed to converge.
  240. *> If JOBZ = 'N', then IFAIL is not referenced.
  241. *> \endverbatim
  242. *>
  243. *> \param[out] INFO
  244. *> \verbatim
  245. *> INFO is INTEGER
  246. *> = 0: successful exit
  247. *> < 0: if INFO = -i, the i-th argument had an illegal value
  248. *> > 0: CPPTRF or CHPEVX returned an error code:
  249. *> <= N: if INFO = i, CHPEVX failed to converge;
  250. *> i eigenvectors failed to converge. Their indices
  251. *> are stored in array IFAIL.
  252. *> > N: if INFO = N + i, for 1 <= i <= n, then the leading
  253. *> principal minor of order i of B is not positive.
  254. *> The factorization of B could not be completed and
  255. *> no eigenvalues or eigenvectors were computed.
  256. *> \endverbatim
  257. *
  258. * Authors:
  259. * ========
  260. *
  261. *> \author Univ. of Tennessee
  262. *> \author Univ. of California Berkeley
  263. *> \author Univ. of Colorado Denver
  264. *> \author NAG Ltd.
  265. *
  266. *> \ingroup complexOTHEReigen
  267. *
  268. *> \par Contributors:
  269. * ==================
  270. *>
  271. *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  272. *
  273. * =====================================================================
  274. SUBROUTINE CHPGVX( ITYPE, JOBZ, RANGE, UPLO, N, AP, BP, VL, VU,
  275. $ IL, IU, ABSTOL, M, W, Z, LDZ, WORK, RWORK,
  276. $ IWORK, IFAIL, INFO )
  277. *
  278. * -- LAPACK driver routine --
  279. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  280. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  281. *
  282. * .. Scalar Arguments ..
  283. CHARACTER JOBZ, RANGE, UPLO
  284. INTEGER IL, INFO, ITYPE, IU, LDZ, M, N
  285. REAL ABSTOL, VL, VU
  286. * ..
  287. * .. Array Arguments ..
  288. INTEGER IFAIL( * ), IWORK( * )
  289. REAL RWORK( * ), W( * )
  290. COMPLEX AP( * ), BP( * ), WORK( * ), Z( LDZ, * )
  291. * ..
  292. *
  293. * =====================================================================
  294. *
  295. * .. Local Scalars ..
  296. LOGICAL ALLEIG, INDEIG, UPPER, VALEIG, WANTZ
  297. CHARACTER TRANS
  298. INTEGER J
  299. * ..
  300. * .. External Functions ..
  301. LOGICAL LSAME
  302. EXTERNAL LSAME
  303. * ..
  304. * .. External Subroutines ..
  305. EXTERNAL CHPEVX, CHPGST, CPPTRF, CTPMV, CTPSV, XERBLA
  306. * ..
  307. * .. Intrinsic Functions ..
  308. INTRINSIC MIN
  309. * ..
  310. * .. Executable Statements ..
  311. *
  312. * Test the input parameters.
  313. *
  314. WANTZ = LSAME( JOBZ, 'V' )
  315. UPPER = LSAME( UPLO, 'U' )
  316. ALLEIG = LSAME( RANGE, 'A' )
  317. VALEIG = LSAME( RANGE, 'V' )
  318. INDEIG = LSAME( RANGE, 'I' )
  319. *
  320. INFO = 0
  321. IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
  322. INFO = -1
  323. ELSE IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
  324. INFO = -2
  325. ELSE IF( .NOT.( ALLEIG .OR. VALEIG .OR. INDEIG ) ) THEN
  326. INFO = -3
  327. ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
  328. INFO = -4
  329. ELSE IF( N.LT.0 ) THEN
  330. INFO = -5
  331. ELSE
  332. IF( VALEIG ) THEN
  333. IF( N.GT.0 .AND. VU.LE.VL ) THEN
  334. INFO = -9
  335. END IF
  336. ELSE IF( INDEIG ) THEN
  337. IF( IL.LT.1 ) THEN
  338. INFO = -10
  339. ELSE IF( IU.LT.MIN( N, IL ) .OR. IU.GT.N ) THEN
  340. INFO = -11
  341. END IF
  342. END IF
  343. END IF
  344. IF( INFO.EQ.0 ) THEN
  345. IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
  346. INFO = -16
  347. END IF
  348. END IF
  349. *
  350. IF( INFO.NE.0 ) THEN
  351. CALL XERBLA( 'CHPGVX', -INFO )
  352. RETURN
  353. END IF
  354. *
  355. * Quick return if possible
  356. *
  357. IF( N.EQ.0 )
  358. $ RETURN
  359. *
  360. * Form a Cholesky factorization of B.
  361. *
  362. CALL CPPTRF( UPLO, N, BP, INFO )
  363. IF( INFO.NE.0 ) THEN
  364. INFO = N + INFO
  365. RETURN
  366. END IF
  367. *
  368. * Transform problem to standard eigenvalue problem and solve.
  369. *
  370. CALL CHPGST( ITYPE, UPLO, N, AP, BP, INFO )
  371. CALL CHPEVX( JOBZ, RANGE, UPLO, N, AP, VL, VU, IL, IU, ABSTOL, M,
  372. $ W, Z, LDZ, WORK, RWORK, IWORK, IFAIL, INFO )
  373. *
  374. IF( WANTZ ) THEN
  375. *
  376. * Backtransform eigenvectors to the original problem.
  377. *
  378. IF( INFO.GT.0 )
  379. $ M = INFO - 1
  380. IF( ITYPE.EQ.1 .OR. ITYPE.EQ.2 ) THEN
  381. *
  382. * For A*x=(lambda)*B*x and A*B*x=(lambda)*x;
  383. * backtransform eigenvectors: x = inv(L)**H*y or inv(U)*y
  384. *
  385. IF( UPPER ) THEN
  386. TRANS = 'N'
  387. ELSE
  388. TRANS = 'C'
  389. END IF
  390. *
  391. DO 10 J = 1, M
  392. CALL CTPSV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
  393. $ 1 )
  394. 10 CONTINUE
  395. *
  396. ELSE IF( ITYPE.EQ.3 ) THEN
  397. *
  398. * For B*A*x=(lambda)*x;
  399. * backtransform eigenvectors: x = L*y or U**H*y
  400. *
  401. IF( UPPER ) THEN
  402. TRANS = 'C'
  403. ELSE
  404. TRANS = 'N'
  405. END IF
  406. *
  407. DO 20 J = 1, M
  408. CALL CTPMV( UPLO, TRANS, 'Non-unit', N, BP, Z( 1, J ),
  409. $ 1 )
  410. 20 CONTINUE
  411. END IF
  412. END IF
  413. *
  414. RETURN
  415. *
  416. * End of CHPGVX
  417. *
  418. END