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.

chpsv.f 6.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. *> \brief <b> CHPSV computes the solution to system of linear equations A * X = B for OTHER 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 CHPSV + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chpsv.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chpsv.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chpsv.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CHPSV( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO )
  22. *
  23. * .. Scalar Arguments ..
  24. * CHARACTER UPLO
  25. * INTEGER INFO, LDB, N, NRHS
  26. * ..
  27. * .. Array Arguments ..
  28. * INTEGER IPIV( * )
  29. * COMPLEX AP( * ), B( LDB, * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> CHPSV computes the solution to a complex system of linear equations
  39. *> A * X = B,
  40. *> where A is an N-by-N Hermitian matrix stored in packed format and X
  41. *> and B are N-by-NRHS matrices.
  42. *>
  43. *> The diagonal pivoting method is used to factor A as
  44. *> A = U * D * U**H, if UPLO = 'U', or
  45. *> A = L * D * L**H, if UPLO = 'L',
  46. *> where U (or L) is a product of permutation and unit upper (lower)
  47. *> triangular matrices, D is Hermitian and block diagonal with 1-by-1
  48. *> and 2-by-2 diagonal blocks. The factored form of A is then used to
  49. *> 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] AP
  77. *> \verbatim
  78. *> AP is COMPLEX array, dimension (N*(N+1)/2)
  79. *> On entry, the upper or lower triangle of the Hermitian matrix
  80. *> A, packed columnwise in a linear array. The j-th column of A
  81. *> is stored in the array AP as follows:
  82. *> if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  83. *> if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  84. *> See below for further details.
  85. *>
  86. *> On exit, the block diagonal matrix D and the multipliers used
  87. *> to obtain the factor U or L from the factorization
  88. *> A = U*D*U**H or A = L*D*L**H as computed by CHPTRF, stored as
  89. *> a packed triangular matrix in the same storage format as A.
  90. *> \endverbatim
  91. *>
  92. *> \param[out] IPIV
  93. *> \verbatim
  94. *> IPIV is INTEGER array, dimension (N)
  95. *> Details of the interchanges and the block structure of D, as
  96. *> determined by CHPTRF. If IPIV(k) > 0, then rows and columns
  97. *> k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
  98. *> diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
  99. *> then rows and columns k-1 and -IPIV(k) were interchanged and
  100. *> D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and
  101. *> IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
  102. *> -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
  103. *> diagonal block.
  104. *> \endverbatim
  105. *>
  106. *> \param[in,out] B
  107. *> \verbatim
  108. *> B is COMPLEX array, dimension (LDB,NRHS)
  109. *> On entry, the N-by-NRHS right hand side matrix B.
  110. *> On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  111. *> \endverbatim
  112. *>
  113. *> \param[in] LDB
  114. *> \verbatim
  115. *> LDB is INTEGER
  116. *> The leading dimension of the array B. LDB >= max(1,N).
  117. *> \endverbatim
  118. *>
  119. *> \param[out] INFO
  120. *> \verbatim
  121. *> INFO is INTEGER
  122. *> = 0: successful exit
  123. *> < 0: if INFO = -i, the i-th argument had an illegal value
  124. *> > 0: if INFO = i, D(i,i) is exactly zero. The factorization
  125. *> has been completed, but the block diagonal matrix D is
  126. *> exactly singular, so the solution could not be
  127. *> computed.
  128. *> \endverbatim
  129. *
  130. * Authors:
  131. * ========
  132. *
  133. *> \author Univ. of Tennessee
  134. *> \author Univ. of California Berkeley
  135. *> \author Univ. of Colorado Denver
  136. *> \author NAG Ltd.
  137. *
  138. *> \ingroup complexOTHERsolve
  139. *
  140. *> \par Further Details:
  141. * =====================
  142. *>
  143. *> \verbatim
  144. *>
  145. *> The packed storage scheme is illustrated by the following example
  146. *> when N = 4, UPLO = 'U':
  147. *>
  148. *> Two-dimensional storage of the Hermitian matrix A:
  149. *>
  150. *> a11 a12 a13 a14
  151. *> a22 a23 a24
  152. *> a33 a34 (aij = conjg(aji))
  153. *> a44
  154. *>
  155. *> Packed storage of the upper triangle of A:
  156. *>
  157. *> AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
  158. *> \endverbatim
  159. *>
  160. * =====================================================================
  161. SUBROUTINE CHPSV( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO )
  162. *
  163. * -- LAPACK driver routine --
  164. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  165. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  166. *
  167. * .. Scalar Arguments ..
  168. CHARACTER UPLO
  169. INTEGER INFO, LDB, N, NRHS
  170. * ..
  171. * .. Array Arguments ..
  172. INTEGER IPIV( * )
  173. COMPLEX AP( * ), B( LDB, * )
  174. * ..
  175. *
  176. * =====================================================================
  177. *
  178. * .. External Functions ..
  179. LOGICAL LSAME
  180. EXTERNAL LSAME
  181. * ..
  182. * .. External Subroutines ..
  183. EXTERNAL CHPTRF, CHPTRS, XERBLA
  184. * ..
  185. * .. Intrinsic Functions ..
  186. INTRINSIC MAX
  187. * ..
  188. * .. Executable Statements ..
  189. *
  190. * Test the input parameters.
  191. *
  192. INFO = 0
  193. IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  194. INFO = -1
  195. ELSE IF( N.LT.0 ) THEN
  196. INFO = -2
  197. ELSE IF( NRHS.LT.0 ) THEN
  198. INFO = -3
  199. ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
  200. INFO = -7
  201. END IF
  202. IF( INFO.NE.0 ) THEN
  203. CALL XERBLA( 'CHPSV ', -INFO )
  204. RETURN
  205. END IF
  206. *
  207. * Compute the factorization A = U*D*U**H or A = L*D*L**H.
  208. *
  209. CALL CHPTRF( UPLO, N, AP, IPIV, INFO )
  210. IF( INFO.EQ.0 ) THEN
  211. *
  212. * Solve the system A*X = B, overwriting B with X.
  213. *
  214. CALL CHPTRS( UPLO, N, NRHS, AP, IPIV, B, LDB, INFO )
  215. *
  216. END IF
  217. RETURN
  218. *
  219. * End of CHPSV
  220. *
  221. END