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.

stpt01.f 5.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. *> \brief \b STPT01
  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 STPT01( UPLO, DIAG, N, AP, AINVP, RCOND, WORK, RESID )
  12. *
  13. * .. Scalar Arguments ..
  14. * CHARACTER DIAG, UPLO
  15. * INTEGER N
  16. * REAL RCOND, RESID
  17. * ..
  18. * .. Array Arguments ..
  19. * REAL AINVP( * ), AP( * ), WORK( * )
  20. * ..
  21. *
  22. *
  23. *> \par Purpose:
  24. * =============
  25. *>
  26. *> \verbatim
  27. *>
  28. *> STPT01 computes the residual for a triangular matrix A times its
  29. *> inverse when A is stored in packed format:
  30. *> RESID = norm(A*AINV - I) / ( N * norm(A) * norm(AINV) * EPS ),
  31. *> where EPS is the machine epsilon.
  32. *> \endverbatim
  33. *
  34. * Arguments:
  35. * ==========
  36. *
  37. *> \param[in] UPLO
  38. *> \verbatim
  39. *> UPLO is CHARACTER*1
  40. *> Specifies whether the matrix A is upper or lower triangular.
  41. *> = 'U': Upper triangular
  42. *> = 'L': Lower triangular
  43. *> \endverbatim
  44. *>
  45. *> \param[in] DIAG
  46. *> \verbatim
  47. *> DIAG is CHARACTER*1
  48. *> Specifies whether or not the matrix A is unit triangular.
  49. *> = 'N': Non-unit triangular
  50. *> = 'U': Unit triangular
  51. *> \endverbatim
  52. *>
  53. *> \param[in] N
  54. *> \verbatim
  55. *> N is INTEGER
  56. *> The order of the matrix A. N >= 0.
  57. *> \endverbatim
  58. *>
  59. *> \param[in] AP
  60. *> \verbatim
  61. *> AP is REAL array, dimension (N*(N+1)/2)
  62. *> The original upper or lower triangular matrix A, packed
  63. *> columnwise in a linear array. The j-th column of A is stored
  64. *> in the array AP as follows:
  65. *> if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j;
  66. *> if UPLO = 'L',
  67. *> AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n.
  68. *> \endverbatim
  69. *>
  70. *> \param[in,out] AINVP
  71. *> \verbatim
  72. *> AINVP is REAL array, dimension (N*(N+1)/2)
  73. *> On entry, the (triangular) inverse of the matrix A, packed
  74. *> columnwise in a linear array as in AP.
  75. *> On exit, the contents of AINVP are destroyed.
  76. *> \endverbatim
  77. *>
  78. *> \param[out] RCOND
  79. *> \verbatim
  80. *> RCOND is REAL
  81. *> The reciprocal condition number of A, computed as
  82. *> 1/(norm(A) * norm(AINV)).
  83. *> \endverbatim
  84. *>
  85. *> \param[out] WORK
  86. *> \verbatim
  87. *> WORK is REAL array, dimension (N)
  88. *> \endverbatim
  89. *>
  90. *> \param[out] RESID
  91. *> \verbatim
  92. *> RESID is REAL
  93. *> norm(A*AINV - I) / ( N * norm(A) * norm(AINV) * EPS )
  94. *> \endverbatim
  95. *
  96. * Authors:
  97. * ========
  98. *
  99. *> \author Univ. of Tennessee
  100. *> \author Univ. of California Berkeley
  101. *> \author Univ. of Colorado Denver
  102. *> \author NAG Ltd.
  103. *
  104. *> \date December 2016
  105. *
  106. *> \ingroup single_lin
  107. *
  108. * =====================================================================
  109. SUBROUTINE STPT01( UPLO, DIAG, N, AP, AINVP, RCOND, WORK, RESID )
  110. *
  111. * -- LAPACK test routine (version 3.7.0) --
  112. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  113. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  114. * December 2016
  115. *
  116. * .. Scalar Arguments ..
  117. CHARACTER DIAG, UPLO
  118. INTEGER N
  119. REAL RCOND, RESID
  120. * ..
  121. * .. Array Arguments ..
  122. REAL AINVP( * ), AP( * ), WORK( * )
  123. * ..
  124. *
  125. * =====================================================================
  126. *
  127. * .. Parameters ..
  128. REAL ZERO, ONE
  129. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  130. * ..
  131. * .. Local Scalars ..
  132. LOGICAL UNITD
  133. INTEGER J, JC
  134. REAL AINVNM, ANORM, EPS
  135. * ..
  136. * .. External Functions ..
  137. LOGICAL LSAME
  138. REAL SLAMCH, SLANTP
  139. EXTERNAL LSAME, SLAMCH, SLANTP
  140. * ..
  141. * .. External Subroutines ..
  142. EXTERNAL STPMV
  143. * ..
  144. * .. Intrinsic Functions ..
  145. INTRINSIC REAL
  146. * ..
  147. * .. Executable Statements ..
  148. *
  149. * Quick exit if N = 0.
  150. *
  151. IF( N.LE.0 ) THEN
  152. RCOND = ONE
  153. RESID = ZERO
  154. RETURN
  155. END IF
  156. *
  157. * Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0.
  158. *
  159. EPS = SLAMCH( 'Epsilon' )
  160. ANORM = SLANTP( '1', UPLO, DIAG, N, AP, WORK )
  161. AINVNM = SLANTP( '1', UPLO, DIAG, N, AINVP, WORK )
  162. IF( ANORM.LE.ZERO .OR. AINVNM.LE.ZERO ) THEN
  163. RCOND = ZERO
  164. RESID = ONE / EPS
  165. RETURN
  166. END IF
  167. RCOND = ( ONE / ANORM ) / AINVNM
  168. *
  169. * Compute A * AINV, overwriting AINV.
  170. *
  171. UNITD = LSAME( DIAG, 'U' )
  172. IF( LSAME( UPLO, 'U' ) ) THEN
  173. JC = 1
  174. DO 10 J = 1, N
  175. IF( UNITD )
  176. $ AINVP( JC+J-1 ) = ONE
  177. *
  178. * Form the j-th column of A*AINV
  179. *
  180. CALL STPMV( 'Upper', 'No transpose', DIAG, J, AP,
  181. $ AINVP( JC ), 1 )
  182. *
  183. * Subtract 1 from the diagonal
  184. *
  185. AINVP( JC+J-1 ) = AINVP( JC+J-1 ) - ONE
  186. JC = JC + J
  187. 10 CONTINUE
  188. ELSE
  189. JC = 1
  190. DO 20 J = 1, N
  191. IF( UNITD )
  192. $ AINVP( JC ) = ONE
  193. *
  194. * Form the j-th column of A*AINV
  195. *
  196. CALL STPMV( 'Lower', 'No transpose', DIAG, N-J+1, AP( JC ),
  197. $ AINVP( JC ), 1 )
  198. *
  199. * Subtract 1 from the diagonal
  200. *
  201. AINVP( JC ) = AINVP( JC ) - ONE
  202. JC = JC + N - J + 1
  203. 20 CONTINUE
  204. END IF
  205. *
  206. * Compute norm(A*AINV - I) / (N * norm(A) * norm(AINV) * EPS)
  207. *
  208. RESID = SLANTP( '1', UPLO, 'Non-unit', N, AINVP, WORK )
  209. *
  210. RESID = ( ( RESID*RCOND ) / REAL( N ) ) / EPS
  211. *
  212. RETURN
  213. *
  214. * End of STPT01
  215. *
  216. END