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.

sget54.f 6.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. *> \brief \b SGET54
  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 SGET54( N, A, LDA, B, LDB, S, LDS, T, LDT, U, LDU, V,
  12. * LDV, WORK, RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * INTEGER LDA, LDB, LDS, LDT, LDU, LDV, N
  16. * REAL RESULT
  17. * ..
  18. * .. Array Arguments ..
  19. * REAL A( LDA, * ), B( LDB, * ), S( LDS, * ),
  20. * $ T( LDT, * ), U( LDU, * ), V( LDV, * ),
  21. * $ WORK( * )
  22. * ..
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> SGET54 checks a generalized decomposition of the form
  31. *>
  32. *> A = U*S*V' and B = U*T* V'
  33. *>
  34. *> where ' means transpose and U and V are orthogonal.
  35. *>
  36. *> Specifically,
  37. *>
  38. *> RESULT = ||( A - U*S*V', B - U*T*V' )|| / (||( A, B )||*n*ulp )
  39. *> \endverbatim
  40. *
  41. * Arguments:
  42. * ==========
  43. *
  44. *> \param[in] N
  45. *> \verbatim
  46. *> N is INTEGER
  47. *> The size of the matrix. If it is zero, SGET54 does nothing.
  48. *> It must be at least zero.
  49. *> \endverbatim
  50. *>
  51. *> \param[in] A
  52. *> \verbatim
  53. *> A is REAL array, dimension (LDA, N)
  54. *> The original (unfactored) 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 1
  61. *> and at least N.
  62. *> \endverbatim
  63. *>
  64. *> \param[in] B
  65. *> \verbatim
  66. *> B is REAL array, dimension (LDB, N)
  67. *> The original (unfactored) matrix B.
  68. *> \endverbatim
  69. *>
  70. *> \param[in] LDB
  71. *> \verbatim
  72. *> LDB is INTEGER
  73. *> The leading dimension of B. It must be at least 1
  74. *> and at least N.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] S
  78. *> \verbatim
  79. *> S is REAL array, dimension (LDS, N)
  80. *> The factored matrix S.
  81. *> \endverbatim
  82. *>
  83. *> \param[in] LDS
  84. *> \verbatim
  85. *> LDS is INTEGER
  86. *> The leading dimension of S. It must be at least 1
  87. *> and at least N.
  88. *> \endverbatim
  89. *>
  90. *> \param[in] T
  91. *> \verbatim
  92. *> T is REAL array, dimension (LDT, N)
  93. *> The factored matrix T.
  94. *> \endverbatim
  95. *>
  96. *> \param[in] LDT
  97. *> \verbatim
  98. *> LDT is INTEGER
  99. *> The leading dimension of T. It must be at least 1
  100. *> and at least N.
  101. *> \endverbatim
  102. *>
  103. *> \param[in] U
  104. *> \verbatim
  105. *> U is REAL array, dimension (LDU, N)
  106. *> The orthogonal matrix on the left-hand side in the
  107. *> decomposition.
  108. *> \endverbatim
  109. *>
  110. *> \param[in] LDU
  111. *> \verbatim
  112. *> LDU is INTEGER
  113. *> The leading dimension of U. LDU must be at least N and
  114. *> at least 1.
  115. *> \endverbatim
  116. *>
  117. *> \param[in] V
  118. *> \verbatim
  119. *> V is REAL array, dimension (LDV, N)
  120. *> The orthogonal matrix on the left-hand side in the
  121. *> decomposition.
  122. *> \endverbatim
  123. *>
  124. *> \param[in] LDV
  125. *> \verbatim
  126. *> LDV is INTEGER
  127. *> The leading dimension of V. LDV must be at least N and
  128. *> at least 1.
  129. *> \endverbatim
  130. *>
  131. *> \param[out] WORK
  132. *> \verbatim
  133. *> WORK is REAL array, dimension (3*N**2)
  134. *> \endverbatim
  135. *>
  136. *> \param[out] RESULT
  137. *> \verbatim
  138. *> RESULT is REAL
  139. *> The value RESULT, It is currently limited to 1/ulp, to
  140. *> avoid overflow. Errors are flagged by RESULT=10/ulp.
  141. *> \endverbatim
  142. *
  143. * Authors:
  144. * ========
  145. *
  146. *> \author Univ. of Tennessee
  147. *> \author Univ. of California Berkeley
  148. *> \author Univ. of Colorado Denver
  149. *> \author NAG Ltd.
  150. *
  151. *> \date November 2011
  152. *
  153. *> \ingroup single_eig
  154. *
  155. * =====================================================================
  156. SUBROUTINE SGET54( N, A, LDA, B, LDB, S, LDS, T, LDT, U, LDU, V,
  157. $ LDV, WORK, RESULT )
  158. *
  159. * -- LAPACK test routine (version 3.4.0) --
  160. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  161. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  162. * November 2011
  163. *
  164. * .. Scalar Arguments ..
  165. INTEGER LDA, LDB, LDS, LDT, LDU, LDV, N
  166. REAL RESULT
  167. * ..
  168. * .. Array Arguments ..
  169. REAL A( LDA, * ), B( LDB, * ), S( LDS, * ),
  170. $ T( LDT, * ), U( LDU, * ), V( LDV, * ),
  171. $ WORK( * )
  172. * ..
  173. *
  174. * =====================================================================
  175. *
  176. * .. Parameters ..
  177. REAL ZERO, ONE
  178. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  179. * ..
  180. * .. Local Scalars ..
  181. REAL ABNORM, ULP, UNFL, WNORM
  182. * ..
  183. * .. Local Arrays ..
  184. REAL DUM( 1 )
  185. * ..
  186. * .. External Functions ..
  187. REAL SLAMCH, SLANGE
  188. EXTERNAL SLAMCH, SLANGE
  189. * ..
  190. * .. External Subroutines ..
  191. EXTERNAL SGEMM, SLACPY
  192. * ..
  193. * .. Intrinsic Functions ..
  194. INTRINSIC MAX, MIN, REAL
  195. * ..
  196. * .. Executable Statements ..
  197. *
  198. RESULT = ZERO
  199. IF( N.LE.0 )
  200. $ RETURN
  201. *
  202. * Constants
  203. *
  204. UNFL = SLAMCH( 'Safe minimum' )
  205. ULP = SLAMCH( 'Epsilon' )*SLAMCH( 'Base' )
  206. *
  207. * compute the norm of (A,B)
  208. *
  209. CALL SLACPY( 'Full', N, N, A, LDA, WORK, N )
  210. CALL SLACPY( 'Full', N, N, B, LDB, WORK( N*N+1 ), N )
  211. ABNORM = MAX( SLANGE( '1', N, 2*N, WORK, N, DUM ), UNFL )
  212. *
  213. * Compute W1 = A - U*S*V', and put in the array WORK(1:N*N)
  214. *
  215. CALL SLACPY( ' ', N, N, A, LDA, WORK, N )
  216. CALL SGEMM( 'N', 'N', N, N, N, ONE, U, LDU, S, LDS, ZERO,
  217. $ WORK( N*N+1 ), N )
  218. *
  219. CALL SGEMM( 'N', 'C', N, N, N, -ONE, WORK( N*N+1 ), N, V, LDV,
  220. $ ONE, WORK, N )
  221. *
  222. * Compute W2 = B - U*T*V', and put in the workarray W(N*N+1:2*N*N)
  223. *
  224. CALL SLACPY( ' ', N, N, B, LDB, WORK( N*N+1 ), N )
  225. CALL SGEMM( 'N', 'N', N, N, N, ONE, U, LDU, T, LDT, ZERO,
  226. $ WORK( 2*N*N+1 ), N )
  227. *
  228. CALL SGEMM( 'N', 'C', N, N, N, -ONE, WORK( 2*N*N+1 ), N, V, LDV,
  229. $ ONE, WORK( N*N+1 ), N )
  230. *
  231. * Compute norm(W)/ ( ulp*norm((A,B)) )
  232. *
  233. WNORM = SLANGE( '1', N, 2*N, WORK, N, DUM )
  234. *
  235. IF( ABNORM.GT.WNORM ) THEN
  236. RESULT = ( WNORM / ABNORM ) / ( 2*N*ULP )
  237. ELSE
  238. IF( ABNORM.LT.ONE ) THEN
  239. RESULT = ( MIN( WNORM, 2*N*ABNORM ) / ABNORM ) / ( 2*N*ULP )
  240. ELSE
  241. RESULT = MIN( WNORM / ABNORM, REAL( 2*N ) ) / ( 2*N*ULP )
  242. END IF
  243. END IF
  244. *
  245. RETURN
  246. *
  247. * End of SGET54
  248. *
  249. END