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.

cptts2.f 6.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. *> \brief \b CPTTS2 solves a tridiagonal system of the form AX=B using the L D LH factorization computed by spttrf.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CPTTS2 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cptts2.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cptts2.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cptts2.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CPTTS2( IUPLO, N, NRHS, D, E, B, LDB )
  22. *
  23. * .. Scalar Arguments ..
  24. * INTEGER IUPLO, LDB, N, NRHS
  25. * ..
  26. * .. Array Arguments ..
  27. * REAL D( * )
  28. * COMPLEX B( LDB, * ), E( * )
  29. * ..
  30. *
  31. *
  32. *> \par Purpose:
  33. * =============
  34. *>
  35. *> \verbatim
  36. *>
  37. *> CPTTS2 solves a tridiagonal system of the form
  38. *> A * X = B
  39. *> using the factorization A = U**H*D*U or A = L*D*L**H computed by CPTTRF.
  40. *> D is a diagonal matrix specified in the vector D, U (or L) is a unit
  41. *> bidiagonal matrix whose superdiagonal (subdiagonal) is specified in
  42. *> the vector E, and X and B are N by NRHS matrices.
  43. *> \endverbatim
  44. *
  45. * Arguments:
  46. * ==========
  47. *
  48. *> \param[in] IUPLO
  49. *> \verbatim
  50. *> IUPLO is INTEGER
  51. *> Specifies the form of the factorization and whether the
  52. *> vector E is the superdiagonal of the upper bidiagonal factor
  53. *> U or the subdiagonal of the lower bidiagonal factor L.
  54. *> = 1: A = U**H *D*U, E is the superdiagonal of U
  55. *> = 0: A = L*D*L**H, E is the subdiagonal of L
  56. *> \endverbatim
  57. *>
  58. *> \param[in] N
  59. *> \verbatim
  60. *> N is INTEGER
  61. *> The order of the tridiagonal matrix A. N >= 0.
  62. *> \endverbatim
  63. *>
  64. *> \param[in] NRHS
  65. *> \verbatim
  66. *> NRHS is INTEGER
  67. *> The number of right hand sides, i.e., the number of columns
  68. *> of the matrix B. NRHS >= 0.
  69. *> \endverbatim
  70. *>
  71. *> \param[in] D
  72. *> \verbatim
  73. *> D is REAL array, dimension (N)
  74. *> The n diagonal elements of the diagonal matrix D from the
  75. *> factorization A = U**H *D*U or A = L*D*L**H.
  76. *> \endverbatim
  77. *>
  78. *> \param[in] E
  79. *> \verbatim
  80. *> E is COMPLEX array, dimension (N-1)
  81. *> If IUPLO = 1, the (n-1) superdiagonal elements of the unit
  82. *> bidiagonal factor U from the factorization A = U**H*D*U.
  83. *> If IUPLO = 0, the (n-1) subdiagonal elements of the unit
  84. *> bidiagonal factor L from the factorization A = L*D*L**H.
  85. *> \endverbatim
  86. *>
  87. *> \param[in,out] B
  88. *> \verbatim
  89. *> B is COMPLEX array, dimension (LDB,NRHS)
  90. *> On entry, the right hand side vectors B for the system of
  91. *> linear equations.
  92. *> On exit, the solution vectors, X.
  93. *> \endverbatim
  94. *>
  95. *> \param[in] LDB
  96. *> \verbatim
  97. *> LDB is INTEGER
  98. *> The leading dimension of the array B. LDB >= max(1,N).
  99. *> \endverbatim
  100. *
  101. * Authors:
  102. * ========
  103. *
  104. *> \author Univ. of Tennessee
  105. *> \author Univ. of California Berkeley
  106. *> \author Univ. of Colorado Denver
  107. *> \author NAG Ltd.
  108. *
  109. *> \date June 2016
  110. *
  111. *> \ingroup complexPTcomputational
  112. *
  113. * =====================================================================
  114. SUBROUTINE CPTTS2( IUPLO, N, NRHS, D, E, B, LDB )
  115. *
  116. * -- LAPACK computational routine (version 3.7.0) --
  117. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  118. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  119. * June 2016
  120. *
  121. * .. Scalar Arguments ..
  122. INTEGER IUPLO, LDB, N, NRHS
  123. * ..
  124. * .. Array Arguments ..
  125. REAL D( * )
  126. COMPLEX B( LDB, * ), E( * )
  127. * ..
  128. *
  129. * =====================================================================
  130. *
  131. * .. Local Scalars ..
  132. INTEGER I, J
  133. * ..
  134. * .. External Subroutines ..
  135. EXTERNAL CSSCAL
  136. * ..
  137. * .. Intrinsic Functions ..
  138. INTRINSIC CONJG
  139. * ..
  140. * .. Executable Statements ..
  141. *
  142. * Quick return if possible
  143. *
  144. IF( N.LE.1 ) THEN
  145. IF( N.EQ.1 )
  146. $ CALL CSSCAL( NRHS, 1. / D( 1 ), B, LDB )
  147. RETURN
  148. END IF
  149. *
  150. IF( IUPLO.EQ.1 ) THEN
  151. *
  152. * Solve A * X = B using the factorization A = U**H *D*U,
  153. * overwriting each right hand side vector with its solution.
  154. *
  155. IF( NRHS.LE.2 ) THEN
  156. J = 1
  157. 5 CONTINUE
  158. *
  159. * Solve U**H * x = b.
  160. *
  161. DO 10 I = 2, N
  162. B( I, J ) = B( I, J ) - B( I-1, J )*CONJG( E( I-1 ) )
  163. 10 CONTINUE
  164. *
  165. * Solve D * U * x = b.
  166. *
  167. DO 20 I = 1, N
  168. B( I, J ) = B( I, J ) / D( I )
  169. 20 CONTINUE
  170. DO 30 I = N - 1, 1, -1
  171. B( I, J ) = B( I, J ) - B( I+1, J )*E( I )
  172. 30 CONTINUE
  173. IF( J.LT.NRHS ) THEN
  174. J = J + 1
  175. GO TO 5
  176. END IF
  177. ELSE
  178. DO 60 J = 1, NRHS
  179. *
  180. * Solve U**H * x = b.
  181. *
  182. DO 40 I = 2, N
  183. B( I, J ) = B( I, J ) - B( I-1, J )*CONJG( E( I-1 ) )
  184. 40 CONTINUE
  185. *
  186. * Solve D * U * x = b.
  187. *
  188. B( N, J ) = B( N, J ) / D( N )
  189. DO 50 I = N - 1, 1, -1
  190. B( I, J ) = B( I, J ) / D( I ) - B( I+1, J )*E( I )
  191. 50 CONTINUE
  192. 60 CONTINUE
  193. END IF
  194. ELSE
  195. *
  196. * Solve A * X = B using the factorization A = L*D*L**H,
  197. * overwriting each right hand side vector with its solution.
  198. *
  199. IF( NRHS.LE.2 ) THEN
  200. J = 1
  201. 65 CONTINUE
  202. *
  203. * Solve L * x = b.
  204. *
  205. DO 70 I = 2, N
  206. B( I, J ) = B( I, J ) - B( I-1, J )*E( I-1 )
  207. 70 CONTINUE
  208. *
  209. * Solve D * L**H * x = b.
  210. *
  211. DO 80 I = 1, N
  212. B( I, J ) = B( I, J ) / D( I )
  213. 80 CONTINUE
  214. DO 90 I = N - 1, 1, -1
  215. B( I, J ) = B( I, J ) - B( I+1, J )*CONJG( E( I ) )
  216. 90 CONTINUE
  217. IF( J.LT.NRHS ) THEN
  218. J = J + 1
  219. GO TO 65
  220. END IF
  221. ELSE
  222. DO 120 J = 1, NRHS
  223. *
  224. * Solve L * x = b.
  225. *
  226. DO 100 I = 2, N
  227. B( I, J ) = B( I, J ) - B( I-1, J )*E( I-1 )
  228. 100 CONTINUE
  229. *
  230. * Solve D * L**H * x = b.
  231. *
  232. B( N, J ) = B( N, J ) / D( N )
  233. DO 110 I = N - 1, 1, -1
  234. B( I, J ) = B( I, J ) / D( I ) -
  235. $ B( I+1, J )*CONJG( E( I ) )
  236. 110 CONTINUE
  237. 120 CONTINUE
  238. END IF
  239. END IF
  240. *
  241. RETURN
  242. *
  243. * End of CPTTS2
  244. *
  245. END