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.

dqpt01.f 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. *> \brief \b DQPT01
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * DOUBLE PRECISION FUNCTION DQPT01( M, N, K, A, AF, LDA, TAU, JPVT,
  12. * WORK, LWORK )
  13. *
  14. * .. Scalar Arguments ..
  15. * INTEGER K, LDA, LWORK, M, N
  16. * ..
  17. * .. Array Arguments ..
  18. * INTEGER JPVT( * )
  19. * DOUBLE PRECISION A( LDA, * ), AF( LDA, * ), TAU( * ),
  20. * $ WORK( LWORK )
  21. * ..
  22. *
  23. *
  24. *> \par Purpose:
  25. * =============
  26. *>
  27. *> \verbatim
  28. *>
  29. *> DQPT01 tests the QR-factorization with pivoting of a matrix A. The
  30. *> array AF contains the (possibly partial) QR-factorization of A, where
  31. *> the upper triangle of AF(1:K,1:K) is a partial triangular factor,
  32. *> the entries below the diagonal in the first K columns are the
  33. *> Householder vectors, and the rest of AF contains a partially updated
  34. *> matrix.
  35. *>
  36. *> This function returns ||A*P - Q*R|| / ( ||norm(A)||*eps*max(M,N) ),
  37. *> where || . || is matrix one norm.
  38. *> \endverbatim
  39. *
  40. * Arguments:
  41. * ==========
  42. *
  43. *> \param[in] M
  44. *> \verbatim
  45. *> M is INTEGER
  46. *> The number of rows of the matrices A and AF.
  47. *> \endverbatim
  48. *>
  49. *> \param[in] N
  50. *> \verbatim
  51. *> N is INTEGER
  52. *> The number of columns of the matrices A and AF.
  53. *> \endverbatim
  54. *>
  55. *> \param[in] K
  56. *> \verbatim
  57. *> K is INTEGER
  58. *> The number of columns of AF that have been reduced
  59. *> to upper triangular form.
  60. *> \endverbatim
  61. *>
  62. *> \param[in] A
  63. *> \verbatim
  64. *> A is DOUBLE PRECISION array, dimension (LDA, N)
  65. *> The original matrix A.
  66. *> \endverbatim
  67. *>
  68. *> \param[in] AF
  69. *> \verbatim
  70. *> AF is DOUBLE PRECISION array, dimension (LDA,N)
  71. *> The (possibly partial) output of DGEQPF. The upper triangle
  72. *> of AF(1:k,1:k) is a partial triangular factor, the entries
  73. *> below the diagonal in the first k columns are the Householder
  74. *> vectors, and the rest of AF contains a partially updated
  75. *> matrix.
  76. *> \endverbatim
  77. *>
  78. *> \param[in] LDA
  79. *> \verbatim
  80. *> LDA is INTEGER
  81. *> The leading dimension of the arrays A and AF.
  82. *> \endverbatim
  83. *>
  84. *> \param[in] TAU
  85. *> \verbatim
  86. *> TAU is DOUBLE PRECISION array, dimension (K)
  87. *> Details of the Householder transformations as returned by
  88. *> DGEQPF.
  89. *> \endverbatim
  90. *>
  91. *> \param[in] JPVT
  92. *> \verbatim
  93. *> JPVT is INTEGER array, dimension (N)
  94. *> Pivot information as returned by DGEQPF.
  95. *> \endverbatim
  96. *>
  97. *> \param[out] WORK
  98. *> \verbatim
  99. *> WORK is DOUBLE PRECISION array, dimension (LWORK)
  100. *> \endverbatim
  101. *>
  102. *> \param[in] LWORK
  103. *> \verbatim
  104. *> LWORK is INTEGER
  105. *> The length of the array WORK. LWORK >= M*N+N.
  106. *> \endverbatim
  107. *
  108. * Authors:
  109. * ========
  110. *
  111. *> \author Univ. of Tennessee
  112. *> \author Univ. of California Berkeley
  113. *> \author Univ. of Colorado Denver
  114. *> \author NAG Ltd.
  115. *
  116. *> \ingroup double_lin
  117. *
  118. * =====================================================================
  119. DOUBLE PRECISION FUNCTION DQPT01( M, N, K, A, AF, LDA, TAU, JPVT,
  120. $ WORK, LWORK )
  121. *
  122. * -- LAPACK test routine --
  123. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  124. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  125. *
  126. * .. Scalar Arguments ..
  127. INTEGER K, LDA, LWORK, M, N
  128. * ..
  129. * .. Array Arguments ..
  130. INTEGER JPVT( * )
  131. DOUBLE PRECISION A( LDA, * ), AF( LDA, * ), TAU( * ),
  132. $ WORK( LWORK )
  133. * ..
  134. *
  135. * =====================================================================
  136. *
  137. * .. Parameters ..
  138. DOUBLE PRECISION ZERO, ONE
  139. PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
  140. * ..
  141. * .. Local Scalars ..
  142. INTEGER I, INFO, J
  143. DOUBLE PRECISION NORMA
  144. * ..
  145. * .. Local Arrays ..
  146. DOUBLE PRECISION RWORK( 1 )
  147. * ..
  148. * .. External Functions ..
  149. DOUBLE PRECISION DLAMCH, DLANGE
  150. EXTERNAL DLAMCH, DLANGE
  151. * ..
  152. * .. External Subroutines ..
  153. EXTERNAL DAXPY, DCOPY, DORMQR, XERBLA
  154. * ..
  155. * .. Intrinsic Functions ..
  156. INTRINSIC DBLE, MAX, MIN
  157. * ..
  158. * .. Executable Statements ..
  159. *
  160. DQPT01 = ZERO
  161. *
  162. * Test if there is enough workspace
  163. *
  164. IF( LWORK.LT.M*N+N ) THEN
  165. CALL XERBLA( 'DQPT01', 10 )
  166. RETURN
  167. END IF
  168. *
  169. * Quick return if possible
  170. *
  171. IF( M.LE.0 .OR. N.LE.0 )
  172. $ RETURN
  173. *
  174. NORMA = DLANGE( 'One-norm', M, N, A, LDA, RWORK )
  175. *
  176. DO J = 1, K
  177. *
  178. * Copy the upper triangular part of the factor R stored
  179. * in AF(1:K,1:K) into the work array WORK.
  180. *
  181. DO I = 1, MIN( J, M )
  182. WORK( ( J-1 )*M+I ) = AF( I, J )
  183. END DO
  184. *
  185. * Zero out the elements below the diagonal in the work array.
  186. *
  187. DO I = J + 1, M
  188. WORK( ( J-1 )*M+I ) = ZERO
  189. END DO
  190. END DO
  191. *
  192. * Copy columns (K+1,N) from AF into the work array WORK.
  193. * AF(1:K,K+1:N) contains the rectangular block of the upper trapezoidal
  194. * factor R, AF(K+1:M,K+1:N) contains the partially updated residual
  195. * matrix of R.
  196. *
  197. DO J = K + 1, N
  198. CALL DCOPY( M, AF( 1, J ), 1, WORK( ( J-1 )*M+1 ), 1 )
  199. END DO
  200. *
  201. CALL DORMQR( 'Left', 'No transpose', M, N, K, AF, LDA, TAU, WORK,
  202. $ M, WORK( M*N+1 ), LWORK-M*N, INFO )
  203. *
  204. DO J = 1, N
  205. *
  206. * Compare J-th column of QR and JPVT(J)-th column of A.
  207. *
  208. CALL DAXPY( M, -ONE, A( 1, JPVT( J ) ), 1, WORK( ( J-1 )*M+1 ),
  209. $ 1 )
  210. END DO
  211. *
  212. DQPT01 = DLANGE( 'One-norm', M, N, WORK, M, RWORK ) /
  213. $ ( DBLE( MAX( M, N ) )*DLAMCH( 'Epsilon' ) )
  214. IF( NORMA.NE.ZERO )
  215. $ DQPT01 = DQPT01 / NORMA
  216. *
  217. RETURN
  218. *
  219. * End of DQPT01
  220. *
  221. END