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.

chesv_aa.f 8.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. *> \brief <b> CHESV_AA computes the solution to system of linear equations A * X = B for HE matrices</b>
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CHESV_AA + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chesv_aa.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chesv_aa.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chesv_aa.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CHESV_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
  22. * LWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER UPLO
  26. * INTEGER INFO, LDA, LDB, LWORK, N, NRHS
  27. * ..
  28. * .. Array Arguments ..
  29. * INTEGER IPIV( * )
  30. * COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
  31. * ..
  32. *
  33. *
  34. *> \par Purpose:
  35. * =============
  36. *>
  37. *> \verbatim
  38. *>
  39. *> CHESV_AA computes the solution to a complex system of linear equations
  40. *> A * X = B,
  41. *> where A is an N-by-N Hermitian matrix and X and B are N-by-NRHS
  42. *> matrices.
  43. *>
  44. *> Aasen's algorithm is used to factor A as
  45. *> A = U * T * U**H, if UPLO = 'U', or
  46. *> A = L * T * L**H, if UPLO = 'L',
  47. *> where U (or L) is a product of permutation and unit upper (lower)
  48. *> triangular matrices, and T is Hermitian and tridiagonal. The factored form
  49. *> of A is then used to solve the system of equations A * X = B.
  50. *> \endverbatim
  51. *
  52. * Arguments:
  53. * ==========
  54. *
  55. *> \param[in] UPLO
  56. *> \verbatim
  57. *> UPLO is CHARACTER*1
  58. *> = 'U': Upper triangle of A is stored;
  59. *> = 'L': Lower triangle of A is stored.
  60. *> \endverbatim
  61. *>
  62. *> \param[in] N
  63. *> \verbatim
  64. *> N is INTEGER
  65. *> The number of linear equations, i.e., the order of the
  66. *> matrix A. N >= 0.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] NRHS
  70. *> \verbatim
  71. *> NRHS is INTEGER
  72. *> The number of right hand sides, i.e., the number of columns
  73. *> of the matrix B. NRHS >= 0.
  74. *> \endverbatim
  75. *>
  76. *> \param[in,out] A
  77. *> \verbatim
  78. *> A is COMPLEX array, dimension (LDA,N)
  79. *> On entry, the Hermitian matrix A. If UPLO = 'U', the leading
  80. *> N-by-N upper triangular part of A contains the upper
  81. *> triangular part of the matrix A, and the strictly lower
  82. *> triangular part of A is not referenced. If UPLO = 'L', the
  83. *> leading N-by-N lower triangular part of A contains the lower
  84. *> triangular part of the matrix A, and the strictly upper
  85. *> triangular part of A is not referenced.
  86. *>
  87. *> On exit, if INFO = 0, the tridiagonal matrix T and the
  88. *> multipliers used to obtain the factor U or L from the
  89. *> factorization A = U*T*U**H or A = L*T*L**H as computed by
  90. *> CHETRF_AA.
  91. *> \endverbatim
  92. *>
  93. *> \param[in] LDA
  94. *> \verbatim
  95. *> LDA is INTEGER
  96. *> The leading dimension of the array A. LDA >= max(1,N).
  97. *> \endverbatim
  98. *>
  99. *> \param[out] IPIV
  100. *> \verbatim
  101. *> IPIV is INTEGER array, dimension (N)
  102. *> On exit, it contains the details of the interchanges, i.e.,
  103. *> the row and column k of A were interchanged with the
  104. *> row and column IPIV(k).
  105. *> \endverbatim
  106. *>
  107. *> \param[in,out] B
  108. *> \verbatim
  109. *> B is COMPLEX array, dimension (LDB,NRHS)
  110. *> On entry, the N-by-NRHS right hand side matrix B.
  111. *> On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  112. *> \endverbatim
  113. *>
  114. *> \param[in] LDB
  115. *> \verbatim
  116. *> LDB is INTEGER
  117. *> The leading dimension of the array B. LDB >= max(1,N).
  118. *> \endverbatim
  119. *>
  120. *> \param[out] WORK
  121. *> \verbatim
  122. *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
  123. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  124. *> \endverbatim
  125. *>
  126. *> \param[in] LWORK
  127. *> \verbatim
  128. *> LWORK is INTEGER
  129. *> The length of WORK. LWORK >= MAX(1,2*N,3*N-2), and for best
  130. *> performance LWORK >= MAX(1,N*NB), where NB is the optimal
  131. *> blocksize for CHETRF.
  132. *> for LWORK < N, TRS will be done with Level BLAS 2
  133. *> for LWORK >= N, TRS will be done with Level BLAS 3
  134. *>
  135. *> If LWORK = -1, then a workspace query is assumed; the routine
  136. *> only calculates the optimal size of the WORK array, returns
  137. *> this value as the first entry of the WORK array, and no error
  138. *> message related to LWORK is issued by XERBLA.
  139. *> \endverbatim
  140. *>
  141. *> \param[out] INFO
  142. *> \verbatim
  143. *> INFO is INTEGER
  144. *> = 0: successful exit
  145. *> < 0: if INFO = -i, the i-th argument had an illegal value
  146. *> > 0: if INFO = i, D(i,i) is exactly zero. The factorization
  147. *> has been completed, but the block diagonal matrix D is
  148. *> exactly singular, so the solution could not be computed.
  149. *> \endverbatim
  150. *
  151. * Authors:
  152. * ========
  153. *
  154. *> \author Univ. of Tennessee
  155. *> \author Univ. of California Berkeley
  156. *> \author Univ. of Colorado Denver
  157. *> \author NAG Ltd.
  158. *
  159. *> \date December 2016
  160. *
  161. *> \ingroup complexHEsolve
  162. *
  163. * =====================================================================
  164. SUBROUTINE CHESV_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
  165. $ LWORK, INFO )
  166. *
  167. * -- LAPACK driver routine (version 3.7.0) --
  168. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  169. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  170. * December 2016
  171. *
  172. * .. Scalar Arguments ..
  173. CHARACTER UPLO
  174. INTEGER INFO, LDA, LDB, LWORK, N, NRHS
  175. * ..
  176. * .. Array Arguments ..
  177. INTEGER IPIV( * )
  178. COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
  179. * ..
  180. *
  181. * =====================================================================
  182. *
  183. * .. Local Scalars ..
  184. LOGICAL LQUERY
  185. INTEGER LWKOPT, LWKOPT_HETRF, LWKOPT_HETRS
  186. * ..
  187. * .. External Functions ..
  188. LOGICAL LSAME
  189. INTEGER ILAENV
  190. EXTERNAL LSAME, ILAENV
  191. * ..
  192. * .. External Subroutines ..
  193. EXTERNAL XERBLA, CHETRF, CHETRS, CHETRS2
  194. * ..
  195. * .. Intrinsic Functions ..
  196. INTRINSIC MAX
  197. * ..
  198. * .. Executable Statements ..
  199. *
  200. * Test the input parameters.
  201. *
  202. INFO = 0
  203. LQUERY = ( LWORK.EQ.-1 )
  204. IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  205. INFO = -1
  206. ELSE IF( N.LT.0 ) THEN
  207. INFO = -2
  208. ELSE IF( NRHS.LT.0 ) THEN
  209. INFO = -3
  210. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  211. INFO = -5
  212. ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
  213. INFO = -8
  214. END IF
  215. *
  216. IF( INFO.EQ.0 ) THEN
  217. CALL CHETRF_AA( UPLO, N, A, LDA, IPIV, WORK, -1, INFO )
  218. LWKOPT_HETRF = INT( WORK(1) )
  219. CALL CHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
  220. $ -1, INFO )
  221. LWKOPT_HETRS = INT( WORK(1) )
  222. LWKOPT = MAX( LWKOPT_HETRF, LWKOPT_HETRS )
  223. WORK( 1 ) = LWKOPT
  224. IF( LWORK.LT.LWKOPT .AND. .NOT.LQUERY ) THEN
  225. INFO = -10
  226. END IF
  227. END IF
  228. *
  229. IF( INFO.NE.0 ) THEN
  230. CALL XERBLA( 'CHESV_AA ', -INFO )
  231. RETURN
  232. ELSE IF( LQUERY ) THEN
  233. RETURN
  234. END IF
  235. *
  236. * Compute the factorization A = U*T*U**H or A = L*T*L**H.
  237. *
  238. CALL CHETRF_AA( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
  239. IF( INFO.EQ.0 ) THEN
  240. *
  241. * Solve the system A*X = B, overwriting B with X.
  242. *
  243. CALL CHETRS_AA( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
  244. $ LWORK, INFO )
  245. *
  246. END IF
  247. *
  248. WORK( 1 ) = LWKOPT
  249. *
  250. RETURN
  251. *
  252. * End of CHESV_AA
  253. *
  254. END