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.

zhbgvd.f 13 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. *> \brief \b ZHBGVD
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download ZHBGVD + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhbgvd.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhbgvd.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhbgvd.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE ZHBGVD( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, W,
  22. * Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK,
  23. * LIWORK, INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * CHARACTER JOBZ, UPLO
  27. * INTEGER INFO, KA, KB, LDAB, LDBB, LDZ, LIWORK, LRWORK,
  28. * $ LWORK, N
  29. * ..
  30. * .. Array Arguments ..
  31. * INTEGER IWORK( * )
  32. * DOUBLE PRECISION RWORK( * ), W( * )
  33. * COMPLEX*16 AB( LDAB, * ), BB( LDBB, * ), WORK( * ),
  34. * $ Z( LDZ, * )
  35. * ..
  36. *
  37. *
  38. *> \par Purpose:
  39. * =============
  40. *>
  41. *> \verbatim
  42. *>
  43. *> ZHBGVD computes all the eigenvalues, and optionally, the eigenvectors
  44. *> of a complex generalized Hermitian-definite banded eigenproblem, of
  45. *> the form A*x=(lambda)*B*x. Here A and B are assumed to be Hermitian
  46. *> and banded, and B is also positive definite. If eigenvectors are
  47. *> desired, it uses a divide and conquer algorithm.
  48. *>
  49. *> \endverbatim
  50. *
  51. * Arguments:
  52. * ==========
  53. *
  54. *> \param[in] JOBZ
  55. *> \verbatim
  56. *> JOBZ is CHARACTER*1
  57. *> = 'N': Compute eigenvalues only;
  58. *> = 'V': Compute eigenvalues and eigenvectors.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] UPLO
  62. *> \verbatim
  63. *> UPLO is CHARACTER*1
  64. *> = 'U': Upper triangles of A and B are stored;
  65. *> = 'L': Lower triangles of A and B are stored.
  66. *> \endverbatim
  67. *>
  68. *> \param[in] N
  69. *> \verbatim
  70. *> N is INTEGER
  71. *> The order of the matrices A and B. N >= 0.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] KA
  75. *> \verbatim
  76. *> KA is INTEGER
  77. *> The number of superdiagonals of the matrix A if UPLO = 'U',
  78. *> or the number of subdiagonals if UPLO = 'L'. KA >= 0.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] KB
  82. *> \verbatim
  83. *> KB is INTEGER
  84. *> The number of superdiagonals of the matrix B if UPLO = 'U',
  85. *> or the number of subdiagonals if UPLO = 'L'. KB >= 0.
  86. *> \endverbatim
  87. *>
  88. *> \param[in,out] AB
  89. *> \verbatim
  90. *> AB is COMPLEX*16 array, dimension (LDAB, N)
  91. *> On entry, the upper or lower triangle of the Hermitian band
  92. *> matrix A, stored in the first ka+1 rows of the array. The
  93. *> j-th column of A is stored in the j-th column of the array AB
  94. *> as follows:
  95. *> if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j;
  96. *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka).
  97. *>
  98. *> On exit, the contents of AB are destroyed.
  99. *> \endverbatim
  100. *>
  101. *> \param[in] LDAB
  102. *> \verbatim
  103. *> LDAB is INTEGER
  104. *> The leading dimension of the array AB. LDAB >= KA+1.
  105. *> \endverbatim
  106. *>
  107. *> \param[in,out] BB
  108. *> \verbatim
  109. *> BB is COMPLEX*16 array, dimension (LDBB, N)
  110. *> On entry, the upper or lower triangle of the Hermitian band
  111. *> matrix B, stored in the first kb+1 rows of the array. The
  112. *> j-th column of B is stored in the j-th column of the array BB
  113. *> as follows:
  114. *> if UPLO = 'U', BB(kb+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j;
  115. *> if UPLO = 'L', BB(1+i-j,j) = B(i,j) for j<=i<=min(n,j+kb).
  116. *>
  117. *> On exit, the factor S from the split Cholesky factorization
  118. *> B = S**H*S, as returned by ZPBSTF.
  119. *> \endverbatim
  120. *>
  121. *> \param[in] LDBB
  122. *> \verbatim
  123. *> LDBB is INTEGER
  124. *> The leading dimension of the array BB. LDBB >= KB+1.
  125. *> \endverbatim
  126. *>
  127. *> \param[out] W
  128. *> \verbatim
  129. *> W is DOUBLE PRECISION array, dimension (N)
  130. *> If INFO = 0, the eigenvalues in ascending order.
  131. *> \endverbatim
  132. *>
  133. *> \param[out] Z
  134. *> \verbatim
  135. *> Z is COMPLEX*16 array, dimension (LDZ, N)
  136. *> If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
  137. *> eigenvectors, with the i-th column of Z holding the
  138. *> eigenvector associated with W(i). The eigenvectors are
  139. *> normalized so that Z**H*B*Z = I.
  140. *> If JOBZ = 'N', then Z is not referenced.
  141. *> \endverbatim
  142. *>
  143. *> \param[in] LDZ
  144. *> \verbatim
  145. *> LDZ is INTEGER
  146. *> The leading dimension of the array Z. LDZ >= 1, and if
  147. *> JOBZ = 'V', LDZ >= N.
  148. *> \endverbatim
  149. *>
  150. *> \param[out] WORK
  151. *> \verbatim
  152. *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
  153. *> On exit, if INFO=0, WORK(1) returns the optimal LWORK.
  154. *> \endverbatim
  155. *>
  156. *> \param[in] LWORK
  157. *> \verbatim
  158. *> LWORK is INTEGER
  159. *> The dimension of the array WORK.
  160. *> If N <= 1, LWORK >= 1.
  161. *> If JOBZ = 'N' and N > 1, LWORK >= N.
  162. *> If JOBZ = 'V' and N > 1, LWORK >= 2*N**2.
  163. *>
  164. *> If LWORK = -1, then a workspace query is assumed; the routine
  165. *> only calculates the optimal sizes of the WORK, RWORK and
  166. *> IWORK arrays, returns these values as the first entries of
  167. *> the WORK, RWORK and IWORK arrays, and no error message
  168. *> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
  169. *> \endverbatim
  170. *>
  171. *> \param[out] RWORK
  172. *> \verbatim
  173. *> RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK))
  174. *> On exit, if INFO=0, RWORK(1) returns the optimal LRWORK.
  175. *> \endverbatim
  176. *>
  177. *> \param[in] LRWORK
  178. *> \verbatim
  179. *> LRWORK is INTEGER
  180. *> The dimension of array RWORK.
  181. *> If N <= 1, LRWORK >= 1.
  182. *> If JOBZ = 'N' and N > 1, LRWORK >= N.
  183. *> If JOBZ = 'V' and N > 1, LRWORK >= 1 + 5*N + 2*N**2.
  184. *>
  185. *> If LRWORK = -1, then a workspace query is assumed; the
  186. *> routine only calculates the optimal sizes of the WORK, RWORK
  187. *> and IWORK arrays, returns these values as the first entries
  188. *> of the WORK, RWORK and IWORK arrays, and no error message
  189. *> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
  190. *> \endverbatim
  191. *>
  192. *> \param[out] IWORK
  193. *> \verbatim
  194. *> IWORK is INTEGER array, dimension (MAX(1,LIWORK))
  195. *> On exit, if INFO=0, IWORK(1) returns the optimal LIWORK.
  196. *> \endverbatim
  197. *>
  198. *> \param[in] LIWORK
  199. *> \verbatim
  200. *> LIWORK is INTEGER
  201. *> The dimension of array IWORK.
  202. *> If JOBZ = 'N' or N <= 1, LIWORK >= 1.
  203. *> If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N.
  204. *>
  205. *> If LIWORK = -1, then a workspace query is assumed; the
  206. *> routine only calculates the optimal sizes of the WORK, RWORK
  207. *> and IWORK arrays, returns these values as the first entries
  208. *> of the WORK, RWORK and IWORK arrays, and no error message
  209. *> related to LWORK or LRWORK or LIWORK is issued by XERBLA.
  210. *> \endverbatim
  211. *>
  212. *> \param[out] INFO
  213. *> \verbatim
  214. *> INFO is INTEGER
  215. *> = 0: successful exit
  216. *> < 0: if INFO = -i, the i-th argument had an illegal value
  217. *> > 0: if INFO = i, and i is:
  218. *> <= N: the algorithm failed to converge:
  219. *> i off-diagonal elements of an intermediate
  220. *> tridiagonal form did not converge to zero;
  221. *> > N: if INFO = N + i, for 1 <= i <= N, then ZPBSTF
  222. *> returned INFO = i: B is not positive definite.
  223. *> The factorization of B could not be completed and
  224. *> no eigenvalues or eigenvectors were computed.
  225. *> \endverbatim
  226. *
  227. * Authors:
  228. * ========
  229. *
  230. *> \author Univ. of Tennessee
  231. *> \author Univ. of California Berkeley
  232. *> \author Univ. of Colorado Denver
  233. *> \author NAG Ltd.
  234. *
  235. *> \ingroup complex16OTHEReigen
  236. *
  237. *> \par Contributors:
  238. * ==================
  239. *>
  240. *> Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  241. *
  242. * =====================================================================
  243. SUBROUTINE ZHBGVD( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, W,
  244. $ Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK,
  245. $ LIWORK, INFO )
  246. *
  247. * -- LAPACK driver routine --
  248. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  249. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  250. *
  251. * .. Scalar Arguments ..
  252. CHARACTER JOBZ, UPLO
  253. INTEGER INFO, KA, KB, LDAB, LDBB, LDZ, LIWORK, LRWORK,
  254. $ LWORK, N
  255. * ..
  256. * .. Array Arguments ..
  257. INTEGER IWORK( * )
  258. DOUBLE PRECISION RWORK( * ), W( * )
  259. COMPLEX*16 AB( LDAB, * ), BB( LDBB, * ), WORK( * ),
  260. $ Z( LDZ, * )
  261. * ..
  262. *
  263. * =====================================================================
  264. *
  265. * .. Parameters ..
  266. COMPLEX*16 CONE, CZERO
  267. PARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ),
  268. $ CZERO = ( 0.0D+0, 0.0D+0 ) )
  269. * ..
  270. * .. Local Scalars ..
  271. LOGICAL LQUERY, UPPER, WANTZ
  272. CHARACTER VECT
  273. INTEGER IINFO, INDE, INDWK2, INDWRK, LIWMIN, LLRWK,
  274. $ LLWK2, LRWMIN, LWMIN
  275. * ..
  276. * .. External Functions ..
  277. LOGICAL LSAME
  278. EXTERNAL LSAME
  279. * ..
  280. * .. External Subroutines ..
  281. EXTERNAL DSTERF, XERBLA, ZGEMM, ZHBGST, ZHBTRD, ZLACPY,
  282. $ ZPBSTF, ZSTEDC
  283. * ..
  284. * .. Executable Statements ..
  285. *
  286. * Test the input parameters.
  287. *
  288. WANTZ = LSAME( JOBZ, 'V' )
  289. UPPER = LSAME( UPLO, 'U' )
  290. LQUERY = ( LWORK.EQ.-1 .OR. LRWORK.EQ.-1 .OR. LIWORK.EQ.-1 )
  291. *
  292. INFO = 0
  293. IF( N.LE.1 ) THEN
  294. LWMIN = 1+N
  295. LRWMIN = 1+N
  296. LIWMIN = 1
  297. ELSE IF( WANTZ ) THEN
  298. LWMIN = 2*N**2
  299. LRWMIN = 1 + 5*N + 2*N**2
  300. LIWMIN = 3 + 5*N
  301. ELSE
  302. LWMIN = N
  303. LRWMIN = N
  304. LIWMIN = 1
  305. END IF
  306. IF( .NOT.( WANTZ .OR. LSAME( JOBZ, 'N' ) ) ) THEN
  307. INFO = -1
  308. ELSE IF( .NOT.( UPPER .OR. LSAME( UPLO, 'L' ) ) ) THEN
  309. INFO = -2
  310. ELSE IF( N.LT.0 ) THEN
  311. INFO = -3
  312. ELSE IF( KA.LT.0 ) THEN
  313. INFO = -4
  314. ELSE IF( KB.LT.0 .OR. KB.GT.KA ) THEN
  315. INFO = -5
  316. ELSE IF( LDAB.LT.KA+1 ) THEN
  317. INFO = -7
  318. ELSE IF( LDBB.LT.KB+1 ) THEN
  319. INFO = -9
  320. ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.N ) ) THEN
  321. INFO = -12
  322. END IF
  323. *
  324. IF( INFO.EQ.0 ) THEN
  325. WORK( 1 ) = LWMIN
  326. RWORK( 1 ) = LRWMIN
  327. IWORK( 1 ) = LIWMIN
  328. *
  329. IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
  330. INFO = -14
  331. ELSE IF( LRWORK.LT.LRWMIN .AND. .NOT.LQUERY ) THEN
  332. INFO = -16
  333. ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN
  334. INFO = -18
  335. END IF
  336. END IF
  337. *
  338. IF( INFO.NE.0 ) THEN
  339. CALL XERBLA( 'ZHBGVD', -INFO )
  340. RETURN
  341. ELSE IF( LQUERY ) THEN
  342. RETURN
  343. END IF
  344. *
  345. * Quick return if possible
  346. *
  347. IF( N.EQ.0 )
  348. $ RETURN
  349. *
  350. * Form a split Cholesky factorization of B.
  351. *
  352. CALL ZPBSTF( UPLO, N, KB, BB, LDBB, INFO )
  353. IF( INFO.NE.0 ) THEN
  354. INFO = N + INFO
  355. RETURN
  356. END IF
  357. *
  358. * Transform problem to standard eigenvalue problem.
  359. *
  360. INDE = 1
  361. INDWRK = INDE + N
  362. INDWK2 = 1 + N*N
  363. LLWK2 = LWORK - INDWK2 + 2
  364. LLRWK = LRWORK - INDWRK + 2
  365. CALL ZHBGST( JOBZ, UPLO, N, KA, KB, AB, LDAB, BB, LDBB, Z, LDZ,
  366. $ WORK, RWORK, IINFO )
  367. *
  368. * Reduce Hermitian band matrix to tridiagonal form.
  369. *
  370. IF( WANTZ ) THEN
  371. VECT = 'U'
  372. ELSE
  373. VECT = 'N'
  374. END IF
  375. CALL ZHBTRD( VECT, UPLO, N, KA, AB, LDAB, W, RWORK( INDE ), Z,
  376. $ LDZ, WORK, IINFO )
  377. *
  378. * For eigenvalues only, call DSTERF. For eigenvectors, call ZSTEDC.
  379. *
  380. IF( .NOT.WANTZ ) THEN
  381. CALL DSTERF( N, W, RWORK( INDE ), INFO )
  382. ELSE
  383. CALL ZSTEDC( 'I', N, W, RWORK( INDE ), WORK, N, WORK( INDWK2 ),
  384. $ LLWK2, RWORK( INDWRK ), LLRWK, IWORK, LIWORK,
  385. $ INFO )
  386. CALL ZGEMM( 'N', 'N', N, N, N, CONE, Z, LDZ, WORK, N, CZERO,
  387. $ WORK( INDWK2 ), N )
  388. CALL ZLACPY( 'A', N, N, WORK( INDWK2 ), N, Z, LDZ )
  389. END IF
  390. *
  391. WORK( 1 ) = LWMIN
  392. RWORK( 1 ) = LRWMIN
  393. IWORK( 1 ) = LIWMIN
  394. RETURN
  395. *
  396. * End of ZHBGVD
  397. *
  398. END