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.

cunbdb6.f 8.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. *> \brief \b CUNBDB6
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CUNBDB6 + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cunbdb6.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cunbdb6.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cunbdb6.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CUNBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
  22. * LDQ2, WORK, LWORK, INFO )
  23. *
  24. * .. Scalar Arguments ..
  25. * INTEGER INCX1, INCX2, INFO, LDQ1, LDQ2, LWORK, M1, M2,
  26. * $ N
  27. * ..
  28. * .. Array Arguments ..
  29. * COMPLEX Q1(LDQ1,*), Q2(LDQ2,*), WORK(*), X1(*), X2(*)
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *>\verbatim
  37. *>
  38. *> CUNBDB6 orthogonalizes the column vector
  39. *> X = [ X1 ]
  40. *> [ X2 ]
  41. *> with respect to the columns of
  42. *> Q = [ Q1 ] .
  43. *> [ Q2 ]
  44. *> The columns of Q must be orthonormal. The orthogonalized vector will
  45. *> be zero if and only if it lies entirely in the range of Q.
  46. *>
  47. *> The projection is computed with at most two iterations of the
  48. *> classical Gram-Schmidt algorithm, see
  49. *> * L. Giraud, J. Langou, M. Rozložník. "On the round-off error
  50. *> analysis of the Gram-Schmidt algorithm with reorthogonalization."
  51. *> 2002. CERFACS Technical Report No. TR/PA/02/33. URL:
  52. *> https://www.cerfacs.fr/algor/reports/2002/TR_PA_02_33.pdf
  53. *>
  54. *>\endverbatim
  55. *
  56. * Arguments:
  57. * ==========
  58. *
  59. *> \param[in] M1
  60. *> \verbatim
  61. *> M1 is INTEGER
  62. *> The dimension of X1 and the number of rows in Q1. 0 <= M1.
  63. *> \endverbatim
  64. *>
  65. *> \param[in] M2
  66. *> \verbatim
  67. *> M2 is INTEGER
  68. *> The dimension of X2 and the number of rows in Q2. 0 <= M2.
  69. *> \endverbatim
  70. *>
  71. *> \param[in] N
  72. *> \verbatim
  73. *> N is INTEGER
  74. *> The number of columns in Q1 and Q2. 0 <= N.
  75. *> \endverbatim
  76. *>
  77. *> \param[in,out] X1
  78. *> \verbatim
  79. *> X1 is COMPLEX array, dimension (M1)
  80. *> On entry, the top part of the vector to be orthogonalized.
  81. *> On exit, the top part of the projected vector.
  82. *> \endverbatim
  83. *>
  84. *> \param[in] INCX1
  85. *> \verbatim
  86. *> INCX1 is INTEGER
  87. *> Increment for entries of X1.
  88. *> \endverbatim
  89. *>
  90. *> \param[in,out] X2
  91. *> \verbatim
  92. *> X2 is COMPLEX array, dimension (M2)
  93. *> On entry, the bottom part of the vector to be
  94. *> orthogonalized. On exit, the bottom part of the projected
  95. *> vector.
  96. *> \endverbatim
  97. *>
  98. *> \param[in] INCX2
  99. *> \verbatim
  100. *> INCX2 is INTEGER
  101. *> Increment for entries of X2.
  102. *> \endverbatim
  103. *>
  104. *> \param[in] Q1
  105. *> \verbatim
  106. *> Q1 is COMPLEX array, dimension (LDQ1, N)
  107. *> The top part of the orthonormal basis matrix.
  108. *> \endverbatim
  109. *>
  110. *> \param[in] LDQ1
  111. *> \verbatim
  112. *> LDQ1 is INTEGER
  113. *> The leading dimension of Q1. LDQ1 >= M1.
  114. *> \endverbatim
  115. *>
  116. *> \param[in] Q2
  117. *> \verbatim
  118. *> Q2 is COMPLEX array, dimension (LDQ2, N)
  119. *> The bottom part of the orthonormal basis matrix.
  120. *> \endverbatim
  121. *>
  122. *> \param[in] LDQ2
  123. *> \verbatim
  124. *> LDQ2 is INTEGER
  125. *> The leading dimension of Q2. LDQ2 >= M2.
  126. *> \endverbatim
  127. *>
  128. *> \param[out] WORK
  129. *> \verbatim
  130. *> WORK is COMPLEX array, dimension (LWORK)
  131. *> \endverbatim
  132. *>
  133. *> \param[in] LWORK
  134. *> \verbatim
  135. *> LWORK is INTEGER
  136. *> The dimension of the array WORK. LWORK >= N.
  137. *> \endverbatim
  138. *>
  139. *> \param[out] INFO
  140. *> \verbatim
  141. *> INFO is INTEGER
  142. *> = 0: successful exit.
  143. *> < 0: if INFO = -i, the i-th argument had an illegal value.
  144. *> \endverbatim
  145. *
  146. * Authors:
  147. * ========
  148. *
  149. *> \author Univ. of Tennessee
  150. *> \author Univ. of California Berkeley
  151. *> \author Univ. of Colorado Denver
  152. *> \author NAG Ltd.
  153. *
  154. *> \ingroup unbdb6
  155. *
  156. * =====================================================================
  157. SUBROUTINE CUNBDB6( M1, M2, N, X1, INCX1, X2, INCX2, Q1, LDQ1, Q2,
  158. $ LDQ2, WORK, LWORK, INFO )
  159. *
  160. * -- LAPACK computational routine --
  161. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  162. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  163. *
  164. * .. Scalar Arguments ..
  165. INTEGER INCX1, INCX2, INFO, LDQ1, LDQ2, LWORK, M1, M2,
  166. $ N
  167. * ..
  168. * .. Array Arguments ..
  169. COMPLEX Q1(LDQ1,*), Q2(LDQ2,*), WORK(*), X1(*), X2(*)
  170. * ..
  171. *
  172. * =====================================================================
  173. *
  174. * .. Parameters ..
  175. REAL ALPHA, REALONE, REALZERO
  176. PARAMETER ( ALPHA = 0.83E0, REALONE = 1.0E0,
  177. $ REALZERO = 0.0E0 )
  178. COMPLEX NEGONE, ONE, ZERO
  179. PARAMETER ( NEGONE = (-1.0E0,0.0E0), ONE = (1.0E0,0.0E0),
  180. $ ZERO = (0.0E0,0.0E0) )
  181. * ..
  182. * .. Local Scalars ..
  183. INTEGER I, IX
  184. REAL EPS, NORM, NORM_NEW, SCL, SSQ
  185. * ..
  186. * .. External Functions ..
  187. REAL SLAMCH
  188. * ..
  189. * .. External Subroutines ..
  190. EXTERNAL CGEMV, CLASSQ, XERBLA
  191. * ..
  192. * .. Intrinsic Function ..
  193. INTRINSIC MAX
  194. * ..
  195. * .. Executable Statements ..
  196. *
  197. * Test input arguments
  198. *
  199. INFO = 0
  200. IF( M1 .LT. 0 ) THEN
  201. INFO = -1
  202. ELSE IF( M2 .LT. 0 ) THEN
  203. INFO = -2
  204. ELSE IF( N .LT. 0 ) THEN
  205. INFO = -3
  206. ELSE IF( INCX1 .LT. 1 ) THEN
  207. INFO = -5
  208. ELSE IF( INCX2 .LT. 1 ) THEN
  209. INFO = -7
  210. ELSE IF( LDQ1 .LT. MAX( 1, M1 ) ) THEN
  211. INFO = -9
  212. ELSE IF( LDQ2 .LT. MAX( 1, M2 ) ) THEN
  213. INFO = -11
  214. ELSE IF( LWORK .LT. N ) THEN
  215. INFO = -13
  216. END IF
  217. *
  218. IF( INFO .NE. 0 ) THEN
  219. CALL XERBLA( 'CUNBDB6', -INFO )
  220. RETURN
  221. END IF
  222. *
  223. EPS = SLAMCH( 'Precision' )
  224. *
  225. * Compute the Euclidean norm of X
  226. *
  227. SCL = REALZERO
  228. SSQ = REALZERO
  229. CALL CLASSQ( M1, X1, INCX1, SCL, SSQ )
  230. CALL CLASSQ( M2, X2, INCX2, SCL, SSQ )
  231. NORM = SCL * SQRT( SSQ )
  232. *
  233. * First, project X onto the orthogonal complement of Q's column
  234. * space
  235. *
  236. IF( M1 .EQ. 0 ) THEN
  237. DO I = 1, N
  238. WORK(I) = ZERO
  239. END DO
  240. ELSE
  241. CALL CGEMV( 'C', M1, N, ONE, Q1, LDQ1, X1, INCX1, ZERO, WORK,
  242. $ 1 )
  243. END IF
  244. *
  245. CALL CGEMV( 'C', M2, N, ONE, Q2, LDQ2, X2, INCX2, ONE, WORK, 1 )
  246. *
  247. CALL CGEMV( 'N', M1, N, NEGONE, Q1, LDQ1, WORK, 1, ONE, X1,
  248. $ INCX1 )
  249. CALL CGEMV( 'N', M2, N, NEGONE, Q2, LDQ2, WORK, 1, ONE, X2,
  250. $ INCX2 )
  251. *
  252. SCL = REALZERO
  253. SSQ = REALZERO
  254. CALL CLASSQ( M1, X1, INCX1, SCL, SSQ )
  255. CALL CLASSQ( M2, X2, INCX2, SCL, SSQ )
  256. NORM_NEW = SCL * SQRT(SSQ)
  257. *
  258. * If projection is sufficiently large in norm, then stop.
  259. * If projection is zero, then stop.
  260. * Otherwise, project again.
  261. *
  262. IF( NORM_NEW .GE. ALPHA * NORM ) THEN
  263. RETURN
  264. END IF
  265. *
  266. IF( NORM_NEW .LE. N * EPS * NORM ) THEN
  267. DO IX = 1, 1 + (M1-1)*INCX1, INCX1
  268. X1( IX ) = ZERO
  269. END DO
  270. DO IX = 1, 1 + (M2-1)*INCX2, INCX2
  271. X2( IX ) = ZERO
  272. END DO
  273. RETURN
  274. END IF
  275. *
  276. NORM = NORM_NEW
  277. *
  278. DO I = 1, N
  279. WORK(I) = ZERO
  280. END DO
  281. *
  282. IF( M1 .EQ. 0 ) THEN
  283. DO I = 1, N
  284. WORK(I) = ZERO
  285. END DO
  286. ELSE
  287. CALL CGEMV( 'C', M1, N, ONE, Q1, LDQ1, X1, INCX1, ZERO, WORK,
  288. $ 1 )
  289. END IF
  290. *
  291. CALL CGEMV( 'C', M2, N, ONE, Q2, LDQ2, X2, INCX2, ONE, WORK, 1 )
  292. *
  293. CALL CGEMV( 'N', M1, N, NEGONE, Q1, LDQ1, WORK, 1, ONE, X1,
  294. $ INCX1 )
  295. CALL CGEMV( 'N', M2, N, NEGONE, Q2, LDQ2, WORK, 1, ONE, X2,
  296. $ INCX2 )
  297. *
  298. SCL = REALZERO
  299. SSQ = REALZERO
  300. CALL CLASSQ( M1, X1, INCX1, SCL, SSQ )
  301. CALL CLASSQ( M2, X2, INCX2, SCL, SSQ )
  302. NORM_NEW = SCL * SQRT(SSQ)
  303. *
  304. * If second projection is sufficiently large in norm, then do
  305. * nothing more. Alternatively, if it shrunk significantly, then
  306. * truncate it to zero.
  307. *
  308. IF( NORM_NEW .LT. ALPHA * NORM ) THEN
  309. DO IX = 1, 1 + (M1-1)*INCX1, INCX1
  310. X1(IX) = ZERO
  311. END DO
  312. DO IX = 1, 1 + (M2-1)*INCX2, INCX2
  313. X2(IX) = ZERO
  314. END DO
  315. END IF
  316. *
  317. RETURN
  318. *
  319. * End of CUNBDB6
  320. *
  321. END