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.

cpbt01.f 7.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. *> \brief \b CPBT01
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * SUBROUTINE CPBT01( UPLO, N, KD, A, LDA, AFAC, LDAFAC, RWORK,
  12. * RESID )
  13. *
  14. * .. Scalar Arguments ..
  15. * CHARACTER UPLO
  16. * INTEGER KD, LDA, LDAFAC, N
  17. * REAL RESID
  18. * ..
  19. * .. Array Arguments ..
  20. * REAL RWORK( * )
  21. * COMPLEX A( LDA, * ), AFAC( LDAFAC, * )
  22. * ..
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> CPBT01 reconstructs a Hermitian positive definite band matrix A from
  31. *> its L*L' or U'*U factorization and computes the residual
  32. *> norm( L*L' - A ) / ( N * norm(A) * EPS ) or
  33. *> norm( U'*U - A ) / ( N * norm(A) * EPS ),
  34. *> where EPS is the machine epsilon, L' is the conjugate transpose of
  35. *> L, and U' is the conjugate transpose of U.
  36. *> \endverbatim
  37. *
  38. * Arguments:
  39. * ==========
  40. *
  41. *> \param[in] UPLO
  42. *> \verbatim
  43. *> UPLO is CHARACTER*1
  44. *> Specifies whether the upper or lower triangular part of the
  45. *> Hermitian matrix A is stored:
  46. *> = 'U': Upper triangular
  47. *> = 'L': Lower triangular
  48. *> \endverbatim
  49. *>
  50. *> \param[in] N
  51. *> \verbatim
  52. *> N is INTEGER
  53. *> The number of rows and columns of the matrix A. N >= 0.
  54. *> \endverbatim
  55. *>
  56. *> \param[in] KD
  57. *> \verbatim
  58. *> KD is INTEGER
  59. *> The number of super-diagonals of the matrix A if UPLO = 'U',
  60. *> or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
  61. *> \endverbatim
  62. *>
  63. *> \param[in] A
  64. *> \verbatim
  65. *> A is COMPLEX array, dimension (LDA,N)
  66. *> The original Hermitian band matrix A. If UPLO = 'U', the
  67. *> upper triangular part of A is stored as a band matrix; if
  68. *> UPLO = 'L', the lower triangular part of A is stored. The
  69. *> columns of the appropriate triangle are stored in the columns
  70. *> of A and the diagonals of the triangle are stored in the rows
  71. *> of A. See CPBTRF for further details.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] LDA
  75. *> \verbatim
  76. *> LDA is INTEGER.
  77. *> The leading dimension of the array A. LDA >= max(1,KD+1).
  78. *> \endverbatim
  79. *>
  80. *> \param[in] AFAC
  81. *> \verbatim
  82. *> AFAC is COMPLEX array, dimension (LDAFAC,N)
  83. *> The factored form of the matrix A. AFAC contains the factor
  84. *> L or U from the L*L' or U'*U factorization in band storage
  85. *> format, as computed by CPBTRF.
  86. *> \endverbatim
  87. *>
  88. *> \param[in] LDAFAC
  89. *> \verbatim
  90. *> LDAFAC is INTEGER
  91. *> The leading dimension of the array AFAC.
  92. *> LDAFAC >= max(1,KD+1).
  93. *> \endverbatim
  94. *>
  95. *> \param[out] RWORK
  96. *> \verbatim
  97. *> RWORK is REAL array, dimension (N)
  98. *> \endverbatim
  99. *>
  100. *> \param[out] RESID
  101. *> \verbatim
  102. *> RESID is REAL
  103. *> If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS )
  104. *> If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS )
  105. *> \endverbatim
  106. *
  107. * Authors:
  108. * ========
  109. *
  110. *> \author Univ. of Tennessee
  111. *> \author Univ. of California Berkeley
  112. *> \author Univ. of Colorado Denver
  113. *> \author NAG Ltd.
  114. *
  115. *> \date December 2016
  116. *
  117. *> \ingroup complex_lin
  118. *
  119. * =====================================================================
  120. SUBROUTINE CPBT01( UPLO, N, KD, A, LDA, AFAC, LDAFAC, RWORK,
  121. $ RESID )
  122. *
  123. * -- LAPACK test routine (version 3.7.0) --
  124. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  125. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  126. * December 2016
  127. *
  128. * .. Scalar Arguments ..
  129. CHARACTER UPLO
  130. INTEGER KD, LDA, LDAFAC, N
  131. REAL RESID
  132. * ..
  133. * .. Array Arguments ..
  134. REAL RWORK( * )
  135. COMPLEX A( LDA, * ), AFAC( LDAFAC, * )
  136. * ..
  137. *
  138. * =====================================================================
  139. *
  140. *
  141. * .. Parameters ..
  142. REAL ZERO, ONE
  143. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  144. * ..
  145. * .. Local Scalars ..
  146. INTEGER I, J, K, KC, KLEN, ML, MU
  147. REAL AKK, ANORM, EPS
  148. * ..
  149. * .. External Functions ..
  150. LOGICAL LSAME
  151. REAL CLANHB, SLAMCH
  152. COMPLEX CDOTC
  153. EXTERNAL LSAME, CLANHB, SLAMCH, CDOTC
  154. * ..
  155. * .. External Subroutines ..
  156. EXTERNAL CHER, CSSCAL, CTRMV
  157. * ..
  158. * .. Intrinsic Functions ..
  159. INTRINSIC AIMAG, MAX, MIN, REAL
  160. * ..
  161. * .. Executable Statements ..
  162. *
  163. * Quick exit if N = 0.
  164. *
  165. IF( N.LE.0 ) THEN
  166. RESID = ZERO
  167. RETURN
  168. END IF
  169. *
  170. * Exit with RESID = 1/EPS if ANORM = 0.
  171. *
  172. EPS = SLAMCH( 'Epsilon' )
  173. ANORM = CLANHB( '1', UPLO, N, KD, A, LDA, RWORK )
  174. IF( ANORM.LE.ZERO ) THEN
  175. RESID = ONE / EPS
  176. RETURN
  177. END IF
  178. *
  179. * Check the imaginary parts of the diagonal elements and return with
  180. * an error code if any are nonzero.
  181. *
  182. IF( LSAME( UPLO, 'U' ) ) THEN
  183. DO 10 J = 1, N
  184. IF( AIMAG( AFAC( KD+1, J ) ).NE.ZERO ) THEN
  185. RESID = ONE / EPS
  186. RETURN
  187. END IF
  188. 10 CONTINUE
  189. ELSE
  190. DO 20 J = 1, N
  191. IF( AIMAG( AFAC( 1, J ) ).NE.ZERO ) THEN
  192. RESID = ONE / EPS
  193. RETURN
  194. END IF
  195. 20 CONTINUE
  196. END IF
  197. *
  198. * Compute the product U'*U, overwriting U.
  199. *
  200. IF( LSAME( UPLO, 'U' ) ) THEN
  201. DO 30 K = N, 1, -1
  202. KC = MAX( 1, KD+2-K )
  203. KLEN = KD + 1 - KC
  204. *
  205. * Compute the (K,K) element of the result.
  206. *
  207. AKK = CDOTC( KLEN+1, AFAC( KC, K ), 1, AFAC( KC, K ), 1 )
  208. AFAC( KD+1, K ) = AKK
  209. *
  210. * Compute the rest of column K.
  211. *
  212. IF( KLEN.GT.0 )
  213. $ CALL CTRMV( 'Upper', 'Conjugate', 'Non-unit', KLEN,
  214. $ AFAC( KD+1, K-KLEN ), LDAFAC-1,
  215. $ AFAC( KC, K ), 1 )
  216. *
  217. 30 CONTINUE
  218. *
  219. * UPLO = 'L': Compute the product L*L', overwriting L.
  220. *
  221. ELSE
  222. DO 40 K = N, 1, -1
  223. KLEN = MIN( KD, N-K )
  224. *
  225. * Add a multiple of column K of the factor L to each of
  226. * columns K+1 through N.
  227. *
  228. IF( KLEN.GT.0 )
  229. $ CALL CHER( 'Lower', KLEN, ONE, AFAC( 2, K ), 1,
  230. $ AFAC( 1, K+1 ), LDAFAC-1 )
  231. *
  232. * Scale column K by the diagonal element.
  233. *
  234. AKK = AFAC( 1, K )
  235. CALL CSSCAL( KLEN+1, AKK, AFAC( 1, K ), 1 )
  236. *
  237. 40 CONTINUE
  238. END IF
  239. *
  240. * Compute the difference L*L' - A or U'*U - A.
  241. *
  242. IF( LSAME( UPLO, 'U' ) ) THEN
  243. DO 60 J = 1, N
  244. MU = MAX( 1, KD+2-J )
  245. DO 50 I = MU, KD + 1
  246. AFAC( I, J ) = AFAC( I, J ) - A( I, J )
  247. 50 CONTINUE
  248. 60 CONTINUE
  249. ELSE
  250. DO 80 J = 1, N
  251. ML = MIN( KD+1, N-J+1 )
  252. DO 70 I = 1, ML
  253. AFAC( I, J ) = AFAC( I, J ) - A( I, J )
  254. 70 CONTINUE
  255. 80 CONTINUE
  256. END IF
  257. *
  258. * Compute norm( L*L' - A ) / ( N * norm(A) * EPS )
  259. *
  260. RESID = CLANHB( '1', UPLO, N, KD, AFAC, LDAFAC, RWORK )
  261. *
  262. RESID = ( ( RESID / REAL( N ) ) / ANORM ) / EPS
  263. *
  264. RETURN
  265. *
  266. * End of CPBT01
  267. *
  268. END