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.

sspgvx.f 13 kB

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