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.

sqlt02.f 6.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. *> \brief \b SQLT02
  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 SQLT02( M, N, K, A, AF, Q, L, LDA, TAU, WORK, LWORK,
  12. * RWORK, RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * INTEGER K, LDA, LWORK, M, N
  16. * ..
  17. * .. Array Arguments ..
  18. * REAL A( LDA, * ), AF( LDA, * ), L( LDA, * ),
  19. * $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
  20. * $ WORK( LWORK )
  21. * ..
  22. *
  23. *
  24. *> \par Purpose:
  25. * =============
  26. *>
  27. *> \verbatim
  28. *>
  29. *> SQLT02 tests SORGQL, which generates an m-by-n matrix Q with
  30. *> orthonornmal columns that is defined as the product of k elementary
  31. *> reflectors.
  32. *>
  33. *> Given the QL factorization of an m-by-n matrix A, SQLT02 generates
  34. *> the orthogonal matrix Q defined by the factorization of the last k
  35. *> columns of A; it compares L(m-n+1:m,n-k+1:n) with
  36. *> Q(1:m,m-n+1:m)'*A(1:m,n-k+1:n), and checks that the columns of Q are
  37. *> orthonormal.
  38. *> \endverbatim
  39. *
  40. * Arguments:
  41. * ==========
  42. *
  43. *> \param[in] M
  44. *> \verbatim
  45. *> M is INTEGER
  46. *> The number of rows of the matrix Q to be generated. M >= 0.
  47. *> \endverbatim
  48. *>
  49. *> \param[in] N
  50. *> \verbatim
  51. *> N is INTEGER
  52. *> The number of columns of the matrix Q to be generated.
  53. *> M >= N >= 0.
  54. *> \endverbatim
  55. *>
  56. *> \param[in] K
  57. *> \verbatim
  58. *> K is INTEGER
  59. *> The number of elementary reflectors whose product defines the
  60. *> matrix Q. N >= K >= 0.
  61. *> \endverbatim
  62. *>
  63. *> \param[in] A
  64. *> \verbatim
  65. *> A is REAL array, dimension (LDA,N)
  66. *> The m-by-n matrix A which was factorized by SQLT01.
  67. *> \endverbatim
  68. *>
  69. *> \param[in] AF
  70. *> \verbatim
  71. *> AF is REAL array, dimension (LDA,N)
  72. *> Details of the QL factorization of A, as returned by SGEQLF.
  73. *> See SGEQLF for further details.
  74. *> \endverbatim
  75. *>
  76. *> \param[out] Q
  77. *> \verbatim
  78. *> Q is REAL array, dimension (LDA,N)
  79. *> \endverbatim
  80. *>
  81. *> \param[out] L
  82. *> \verbatim
  83. *> L is REAL array, dimension (LDA,N)
  84. *> \endverbatim
  85. *>
  86. *> \param[in] LDA
  87. *> \verbatim
  88. *> LDA is INTEGER
  89. *> The leading dimension of the arrays A, AF, Q and L. LDA >= M.
  90. *> \endverbatim
  91. *>
  92. *> \param[in] TAU
  93. *> \verbatim
  94. *> TAU is REAL array, dimension (N)
  95. *> The scalar factors of the elementary reflectors corresponding
  96. *> to the QL factorization in AF.
  97. *> \endverbatim
  98. *>
  99. *> \param[out] WORK
  100. *> \verbatim
  101. *> WORK is REAL array, dimension (LWORK)
  102. *> \endverbatim
  103. *>
  104. *> \param[in] LWORK
  105. *> \verbatim
  106. *> LWORK is INTEGER
  107. *> The dimension of the array WORK.
  108. *> \endverbatim
  109. *>
  110. *> \param[out] RWORK
  111. *> \verbatim
  112. *> RWORK is REAL array, dimension (M)
  113. *> \endverbatim
  114. *>
  115. *> \param[out] RESULT
  116. *> \verbatim
  117. *> RESULT is REAL array, dimension (2)
  118. *> The test ratios:
  119. *> RESULT(1) = norm( L - Q'*A ) / ( M * norm(A) * EPS )
  120. *> RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
  121. *> \endverbatim
  122. *
  123. * Authors:
  124. * ========
  125. *
  126. *> \author Univ. of Tennessee
  127. *> \author Univ. of California Berkeley
  128. *> \author Univ. of Colorado Denver
  129. *> \author NAG Ltd.
  130. *
  131. *> \date November 2011
  132. *
  133. *> \ingroup single_lin
  134. *
  135. * =====================================================================
  136. SUBROUTINE SQLT02( M, N, K, A, AF, Q, L, LDA, TAU, WORK, LWORK,
  137. $ RWORK, RESULT )
  138. *
  139. * -- LAPACK test routine (version 3.4.0) --
  140. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  141. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  142. * November 2011
  143. *
  144. * .. Scalar Arguments ..
  145. INTEGER K, LDA, LWORK, M, N
  146. * ..
  147. * .. Array Arguments ..
  148. REAL A( LDA, * ), AF( LDA, * ), L( LDA, * ),
  149. $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
  150. $ WORK( LWORK )
  151. * ..
  152. *
  153. * =====================================================================
  154. *
  155. * .. Parameters ..
  156. REAL ZERO, ONE
  157. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
  158. REAL ROGUE
  159. PARAMETER ( ROGUE = -1.0E+10 )
  160. * ..
  161. * .. Local Scalars ..
  162. INTEGER INFO
  163. REAL ANORM, EPS, RESID
  164. * ..
  165. * .. External Functions ..
  166. REAL SLAMCH, SLANGE, SLANSY
  167. EXTERNAL SLAMCH, SLANGE, SLANSY
  168. * ..
  169. * .. External Subroutines ..
  170. EXTERNAL SGEMM, SLACPY, SLASET, SORGQL, SSYRK
  171. * ..
  172. * .. Intrinsic Functions ..
  173. INTRINSIC MAX, REAL
  174. * ..
  175. * .. Scalars in Common ..
  176. CHARACTER*32 SRNAMT
  177. * ..
  178. * .. Common blocks ..
  179. COMMON / SRNAMC / SRNAMT
  180. * ..
  181. * .. Executable Statements ..
  182. *
  183. * Quick return if possible
  184. *
  185. IF( M.EQ.0 .OR. N.EQ.0 .OR. K.EQ.0 ) THEN
  186. RESULT( 1 ) = ZERO
  187. RESULT( 2 ) = ZERO
  188. RETURN
  189. END IF
  190. *
  191. EPS = SLAMCH( 'Epsilon' )
  192. *
  193. * Copy the last k columns of the factorization to the array Q
  194. *
  195. CALL SLASET( 'Full', M, N, ROGUE, ROGUE, Q, LDA )
  196. IF( K.LT.M )
  197. $ CALL SLACPY( 'Full', M-K, K, AF( 1, N-K+1 ), LDA,
  198. $ Q( 1, N-K+1 ), LDA )
  199. IF( K.GT.1 )
  200. $ CALL SLACPY( 'Upper', K-1, K-1, AF( M-K+1, N-K+2 ), LDA,
  201. $ Q( M-K+1, N-K+2 ), LDA )
  202. *
  203. * Generate the last n columns of the matrix Q
  204. *
  205. SRNAMT = 'SORGQL'
  206. CALL SORGQL( M, N, K, Q, LDA, TAU( N-K+1 ), WORK, LWORK, INFO )
  207. *
  208. * Copy L(m-n+1:m,n-k+1:n)
  209. *
  210. CALL SLASET( 'Full', N, K, ZERO, ZERO, L( M-N+1, N-K+1 ), LDA )
  211. CALL SLACPY( 'Lower', K, K, AF( M-K+1, N-K+1 ), LDA,
  212. $ L( M-K+1, N-K+1 ), LDA )
  213. *
  214. * Compute L(m-n+1:m,n-k+1:n) - Q(1:m,m-n+1:m)' * A(1:m,n-k+1:n)
  215. *
  216. CALL SGEMM( 'Transpose', 'No transpose', N, K, M, -ONE, Q, LDA,
  217. $ A( 1, N-K+1 ), LDA, ONE, L( M-N+1, N-K+1 ), LDA )
  218. *
  219. * Compute norm( L - Q'*A ) / ( M * norm(A) * EPS ) .
  220. *
  221. ANORM = SLANGE( '1', M, K, A( 1, N-K+1 ), LDA, RWORK )
  222. RESID = SLANGE( '1', N, K, L( M-N+1, N-K+1 ), LDA, RWORK )
  223. IF( ANORM.GT.ZERO ) THEN
  224. RESULT( 1 ) = ( ( RESID / REAL( MAX( 1, M ) ) ) / ANORM ) / EPS
  225. ELSE
  226. RESULT( 1 ) = ZERO
  227. END IF
  228. *
  229. * Compute I - Q'*Q
  230. *
  231. CALL SLASET( 'Full', N, N, ZERO, ONE, L, LDA )
  232. CALL SSYRK( 'Upper', 'Transpose', N, M, -ONE, Q, LDA, ONE, L,
  233. $ LDA )
  234. *
  235. * Compute norm( I - Q'*Q ) / ( M * EPS ) .
  236. *
  237. RESID = SLANSY( '1', 'Upper', N, L, LDA, RWORK )
  238. *
  239. RESULT( 2 ) = ( RESID / REAL( MAX( 1, M ) ) ) / EPS
  240. *
  241. RETURN
  242. *
  243. * End of SQLT02
  244. *
  245. END