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.

sget53.f 7.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. *> \brief \b SGET53
  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 SGET53( A, LDA, B, LDB, SCALE, WR, WI, RESULT, INFO )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER INFO, LDA, LDB
  15. * REAL RESULT, SCALE, WI, WR
  16. * ..
  17. * .. Array Arguments ..
  18. * REAL A( LDA, * ), B( LDB, * )
  19. * ..
  20. *
  21. *
  22. *> \par Purpose:
  23. * =============
  24. *>
  25. *> \verbatim
  26. *>
  27. *> SGET53 checks the generalized eigenvalues computed by SLAG2.
  28. *>
  29. *> The basic test for an eigenvalue is:
  30. *>
  31. *> | det( s A - w B ) |
  32. *> RESULT = ---------------------------------------------------
  33. *> ulp max( s norm(A), |w| norm(B) )*norm( s A - w B )
  34. *>
  35. *> Two "safety checks" are performed:
  36. *>
  37. *> (1) ulp*max( s*norm(A), |w|*norm(B) ) must be at least
  38. *> safe_minimum. This insures that the test performed is
  39. *> not essentially det(0*A + 0*B)=0.
  40. *>
  41. *> (2) s*norm(A) + |w|*norm(B) must be less than 1/safe_minimum.
  42. *> This insures that s*A - w*B will not overflow.
  43. *>
  44. *> If these tests are not passed, then s and w are scaled and
  45. *> tested anyway, if this is possible.
  46. *> \endverbatim
  47. *
  48. * Arguments:
  49. * ==========
  50. *
  51. *> \param[in] A
  52. *> \verbatim
  53. *> A is REAL array, dimension (LDA, 2)
  54. *> The 2x2 matrix A.
  55. *> \endverbatim
  56. *>
  57. *> \param[in] LDA
  58. *> \verbatim
  59. *> LDA is INTEGER
  60. *> The leading dimension of A. It must be at least 2.
  61. *> \endverbatim
  62. *>
  63. *> \param[in] B
  64. *> \verbatim
  65. *> B is REAL array, dimension (LDB, N)
  66. *> The 2x2 upper-triangular matrix B.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] LDB
  70. *> \verbatim
  71. *> LDB is INTEGER
  72. *> The leading dimension of B. It must be at least 2.
  73. *> \endverbatim
  74. *>
  75. *> \param[in] SCALE
  76. *> \verbatim
  77. *> SCALE is REAL
  78. *> The "scale factor" s in the formula s A - w B . It is
  79. *> assumed to be non-negative.
  80. *> \endverbatim
  81. *>
  82. *> \param[in] WR
  83. *> \verbatim
  84. *> WR is REAL
  85. *> The real part of the eigenvalue w in the formula
  86. *> s A - w B .
  87. *> \endverbatim
  88. *>
  89. *> \param[in] WI
  90. *> \verbatim
  91. *> WI is REAL
  92. *> The imaginary part of the eigenvalue w in the formula
  93. *> s A - w B .
  94. *> \endverbatim
  95. *>
  96. *> \param[out] RESULT
  97. *> \verbatim
  98. *> RESULT is REAL
  99. *> If INFO is 2 or less, the value computed by the test
  100. *> described above.
  101. *> If INFO=3, this will just be 1/ulp.
  102. *> \endverbatim
  103. *>
  104. *> \param[out] INFO
  105. *> \verbatim
  106. *> INFO is INTEGER
  107. *> =0: The input data pass the "safety checks".
  108. *> =1: s*norm(A) + |w|*norm(B) > 1/safe_minimum.
  109. *> =2: ulp*max( s*norm(A), |w|*norm(B) ) < safe_minimum
  110. *> =3: same as INFO=2, but s and w could not be scaled so
  111. *> as to compute the test.
  112. *> \endverbatim
  113. *
  114. * Authors:
  115. * ========
  116. *
  117. *> \author Univ. of Tennessee
  118. *> \author Univ. of California Berkeley
  119. *> \author Univ. of Colorado Denver
  120. *> \author NAG Ltd.
  121. *
  122. *> \ingroup single_eig
  123. *
  124. * =====================================================================
  125. SUBROUTINE SGET53( A, LDA, B, LDB, SCALE, WR, WI, RESULT, INFO )
  126. *
  127. * -- LAPACK test routine --
  128. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  129. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  130. *
  131. * .. Scalar Arguments ..
  132. INTEGER INFO, LDA, LDB
  133. REAL RESULT, SCALE, WI, WR
  134. * ..
  135. * .. Array Arguments ..
  136. REAL A( LDA, * ), B( LDB, * )
  137. * ..
  138. *
  139. * =====================================================================
  140. *
  141. * .. Parameters ..
  142. REAL ZERO, ONE
  143. PARAMETER ( ZERO = 0.0, ONE = 1.0 )
  144. * ..
  145. * .. Local Scalars ..
  146. REAL ABSW, ANORM, BNORM, CI11, CI12, CI22, CNORM,
  147. $ CR11, CR12, CR21, CR22, CSCALE, DETI, DETR, S1,
  148. $ SAFMIN, SCALES, SIGMIN, TEMP, ULP, WIS, WRS
  149. * ..
  150. * .. External Functions ..
  151. REAL SLAMCH
  152. EXTERNAL SLAMCH
  153. * ..
  154. * .. Intrinsic Functions ..
  155. INTRINSIC ABS, MAX, SQRT
  156. * ..
  157. * .. Executable Statements ..
  158. *
  159. * Initialize
  160. *
  161. INFO = 0
  162. RESULT = ZERO
  163. SCALES = SCALE
  164. WRS = WR
  165. WIS = WI
  166. *
  167. * Machine constants and norms
  168. *
  169. SAFMIN = SLAMCH( 'Safe minimum' )
  170. ULP = SLAMCH( 'Epsilon' )*SLAMCH( 'Base' )
  171. ABSW = ABS( WRS ) + ABS( WIS )
  172. ANORM = MAX( ABS( A( 1, 1 ) )+ABS( A( 2, 1 ) ),
  173. $ ABS( A( 1, 2 ) )+ABS( A( 2, 2 ) ), SAFMIN )
  174. BNORM = MAX( ABS( B( 1, 1 ) ), ABS( B( 1, 2 ) )+ABS( B( 2, 2 ) ),
  175. $ SAFMIN )
  176. *
  177. * Check for possible overflow.
  178. *
  179. TEMP = ( SAFMIN*BNORM )*ABSW + ( SAFMIN*ANORM )*SCALES
  180. IF( TEMP.GE.ONE ) THEN
  181. *
  182. * Scale down to avoid overflow
  183. *
  184. INFO = 1
  185. TEMP = ONE / TEMP
  186. SCALES = SCALES*TEMP
  187. WRS = WRS*TEMP
  188. WIS = WIS*TEMP
  189. ABSW = ABS( WRS ) + ABS( WIS )
  190. END IF
  191. S1 = MAX( ULP*MAX( SCALES*ANORM, ABSW*BNORM ),
  192. $ SAFMIN*MAX( SCALES, ABSW ) )
  193. *
  194. * Check for W and SCALE essentially zero.
  195. *
  196. IF( S1.LT.SAFMIN ) THEN
  197. INFO = 2
  198. IF( SCALES.LT.SAFMIN .AND. ABSW.LT.SAFMIN ) THEN
  199. INFO = 3
  200. RESULT = ONE / ULP
  201. RETURN
  202. END IF
  203. *
  204. * Scale up to avoid underflow
  205. *
  206. TEMP = ONE / MAX( SCALES*ANORM+ABSW*BNORM, SAFMIN )
  207. SCALES = SCALES*TEMP
  208. WRS = WRS*TEMP
  209. WIS = WIS*TEMP
  210. ABSW = ABS( WRS ) + ABS( WIS )
  211. S1 = MAX( ULP*MAX( SCALES*ANORM, ABSW*BNORM ),
  212. $ SAFMIN*MAX( SCALES, ABSW ) )
  213. IF( S1.LT.SAFMIN ) THEN
  214. INFO = 3
  215. RESULT = ONE / ULP
  216. RETURN
  217. END IF
  218. END IF
  219. *
  220. * Compute C = s A - w B
  221. *
  222. CR11 = SCALES*A( 1, 1 ) - WRS*B( 1, 1 )
  223. CI11 = -WIS*B( 1, 1 )
  224. CR21 = SCALES*A( 2, 1 )
  225. CR12 = SCALES*A( 1, 2 ) - WRS*B( 1, 2 )
  226. CI12 = -WIS*B( 1, 2 )
  227. CR22 = SCALES*A( 2, 2 ) - WRS*B( 2, 2 )
  228. CI22 = -WIS*B( 2, 2 )
  229. *
  230. * Compute the smallest singular value of s A - w B:
  231. *
  232. * |det( s A - w B )|
  233. * sigma_min = ------------------
  234. * norm( s A - w B )
  235. *
  236. CNORM = MAX( ABS( CR11 )+ABS( CI11 )+ABS( CR21 ),
  237. $ ABS( CR12 )+ABS( CI12 )+ABS( CR22 )+ABS( CI22 ), SAFMIN )
  238. CSCALE = ONE / SQRT( CNORM )
  239. DETR = ( CSCALE*CR11 )*( CSCALE*CR22 ) -
  240. $ ( CSCALE*CI11 )*( CSCALE*CI22 ) -
  241. $ ( CSCALE*CR12 )*( CSCALE*CR21 )
  242. DETI = ( CSCALE*CR11 )*( CSCALE*CI22 ) +
  243. $ ( CSCALE*CI11 )*( CSCALE*CR22 ) -
  244. $ ( CSCALE*CI12 )*( CSCALE*CR21 )
  245. SIGMIN = ABS( DETR ) + ABS( DETI )
  246. RESULT = SIGMIN / S1
  247. RETURN
  248. *
  249. * End of SGET53
  250. *
  251. END