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.

cglmts.f 6.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. *> \brief \b CGLMTS
  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 CGLMTS( N, M, P, A, AF, LDA, B, BF, LDB, D, DF,
  12. * X, U, WORK, LWORK, RWORK, RESULT )
  13. *
  14. * .. Scalar Arguments ..
  15. * INTEGER LDA, LDB, LWORK, M, P, N
  16. * REAL RESULT
  17. * ..
  18. * .. Array Arguments ..
  19. * REAL RWORK( * )
  20. * COMPLEX A( LDA, * ), AF( LDA, * ), B( LDB, * ),
  21. * $ BF( LDB, * ), D( * ), DF( * ), U( * ),
  22. * $ WORK( LWORK ), X( * )
  23. *
  24. *
  25. *> \par Purpose:
  26. * =============
  27. *>
  28. *> \verbatim
  29. *>
  30. *> CGLMTS tests CGGGLM - a subroutine for solving the generalized
  31. *> linear model problem.
  32. *> \endverbatim
  33. *
  34. * Arguments:
  35. * ==========
  36. *
  37. *> \param[in] N
  38. *> \verbatim
  39. *> N is INTEGER
  40. *> The number of rows of the matrices A and B. N >= 0.
  41. *> \endverbatim
  42. *>
  43. *> \param[in] M
  44. *> \verbatim
  45. *> M is INTEGER
  46. *> The number of columns of the matrix A. M >= 0.
  47. *> \endverbatim
  48. *>
  49. *> \param[in] P
  50. *> \verbatim
  51. *> P is INTEGER
  52. *> The number of columns of the matrix B. P >= 0.
  53. *> \endverbatim
  54. *>
  55. *> \param[in] A
  56. *> \verbatim
  57. *> A is COMPLEX array, dimension (LDA,M)
  58. *> The N-by-M matrix A.
  59. *> \endverbatim
  60. *>
  61. *> \param[out] AF
  62. *> \verbatim
  63. *> AF is COMPLEX array, dimension (LDA,M)
  64. *> \endverbatim
  65. *>
  66. *> \param[in] LDA
  67. *> \verbatim
  68. *> LDA is INTEGER
  69. *> The leading dimension of the arrays A, AF. LDA >= max(M,N).
  70. *> \endverbatim
  71. *>
  72. *> \param[in] B
  73. *> \verbatim
  74. *> B is COMPLEX array, dimension (LDB,P)
  75. *> The N-by-P matrix A.
  76. *> \endverbatim
  77. *>
  78. *> \param[out] BF
  79. *> \verbatim
  80. *> BF is COMPLEX array, dimension (LDB,P)
  81. *> \endverbatim
  82. *>
  83. *> \param[in] LDB
  84. *> \verbatim
  85. *> LDB is INTEGER
  86. *> The leading dimension of the arrays B, BF. LDB >= max(P,N).
  87. *> \endverbatim
  88. *>
  89. *> \param[in] D
  90. *> \verbatim
  91. *> D is COMPLEX array, dimension( N )
  92. *> On input, the left hand side of the GLM.
  93. *> \endverbatim
  94. *>
  95. *> \param[out] DF
  96. *> \verbatim
  97. *> DF is COMPLEX array, dimension( N )
  98. *> \endverbatim
  99. *>
  100. *> \param[out] X
  101. *> \verbatim
  102. *> X is COMPLEX array, dimension( M )
  103. *> solution vector X in the GLM problem.
  104. *> \endverbatim
  105. *>
  106. *> \param[out] U
  107. *> \verbatim
  108. *> U is COMPLEX array, dimension( P )
  109. *> solution vector U in the GLM problem.
  110. *> \endverbatim
  111. *>
  112. *> \param[out] WORK
  113. *> \verbatim
  114. *> WORK is COMPLEX array, dimension (LWORK)
  115. *> \endverbatim
  116. *>
  117. *> \param[in] LWORK
  118. *> \verbatim
  119. *> LWORK is INTEGER
  120. *> The dimension of the array WORK.
  121. *> \endverbatim
  122. *>
  123. *> \param[out] RWORK
  124. *> \verbatim
  125. *> RWORK is REAL array, dimension (M)
  126. *> \endverbatim
  127. *>
  128. *> \param[out] RESULT
  129. *> \verbatim
  130. *> RESULT is REAL
  131. *> The test ratio:
  132. *> norm( d - A*x - B*u )
  133. *> RESULT = -----------------------------------------
  134. *> (norm(A)+norm(B))*(norm(x)+norm(u))*EPS
  135. *> \endverbatim
  136. *
  137. * Authors:
  138. * ========
  139. *
  140. *> \author Univ. of Tennessee
  141. *> \author Univ. of California Berkeley
  142. *> \author Univ. of Colorado Denver
  143. *> \author NAG Ltd.
  144. *
  145. *> \date November 2011
  146. *
  147. *> \ingroup complex_eig
  148. *
  149. * =====================================================================
  150. SUBROUTINE CGLMTS( N, M, P, A, AF, LDA, B, BF, LDB, D, DF,
  151. $ X, U, WORK, LWORK, RWORK, RESULT )
  152. *
  153. * -- LAPACK test routine (version 3.4.0) --
  154. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  155. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  156. * November 2011
  157. *
  158. * .. Scalar Arguments ..
  159. INTEGER LDA, LDB, LWORK, M, P, N
  160. REAL RESULT
  161. * ..
  162. * .. Array Arguments ..
  163. REAL RWORK( * )
  164. COMPLEX A( LDA, * ), AF( LDA, * ), B( LDB, * ),
  165. $ BF( LDB, * ), D( * ), DF( * ), U( * ),
  166. $ WORK( LWORK ), X( * )
  167. *
  168. * ====================================================================
  169. *
  170. * .. Parameters ..
  171. REAL ZERO
  172. PARAMETER ( ZERO = 0.0E+0 )
  173. COMPLEX CONE
  174. PARAMETER ( CONE = 1.0E+0 )
  175. * ..
  176. * .. Local Scalars ..
  177. INTEGER INFO
  178. REAL ANORM, BNORM, EPS, XNORM, YNORM, DNORM, UNFL
  179. * ..
  180. * .. External Functions ..
  181. REAL SCASUM, SLAMCH, CLANGE
  182. EXTERNAL SCASUM, SLAMCH, CLANGE
  183. * ..
  184. * .. External Subroutines ..
  185. EXTERNAL CLACPY
  186. *
  187. * .. Intrinsic Functions ..
  188. INTRINSIC MAX
  189. * ..
  190. * .. Executable Statements ..
  191. *
  192. EPS = SLAMCH( 'Epsilon' )
  193. UNFL = SLAMCH( 'Safe minimum' )
  194. ANORM = MAX( CLANGE( '1', N, M, A, LDA, RWORK ), UNFL )
  195. BNORM = MAX( CLANGE( '1', N, P, B, LDB, RWORK ), UNFL )
  196. *
  197. * Copy the matrices A and B to the arrays AF and BF,
  198. * and the vector D the array DF.
  199. *
  200. CALL CLACPY( 'Full', N, M, A, LDA, AF, LDA )
  201. CALL CLACPY( 'Full', N, P, B, LDB, BF, LDB )
  202. CALL CCOPY( N, D, 1, DF, 1 )
  203. *
  204. * Solve GLM problem
  205. *
  206. CALL CGGGLM( N, M, P, AF, LDA, BF, LDB, DF, X, U, WORK, LWORK,
  207. $ INFO )
  208. *
  209. * Test the residual for the solution of LSE
  210. *
  211. * norm( d - A*x - B*u )
  212. * RESULT = -----------------------------------------
  213. * (norm(A)+norm(B))*(norm(x)+norm(u))*EPS
  214. *
  215. CALL CCOPY( N, D, 1, DF, 1 )
  216. CALL CGEMV( 'No transpose', N, M, -CONE, A, LDA, X, 1, CONE,
  217. $ DF, 1 )
  218. *
  219. CALL CGEMV( 'No transpose', N, P, -CONE, B, LDB, U, 1, CONE,
  220. $ DF, 1 )
  221. *
  222. DNORM = SCASUM( N, DF, 1 )
  223. XNORM = SCASUM( M, X, 1 ) + SCASUM( P, U, 1 )
  224. YNORM = ANORM + BNORM
  225. *
  226. IF( XNORM.LE.ZERO ) THEN
  227. RESULT = ZERO
  228. ELSE
  229. RESULT = ( ( DNORM / YNORM ) / XNORM ) /EPS
  230. END IF
  231. *
  232. RETURN
  233. *
  234. * End of CGLMTS
  235. *
  236. END