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.

dgbtrs.f 7.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. *> \brief \b DGBTRS
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download DGBTRS + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgbtrs.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgbtrs.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgbtrs.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE DGBTRS( TRANS, N, KL, KU, NRHS, AB, LDAB, IPIV, B, LDB,
  22. * INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER TRANS
  26. * INTEGER INFO, KL, KU, LDAB, LDB, N, NRHS
  27. * ..
  28. * .. Array Arguments ..
  29. * INTEGER IPIV( * )
  30. * DOUBLE PRECISION AB( LDAB, * ), B( LDB, * )
  31. * ..
  32. *
  33. *
  34. *> \par Purpose:
  35. * =============
  36. *>
  37. *> \verbatim
  38. *>
  39. *> DGBTRS solves a system of linear equations
  40. *> A * X = B or A**T * X = B
  41. *> with a general band matrix A using the LU factorization computed
  42. *> by DGBTRF.
  43. *> \endverbatim
  44. *
  45. * Arguments:
  46. * ==========
  47. *
  48. *> \param[in] TRANS
  49. *> \verbatim
  50. *> TRANS is CHARACTER*1
  51. *> Specifies the form of the system of equations.
  52. *> = 'N': A * X = B (No transpose)
  53. *> = 'T': A**T* X = B (Transpose)
  54. *> = 'C': A**T* X = B (Conjugate transpose = Transpose)
  55. *> \endverbatim
  56. *>
  57. *> \param[in] N
  58. *> \verbatim
  59. *> N is INTEGER
  60. *> The order of the matrix A. N >= 0.
  61. *> \endverbatim
  62. *>
  63. *> \param[in] KL
  64. *> \verbatim
  65. *> KL is INTEGER
  66. *> The number of subdiagonals within the band of A. KL >= 0.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] KU
  70. *> \verbatim
  71. *> KU is INTEGER
  72. *> The number of superdiagonals within the band of A. KU >= 0.
  73. *> \endverbatim
  74. *>
  75. *> \param[in] NRHS
  76. *> \verbatim
  77. *> NRHS is INTEGER
  78. *> The number of right hand sides, i.e., the number of columns
  79. *> of the matrix B. NRHS >= 0.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] AB
  83. *> \verbatim
  84. *> AB is DOUBLE PRECISION array, dimension (LDAB,N)
  85. *> Details of the LU factorization of the band matrix A, as
  86. *> computed by DGBTRF. U is stored as an upper triangular band
  87. *> matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and
  88. *> the multipliers used during the factorization are stored in
  89. *> rows KL+KU+2 to 2*KL+KU+1.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] LDAB
  93. *> \verbatim
  94. *> LDAB is INTEGER
  95. *> The leading dimension of the array AB. LDAB >= 2*KL+KU+1.
  96. *> \endverbatim
  97. *>
  98. *> \param[in] IPIV
  99. *> \verbatim
  100. *> IPIV is INTEGER array, dimension (N)
  101. *> The pivot indices; for 1 <= i <= N, row i of the matrix was
  102. *> interchanged with row IPIV(i).
  103. *> \endverbatim
  104. *>
  105. *> \param[in,out] B
  106. *> \verbatim
  107. *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
  108. *> On entry, the right hand side matrix B.
  109. *> On exit, the solution matrix X.
  110. *> \endverbatim
  111. *>
  112. *> \param[in] LDB
  113. *> \verbatim
  114. *> LDB is INTEGER
  115. *> The leading dimension of the array B. LDB >= max(1,N).
  116. *> \endverbatim
  117. *>
  118. *> \param[out] INFO
  119. *> \verbatim
  120. *> INFO is INTEGER
  121. *> = 0: successful exit
  122. *> < 0: if INFO = -i, the i-th argument had an illegal value
  123. *> \endverbatim
  124. *
  125. * Authors:
  126. * ========
  127. *
  128. *> \author Univ. of Tennessee
  129. *> \author Univ. of California Berkeley
  130. *> \author Univ. of Colorado Denver
  131. *> \author NAG Ltd.
  132. *
  133. *> \ingroup doubleGBcomputational
  134. *
  135. * =====================================================================
  136. SUBROUTINE DGBTRS( TRANS, N, KL, KU, NRHS, AB, LDAB, IPIV, B, LDB,
  137. $ INFO )
  138. *
  139. * -- LAPACK computational routine --
  140. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  141. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  142. *
  143. * .. Scalar Arguments ..
  144. CHARACTER TRANS
  145. INTEGER INFO, KL, KU, LDAB, LDB, N, NRHS
  146. * ..
  147. * .. Array Arguments ..
  148. INTEGER IPIV( * )
  149. DOUBLE PRECISION AB( LDAB, * ), B( LDB, * )
  150. * ..
  151. *
  152. * =====================================================================
  153. *
  154. * .. Parameters ..
  155. DOUBLE PRECISION ONE
  156. PARAMETER ( ONE = 1.0D+0 )
  157. * ..
  158. * .. Local Scalars ..
  159. LOGICAL LNOTI, NOTRAN
  160. INTEGER I, J, KD, L, LM
  161. * ..
  162. * .. External Functions ..
  163. LOGICAL LSAME
  164. EXTERNAL LSAME
  165. * ..
  166. * .. External Subroutines ..
  167. EXTERNAL DGEMV, DGER, DSWAP, DTBSV, XERBLA
  168. * ..
  169. * .. Intrinsic Functions ..
  170. INTRINSIC MAX, MIN
  171. * ..
  172. * .. Executable Statements ..
  173. *
  174. * Test the input parameters.
  175. *
  176. INFO = 0
  177. NOTRAN = LSAME( TRANS, 'N' )
  178. IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
  179. $ LSAME( TRANS, 'C' ) ) THEN
  180. INFO = -1
  181. ELSE IF( N.LT.0 ) THEN
  182. INFO = -2
  183. ELSE IF( KL.LT.0 ) THEN
  184. INFO = -3
  185. ELSE IF( KU.LT.0 ) THEN
  186. INFO = -4
  187. ELSE IF( NRHS.LT.0 ) THEN
  188. INFO = -5
  189. ELSE IF( LDAB.LT.( 2*KL+KU+1 ) ) THEN
  190. INFO = -7
  191. ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
  192. INFO = -10
  193. END IF
  194. IF( INFO.NE.0 ) THEN
  195. CALL XERBLA( 'DGBTRS', -INFO )
  196. RETURN
  197. END IF
  198. *
  199. * Quick return if possible
  200. *
  201. IF( N.EQ.0 .OR. NRHS.EQ.0 )
  202. $ RETURN
  203. *
  204. KD = KU + KL + 1
  205. LNOTI = KL.GT.0
  206. *
  207. IF( NOTRAN ) THEN
  208. *
  209. * Solve A*X = B.
  210. *
  211. * Solve L*X = B, overwriting B with X.
  212. *
  213. * L is represented as a product of permutations and unit lower
  214. * triangular matrices L = P(1) * L(1) * ... * P(n-1) * L(n-1),
  215. * where each transformation L(i) is a rank-one modification of
  216. * the identity matrix.
  217. *
  218. IF( LNOTI ) THEN
  219. DO 10 J = 1, N - 1
  220. LM = MIN( KL, N-J )
  221. L = IPIV( J )
  222. IF( L.NE.J )
  223. $ CALL DSWAP( NRHS, B( L, 1 ), LDB, B( J, 1 ), LDB )
  224. CALL DGER( LM, NRHS, -ONE, AB( KD+1, J ), 1, B( J, 1 ),
  225. $ LDB, B( J+1, 1 ), LDB )
  226. 10 CONTINUE
  227. END IF
  228. *
  229. DO 20 I = 1, NRHS
  230. *
  231. * Solve U*X = B, overwriting B with X.
  232. *
  233. CALL DTBSV( 'Upper', 'No transpose', 'Non-unit', N, KL+KU,
  234. $ AB, LDAB, B( 1, I ), 1 )
  235. 20 CONTINUE
  236. *
  237. ELSE
  238. *
  239. * Solve A**T*X = B.
  240. *
  241. DO 30 I = 1, NRHS
  242. *
  243. * Solve U**T*X = B, overwriting B with X.
  244. *
  245. CALL DTBSV( 'Upper', 'Transpose', 'Non-unit', N, KL+KU, AB,
  246. $ LDAB, B( 1, I ), 1 )
  247. 30 CONTINUE
  248. *
  249. * Solve L**T*X = B, overwriting B with X.
  250. *
  251. IF( LNOTI ) THEN
  252. DO 40 J = N - 1, 1, -1
  253. LM = MIN( KL, N-J )
  254. CALL DGEMV( 'Transpose', LM, NRHS, -ONE, B( J+1, 1 ),
  255. $ LDB, AB( KD+1, J ), 1, ONE, B( J, 1 ), LDB )
  256. L = IPIV( J )
  257. IF( L.NE.J )
  258. $ CALL DSWAP( NRHS, B( L, 1 ), LDB, B( J, 1 ), LDB )
  259. 40 CONTINUE
  260. END IF
  261. END IF
  262. RETURN
  263. *
  264. * End of DGBTRS
  265. *
  266. END