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.

stbt03.f 8.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. *> \brief \b STBT03
  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 STBT03( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB,
  12. * SCALE, CNORM, TSCAL, X, LDX, B, LDB, WORK,
  13. * RESID )
  14. *
  15. * .. Scalar Arguments ..
  16. * CHARACTER DIAG, TRANS, UPLO
  17. * INTEGER KD, LDAB, LDB, LDX, N, NRHS
  18. * REAL RESID, SCALE, TSCAL
  19. * ..
  20. * .. Array Arguments ..
  21. * REAL AB( LDAB, * ), B( LDB, * ), CNORM( * ),
  22. * $ WORK( * ), X( LDX, * )
  23. * ..
  24. *
  25. *
  26. *> \par Purpose:
  27. * =============
  28. *>
  29. *> \verbatim
  30. *>
  31. *> STBT03 computes the residual for the solution to a scaled triangular
  32. *> system of equations A*x = s*b or A'*x = s*b when A is a
  33. *> triangular band matrix. Here A' is the transpose of A, s is a scalar,
  34. *> and x and b are N by NRHS matrices. The test ratio is the maximum
  35. *> over the number of right hand sides of
  36. *> norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ),
  37. *> where op(A) denotes A or A' and EPS is the machine epsilon.
  38. *> \endverbatim
  39. *
  40. * Arguments:
  41. * ==========
  42. *
  43. *> \param[in] UPLO
  44. *> \verbatim
  45. *> UPLO is CHARACTER*1
  46. *> Specifies whether the matrix A is upper or lower triangular.
  47. *> = 'U': Upper triangular
  48. *> = 'L': Lower triangular
  49. *> \endverbatim
  50. *>
  51. *> \param[in] TRANS
  52. *> \verbatim
  53. *> TRANS is CHARACTER*1
  54. *> Specifies the operation applied to A.
  55. *> = 'N': A *x = b (No transpose)
  56. *> = 'T': A'*x = b (Transpose)
  57. *> = 'C': A'*x = b (Conjugate transpose = Transpose)
  58. *> \endverbatim
  59. *>
  60. *> \param[in] DIAG
  61. *> \verbatim
  62. *> DIAG is CHARACTER*1
  63. *> Specifies whether or not the matrix A is unit triangular.
  64. *> = 'N': Non-unit triangular
  65. *> = 'U': Unit triangular
  66. *> \endverbatim
  67. *>
  68. *> \param[in] N
  69. *> \verbatim
  70. *> N is INTEGER
  71. *> The order of the matrix A. N >= 0.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] KD
  75. *> \verbatim
  76. *> KD is INTEGER
  77. *> The number of superdiagonals or subdiagonals of the
  78. *> triangular band matrix A. KD >= 0.
  79. *> \endverbatim
  80. *>
  81. *> \param[in] NRHS
  82. *> \verbatim
  83. *> NRHS is INTEGER
  84. *> The number of right hand sides, i.e., the number of columns
  85. *> of the matrices X and B. NRHS >= 0.
  86. *> \endverbatim
  87. *>
  88. *> \param[in] AB
  89. *> \verbatim
  90. *> AB is REAL array, dimension (LDAB,N)
  91. *> The upper or lower triangular band matrix A, stored in the
  92. *> first kd+1 rows of the array. The j-th column of A is stored
  93. *> in the j-th column of the array AB as follows:
  94. *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  95. *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  96. *> \endverbatim
  97. *>
  98. *> \param[in] LDAB
  99. *> \verbatim
  100. *> LDAB is INTEGER
  101. *> The leading dimension of the array AB. LDAB >= KD+1.
  102. *> \endverbatim
  103. *>
  104. *> \param[in] SCALE
  105. *> \verbatim
  106. *> SCALE is REAL
  107. *> The scaling factor s used in solving the triangular system.
  108. *> \endverbatim
  109. *>
  110. *> \param[in] CNORM
  111. *> \verbatim
  112. *> CNORM is REAL array, dimension (N)
  113. *> The 1-norms of the columns of A, not counting the diagonal.
  114. *> \endverbatim
  115. *>
  116. *> \param[in] TSCAL
  117. *> \verbatim
  118. *> TSCAL is REAL
  119. *> The scaling factor used in computing the 1-norms in CNORM.
  120. *> CNORM actually contains the column norms of TSCAL*A.
  121. *> \endverbatim
  122. *>
  123. *> \param[in] X
  124. *> \verbatim
  125. *> X is REAL array, dimension (LDX,NRHS)
  126. *> The computed solution vectors for the system of linear
  127. *> equations.
  128. *> \endverbatim
  129. *>
  130. *> \param[in] LDX
  131. *> \verbatim
  132. *> LDX is INTEGER
  133. *> The leading dimension of the array X. LDX >= max(1,N).
  134. *> \endverbatim
  135. *>
  136. *> \param[in] B
  137. *> \verbatim
  138. *> B is REAL array, dimension (LDB,NRHS)
  139. *> The right hand side vectors for the system of linear
  140. *> equations.
  141. *> \endverbatim
  142. *>
  143. *> \param[in] LDB
  144. *> \verbatim
  145. *> LDB is INTEGER
  146. *> The leading dimension of the array B. LDB >= max(1,N).
  147. *> \endverbatim
  148. *>
  149. *> \param[out] WORK
  150. *> \verbatim
  151. *> WORK is REAL array, dimension (N)
  152. *> \endverbatim
  153. *>
  154. *> \param[out] RESID
  155. *> \verbatim
  156. *> RESID is REAL
  157. *> The maximum over the number of right hand sides of
  158. *> norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
  159. *> \endverbatim
  160. *
  161. * Authors:
  162. * ========
  163. *
  164. *> \author Univ. of Tennessee
  165. *> \author Univ. of California Berkeley
  166. *> \author Univ. of Colorado Denver
  167. *> \author NAG Ltd.
  168. *
  169. *> \date December 2016
  170. *
  171. *> \ingroup single_lin
  172. *
  173. * =====================================================================
  174. SUBROUTINE STBT03( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB,
  175. $ SCALE, CNORM, TSCAL, X, LDX, B, LDB, WORK,
  176. $ RESID )
  177. *
  178. * -- LAPACK test routine (version 3.7.0) --
  179. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  180. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  181. * December 2016
  182. *
  183. * .. Scalar Arguments ..
  184. CHARACTER DIAG, TRANS, UPLO
  185. INTEGER KD, LDAB, LDB, LDX, N, NRHS
  186. REAL RESID, SCALE, TSCAL
  187. * ..
  188. * .. Array Arguments ..
  189. REAL AB( LDAB, * ), B( LDB, * ), CNORM( * ),
  190. $ WORK( * ), X( LDX, * )
  191. * ..
  192. *
  193. * =====================================================================
  194. *
  195. * .. Parameters ..
  196. REAL ONE, ZERO
  197. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  198. * ..
  199. * .. Local Scalars ..
  200. INTEGER IX, J
  201. REAL BIGNUM, EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL
  202. * ..
  203. * .. External Functions ..
  204. LOGICAL LSAME
  205. INTEGER ISAMAX
  206. REAL SLAMCH
  207. EXTERNAL LSAME, ISAMAX, SLAMCH
  208. * ..
  209. * .. External Subroutines ..
  210. EXTERNAL SAXPY, SCOPY, SLABAD, SSCAL, STBMV
  211. * ..
  212. * .. Intrinsic Functions ..
  213. INTRINSIC ABS, MAX, REAL
  214. * ..
  215. * .. Executable Statements ..
  216. *
  217. * Quick exit if N = 0
  218. *
  219. IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
  220. RESID = ZERO
  221. RETURN
  222. END IF
  223. EPS = SLAMCH( 'Epsilon' )
  224. SMLNUM = SLAMCH( 'Safe minimum' )
  225. BIGNUM = ONE / SMLNUM
  226. CALL SLABAD( SMLNUM, BIGNUM )
  227. *
  228. * Compute the norm of the triangular matrix A using the column
  229. * norms already computed by SLATBS.
  230. *
  231. TNORM = ZERO
  232. IF( LSAME( DIAG, 'N' ) ) THEN
  233. IF( LSAME( UPLO, 'U' ) ) THEN
  234. DO 10 J = 1, N
  235. TNORM = MAX( TNORM, TSCAL*ABS( AB( KD+1, J ) )+
  236. $ CNORM( J ) )
  237. 10 CONTINUE
  238. ELSE
  239. DO 20 J = 1, N
  240. TNORM = MAX( TNORM, TSCAL*ABS( AB( 1, J ) )+CNORM( J ) )
  241. 20 CONTINUE
  242. END IF
  243. ELSE
  244. DO 30 J = 1, N
  245. TNORM = MAX( TNORM, TSCAL+CNORM( J ) )
  246. 30 CONTINUE
  247. END IF
  248. *
  249. * Compute the maximum over the number of right hand sides of
  250. * norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
  251. *
  252. RESID = ZERO
  253. DO 40 J = 1, NRHS
  254. CALL SCOPY( N, X( 1, J ), 1, WORK, 1 )
  255. IX = ISAMAX( N, WORK, 1 )
  256. XNORM = MAX( ONE, ABS( X( IX, J ) ) )
  257. XSCAL = ( ONE / XNORM ) / REAL( KD+1 )
  258. CALL SSCAL( N, XSCAL, WORK, 1 )
  259. CALL STBMV( UPLO, TRANS, DIAG, N, KD, AB, LDAB, WORK, 1 )
  260. CALL SAXPY( N, -SCALE*XSCAL, B( 1, J ), 1, WORK, 1 )
  261. IX = ISAMAX( N, WORK, 1 )
  262. ERR = TSCAL*ABS( WORK( IX ) )
  263. IX = ISAMAX( N, X( 1, J ), 1 )
  264. XNORM = ABS( X( IX, J ) )
  265. IF( ERR*SMLNUM.LE.XNORM ) THEN
  266. IF( XNORM.GT.ZERO )
  267. $ ERR = ERR / XNORM
  268. ELSE
  269. IF( ERR.GT.ZERO )
  270. $ ERR = ONE / EPS
  271. END IF
  272. IF( ERR*SMLNUM.LE.TNORM ) THEN
  273. IF( TNORM.GT.ZERO )
  274. $ ERR = ERR / TNORM
  275. ELSE
  276. IF( ERR.GT.ZERO )
  277. $ ERR = ONE / EPS
  278. END IF
  279. RESID = MAX( RESID, ERR )
  280. 40 CONTINUE
  281. *
  282. RETURN
  283. *
  284. * End of STBT03
  285. *
  286. END