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.

cgeqp3rk.f 39 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  1. *> \brief \b CGEQP3RK computes a truncated Householder QR factorization with column pivoting of a complex m-by-n matrix A by using Level 3 BLAS and overwrites m-by-nrhs matrix B with Q**H * B.
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. *> \htmlonly
  9. *> Download CGEQP3RK + dependencies
  10. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgeqp3rk.f">
  11. *> [TGZ]</a>
  12. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgeqp3rk.f">
  13. *> [ZIP]</a>
  14. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgeqp3rk.f">
  15. *> [TXT]</a>
  16. *> \endhtmlonly
  17. *
  18. * Definition:
  19. * ===========
  20. *
  21. * SUBROUTINE CGEQP3RK( M, N, NRHS, KMAX, ABSTOL, RELTOL, A, LDA,
  22. * $ K, MAXC2NRMK, RELMAXC2NRMK, JPIV, TAU,
  23. * $ WORK, LWORK, RWORK, IWORK, INFO )
  24. * IMPLICIT NONE
  25. *
  26. * .. Scalar Arguments ..
  27. * INTEGER INFO, K, KMAX, LDA, LWORK, M, N, NRHS
  28. * REAL ABSTOL, MAXC2NRMK, RELMAXC2NRMK, RELTOL
  29. * ..
  30. * .. Array Arguments ..
  31. * INTEGER IWORK( * ), JPIV( * )
  32. * REAL RWORK( * )
  33. * COMPLEX A( LDA, * ), TAU( * ), WORK( * )
  34. * ..
  35. *
  36. *
  37. *> \par Purpose:
  38. * =============
  39. *>
  40. *> \verbatim
  41. *>
  42. *> CGEQP3RK performs two tasks simultaneously:
  43. *>
  44. *> Task 1: The routine computes a truncated (rank K) or full rank
  45. *> Householder QR factorization with column pivoting of a complex
  46. *> M-by-N matrix A using Level 3 BLAS. K is the number of columns
  47. *> that were factorized, i.e. factorization rank of the
  48. *> factor R, K <= min(M,N).
  49. *>
  50. *> A * P(K) = Q(K) * R(K) =
  51. *>
  52. *> = Q(K) * ( R11(K) R12(K) ) = Q(K) * ( R(K)_approx )
  53. *> ( 0 R22(K) ) ( 0 R(K)_residual ),
  54. *>
  55. *> where:
  56. *>
  57. *> P(K) is an N-by-N permutation matrix;
  58. *> Q(K) is an M-by-M unitary matrix;
  59. *> R(K)_approx = ( R11(K), R12(K) ) is a rank K approximation of the
  60. *> full rank factor R with K-by-K upper-triangular
  61. *> R11(K) and K-by-N rectangular R12(K). The diagonal
  62. *> entries of R11(K) appear in non-increasing order
  63. *> of absolute value, and absolute values of all of
  64. *> them exceed the maximum column 2-norm of R22(K)
  65. *> up to roundoff error.
  66. *> R(K)_residual = R22(K) is the residual of a rank K approximation
  67. *> of the full rank factor R. It is a
  68. *> an (M-K)-by-(N-K) rectangular matrix;
  69. *> 0 is a an (M-K)-by-K zero matrix.
  70. *>
  71. *> Task 2: At the same time, the routine overwrites a complex M-by-NRHS
  72. *> matrix B with Q(K)**H * B using Level 3 BLAS.
  73. *>
  74. *> =====================================================================
  75. *>
  76. *> The matrices A and B are stored on input in the array A as
  77. *> the left and right blocks A(1:M,1:N) and A(1:M, N+1:N+NRHS)
  78. *> respectively.
  79. *>
  80. *> N NRHS
  81. *> array_A = M [ mat_A, mat_B ]
  82. *>
  83. *> The truncation criteria (i.e. when to stop the factorization)
  84. *> can be any of the following:
  85. *>
  86. *> 1) The input parameter KMAX, the maximum number of columns
  87. *> KMAX to factorize, i.e. the factorization rank is limited
  88. *> to KMAX. If KMAX >= min(M,N), the criterion is not used.
  89. *>
  90. *> 2) The input parameter ABSTOL, the absolute tolerance for
  91. *> the maximum column 2-norm of the residual matrix R22(K). This
  92. *> means that the factorization stops if this norm is less or
  93. *> equal to ABSTOL. If ABSTOL < 0.0, the criterion is not used.
  94. *>
  95. *> 3) The input parameter RELTOL, the tolerance for the maximum
  96. *> column 2-norm matrix of the residual matrix R22(K) divided
  97. *> by the maximum column 2-norm of the original matrix A, which
  98. *> is equal to abs(R(1,1)). This means that the factorization stops
  99. *> when the ratio of the maximum column 2-norm of R22(K) to
  100. *> the maximum column 2-norm of A is less than or equal to RELTOL.
  101. *> If RELTOL < 0.0, the criterion is not used.
  102. *>
  103. *> 4) In case both stopping criteria ABSTOL or RELTOL are not used,
  104. *> and when the residual matrix R22(K) is a zero matrix in some
  105. *> factorization step K. ( This stopping criterion is implicit. )
  106. *>
  107. *> The algorithm stops when any of these conditions is first
  108. *> satisfied, otherwise the whole matrix A is factorized.
  109. *>
  110. *> To factorize the whole matrix A, use the values
  111. *> KMAX >= min(M,N), ABSTOL < 0.0 and RELTOL < 0.0.
  112. *>
  113. *> The routine returns:
  114. *> a) Q(K), R(K)_approx = ( R11(K), R12(K) ),
  115. *> R(K)_residual = R22(K), P(K), i.e. the resulting matrices
  116. *> of the factorization; P(K) is represented by JPIV,
  117. *> ( if K = min(M,N), R(K)_approx is the full factor R,
  118. *> and there is no residual matrix R(K)_residual);
  119. *> b) K, the number of columns that were factorized,
  120. *> i.e. factorization rank;
  121. *> c) MAXC2NRMK, the maximum column 2-norm of the residual
  122. *> matrix R(K)_residual = R22(K),
  123. *> ( if K = min(M,N), MAXC2NRMK = 0.0 );
  124. *> d) RELMAXC2NRMK equals MAXC2NRMK divided by MAXC2NRM, the maximum
  125. *> column 2-norm of the original matrix A, which is equal
  126. *> to abs(R(1,1)), ( if K = min(M,N), RELMAXC2NRMK = 0.0 );
  127. *> e) Q(K)**H * B, the matrix B with the unitary
  128. *> transformation Q(K)**H applied on the left.
  129. *>
  130. *> The N-by-N permutation matrix P(K) is stored in a compact form in
  131. *> the integer array JPIV. For 1 <= j <= N, column j
  132. *> of the matrix A was interchanged with column JPIV(j).
  133. *>
  134. *> The M-by-M unitary matrix Q is represented as a product
  135. *> of elementary Householder reflectors
  136. *>
  137. *> Q(K) = H(1) * H(2) * . . . * H(K),
  138. *>
  139. *> where K is the number of columns that were factorized.
  140. *>
  141. *> Each H(j) has the form
  142. *>
  143. *> H(j) = I - tau * v * v**H,
  144. *>
  145. *> where 1 <= j <= K and
  146. *> I is an M-by-M identity matrix,
  147. *> tau is a complex scalar,
  148. *> v is a complex vector with v(1:j-1) = 0 and v(j) = 1.
  149. *>
  150. *> v(j+1:M) is stored on exit in A(j+1:M,j) and tau in TAU(j).
  151. *>
  152. *> See the Further Details section for more information.
  153. *> \endverbatim
  154. *
  155. * Arguments:
  156. * ==========
  157. *
  158. *> \param[in] M
  159. *> \verbatim
  160. *> M is INTEGER
  161. *> The number of rows of the matrix A. M >= 0.
  162. *> \endverbatim
  163. *>
  164. *> \param[in] N
  165. *> \verbatim
  166. *> N is INTEGER
  167. *> The number of columns of the matrix A. N >= 0.
  168. *> \endverbatim
  169. *>
  170. *> \param[in] NRHS
  171. *> \verbatim
  172. *> NRHS is INTEGER
  173. *> The number of right hand sides, i.e. the number of
  174. *> columns of the matrix B. NRHS >= 0.
  175. *> \endverbatim
  176. *>
  177. *> \param[in] KMAX
  178. *> \verbatim
  179. *> KMAX is INTEGER
  180. *>
  181. *> The first factorization stopping criterion. KMAX >= 0.
  182. *>
  183. *> The maximum number of columns of the matrix A to factorize,
  184. *> i.e. the maximum factorization rank.
  185. *>
  186. *> a) If KMAX >= min(M,N), then this stopping criterion
  187. *> is not used, the routine factorizes columns
  188. *> depending on ABSTOL and RELTOL.
  189. *>
  190. *> b) If KMAX = 0, then this stopping criterion is
  191. *> satisfied on input and the routine exits immediately.
  192. *> This means that the factorization is not performed,
  193. *> the matrices A and B are not modified, and
  194. *> the matrix A is itself the residual.
  195. *> \endverbatim
  196. *>
  197. *> \param[in] ABSTOL
  198. *> \verbatim
  199. *> ABSTOL is REAL
  200. *>
  201. *> The second factorization stopping criterion, cannot be NaN.
  202. *>
  203. *> The absolute tolerance (stopping threshold) for
  204. *> maximum column 2-norm of the residual matrix R22(K).
  205. *> The algorithm converges (stops the factorization) when
  206. *> the maximum column 2-norm of the residual matrix R22(K)
  207. *> is less than or equal to ABSTOL. Let SAFMIN = DLAMCH('S').
  208. *>
  209. *> a) If ABSTOL is NaN, then no computation is performed
  210. *> and an error message ( INFO = -5 ) is issued
  211. *> by XERBLA.
  212. *>
  213. *> b) If ABSTOL < 0.0, then this stopping criterion is not
  214. *> used, the routine factorizes columns depending
  215. *> on KMAX and RELTOL.
  216. *> This includes the case ABSTOL = -Inf.
  217. *>
  218. *> c) If 0.0 <= ABSTOL < 2*SAFMIN, then ABSTOL = 2*SAFMIN
  219. *> is used. This includes the case ABSTOL = -0.0.
  220. *>
  221. *> d) If 2*SAFMIN <= ABSTOL then the input value
  222. *> of ABSTOL is used.
  223. *>
  224. *> Let MAXC2NRM be the maximum column 2-norm of the
  225. *> whole original matrix A.
  226. *> If ABSTOL chosen above is >= MAXC2NRM, then this
  227. *> stopping criterion is satisfied on input and routine exits
  228. *> immediately after MAXC2NRM is computed. The routine
  229. *> returns MAXC2NRM in MAXC2NORMK,
  230. *> and 1.0 in RELMAXC2NORMK.
  231. *> This includes the case ABSTOL = +Inf. This means that the
  232. *> factorization is not performed, the matrices A and B are not
  233. *> modified, and the matrix A is itself the residual.
  234. *> \endverbatim
  235. *>
  236. *> \param[in] RELTOL
  237. *> \verbatim
  238. *> RELTOL is REAL
  239. *>
  240. *> The third factorization stopping criterion, cannot be NaN.
  241. *>
  242. *> The tolerance (stopping threshold) for the ratio
  243. *> abs(R(K+1,K+1))/abs(R(1,1)) of the maximum column 2-norm of
  244. *> the residual matrix R22(K) to the maximum column 2-norm of
  245. *> the original matrix A. The algorithm converges (stops the
  246. *> factorization), when abs(R(K+1,K+1))/abs(R(1,1)) A is less
  247. *> than or equal to RELTOL. Let EPS = DLAMCH('E').
  248. *>
  249. *> a) If RELTOL is NaN, then no computation is performed
  250. *> and an error message ( INFO = -6 ) is issued
  251. *> by XERBLA.
  252. *>
  253. *> b) If RELTOL < 0.0, then this stopping criterion is not
  254. *> used, the routine factorizes columns depending
  255. *> on KMAX and ABSTOL.
  256. *> This includes the case RELTOL = -Inf.
  257. *>
  258. *> c) If 0.0 <= RELTOL < EPS, then RELTOL = EPS is used.
  259. *> This includes the case RELTOL = -0.0.
  260. *>
  261. *> d) If EPS <= RELTOL then the input value of RELTOL
  262. *> is used.
  263. *>
  264. *> Let MAXC2NRM be the maximum column 2-norm of the
  265. *> whole original matrix A.
  266. *> If RELTOL chosen above is >= 1.0, then this stopping
  267. *> criterion is satisfied on input and routine exits
  268. *> immediately after MAXC2NRM is computed.
  269. *> The routine returns MAXC2NRM in MAXC2NORMK,
  270. *> and 1.0 in RELMAXC2NORMK.
  271. *> This includes the case RELTOL = +Inf. This means that the
  272. *> factorization is not performed, the matrices A and B are not
  273. *> modified, and the matrix A is itself the residual.
  274. *>
  275. *> NOTE: We recommend that RELTOL satisfy
  276. *> min( 10*max(M,N)*EPS, sqrt(EPS) ) <= RELTOL
  277. *> \endverbatim
  278. *>
  279. *> \param[in,out] A
  280. *> \verbatim
  281. *> A is COMPLEX array, dimension (LDA,N+NRHS)
  282. *>
  283. *> On entry:
  284. *>
  285. *> a) The subarray A(1:M,1:N) contains the M-by-N matrix A.
  286. *> b) The subarray A(1:M,N+1:N+NRHS) contains the M-by-NRHS
  287. *> matrix B.
  288. *>
  289. *> N NRHS
  290. *> array_A = M [ mat_A, mat_B ]
  291. *>
  292. *> On exit:
  293. *>
  294. *> a) The subarray A(1:M,1:N) contains parts of the factors
  295. *> of the matrix A:
  296. *>
  297. *> 1) If K = 0, A(1:M,1:N) contains the original matrix A.
  298. *> 2) If K > 0, A(1:M,1:N) contains parts of the
  299. *> factors:
  300. *>
  301. *> 1. The elements below the diagonal of the subarray
  302. *> A(1:M,1:K) together with TAU(1:K) represent the
  303. *> unitary matrix Q(K) as a product of K Householder
  304. *> elementary reflectors.
  305. *>
  306. *> 2. The elements on and above the diagonal of
  307. *> the subarray A(1:K,1:N) contain K-by-N
  308. *> upper-trapezoidal matrix
  309. *> R(K)_approx = ( R11(K), R12(K) ).
  310. *> NOTE: If K=min(M,N), i.e. full rank factorization,
  311. *> then R_approx(K) is the full factor R which
  312. *> is upper-trapezoidal. If, in addition, M>=N,
  313. *> then R is upper-triangular.
  314. *>
  315. *> 3. The subarray A(K+1:M,K+1:N) contains (M-K)-by-(N-K)
  316. *> rectangular matrix R(K)_residual = R22(K).
  317. *>
  318. *> b) If NRHS > 0, the subarray A(1:M,N+1:N+NRHS) contains
  319. *> the M-by-NRHS product Q(K)**H * B.
  320. *> \endverbatim
  321. *>
  322. *> \param[in] LDA
  323. *> \verbatim
  324. *> LDA is INTEGER
  325. *> The leading dimension of the array A. LDA >= max(1,M).
  326. *> This is the leading dimension for both matrices, A and B.
  327. *> \endverbatim
  328. *>
  329. *> \param[out] K
  330. *> \verbatim
  331. *> K is INTEGER
  332. *> Factorization rank of the matrix A, i.e. the rank of
  333. *> the factor R, which is the same as the number of non-zero
  334. *> rows of the factor R. 0 <= K <= min(M,KMAX,N).
  335. *>
  336. *> K also represents the number of non-zero Householder
  337. *> vectors.
  338. *>
  339. *> NOTE: If K = 0, a) the arrays A and B are not modified;
  340. *> b) the array TAU(1:min(M,N)) is set to ZERO,
  341. *> if the matrix A does not contain NaN,
  342. *> otherwise the elements TAU(1:min(M,N))
  343. *> are undefined;
  344. *> c) the elements of the array JPIV are set
  345. *> as follows: for j = 1:N, JPIV(j) = j.
  346. *> \endverbatim
  347. *>
  348. *> \param[out] MAXC2NRMK
  349. *> \verbatim
  350. *> MAXC2NRMK is REAL
  351. *> The maximum column 2-norm of the residual matrix R22(K),
  352. *> when the factorization stopped at rank K. MAXC2NRMK >= 0.
  353. *>
  354. *> a) If K = 0, i.e. the factorization was not performed,
  355. *> the matrix A was not modified and is itself a residual
  356. *> matrix, then MAXC2NRMK equals the maximum column 2-norm
  357. *> of the original matrix A.
  358. *>
  359. *> b) If 0 < K < min(M,N), then MAXC2NRMK is returned.
  360. *>
  361. *> c) If K = min(M,N), i.e. the whole matrix A was
  362. *> factorized and there is no residual matrix,
  363. *> then MAXC2NRMK = 0.0.
  364. *>
  365. *> NOTE: MAXC2NRMK in the factorization step K would equal
  366. *> R(K+1,K+1) in the next factorization step K+1.
  367. *> \endverbatim
  368. *>
  369. *> \param[out] RELMAXC2NRMK
  370. *> \verbatim
  371. *> RELMAXC2NRMK is REAL
  372. *> The ratio MAXC2NRMK / MAXC2NRM of the maximum column
  373. *> 2-norm of the residual matrix R22(K) (when the factorization
  374. *> stopped at rank K) to the maximum column 2-norm of the
  375. *> whole original matrix A. RELMAXC2NRMK >= 0.
  376. *>
  377. *> a) If K = 0, i.e. the factorization was not performed,
  378. *> the matrix A was not modified and is itself a residual
  379. *> matrix, then RELMAXC2NRMK = 1.0.
  380. *>
  381. *> b) If 0 < K < min(M,N), then
  382. *> RELMAXC2NRMK = MAXC2NRMK / MAXC2NRM is returned.
  383. *>
  384. *> c) If K = min(M,N), i.e. the whole matrix A was
  385. *> factorized and there is no residual matrix,
  386. *> then RELMAXC2NRMK = 0.0.
  387. *>
  388. *> NOTE: RELMAXC2NRMK in the factorization step K would equal
  389. *> abs(R(K+1,K+1))/abs(R(1,1)) in the next factorization
  390. *> step K+1.
  391. *> \endverbatim
  392. *>
  393. *> \param[out] JPIV
  394. *> \verbatim
  395. *> JPIV is INTEGER array, dimension (N)
  396. *> Column pivot indices. For 1 <= j <= N, column j
  397. *> of the matrix A was interchanged with column JPIV(j).
  398. *>
  399. *> The elements of the array JPIV(1:N) are always set
  400. *> by the routine, for example, even when no columns
  401. *> were factorized, i.e. when K = 0, the elements are
  402. *> set as JPIV(j) = j for j = 1:N.
  403. *> \endverbatim
  404. *>
  405. *> \param[out] TAU
  406. *> \verbatim
  407. *> TAU is COMPLEX array, dimension (min(M,N))
  408. *> The scalar factors of the elementary reflectors.
  409. *>
  410. *> If 0 < K <= min(M,N), only the elements TAU(1:K) of
  411. *> the array TAU are modified by the factorization.
  412. *> After the factorization computed, if no NaN was found
  413. *> during the factorization, the remaining elements
  414. *> TAU(K+1:min(M,N)) are set to zero, otherwise the
  415. *> elements TAU(K+1:min(M,N)) are not set and therefore
  416. *> undefined.
  417. *> ( If K = 0, all elements of TAU are set to zero, if
  418. *> the matrix A does not contain NaN. )
  419. *> \endverbatim
  420. *>
  421. *> \param[out] WORK
  422. *> \verbatim
  423. *> WORK is COMPLEX array, dimension (MAX(1,LWORK))
  424. *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  425. *> \endverbatim
  426. *>
  427. *> \param[in] LWORK
  428. *> \verbatim
  429. *> LWORK is INTEGER
  430. *> The dimension of the array WORK.
  431. *. LWORK >= N+NRHS-1
  432. *> For optimal performance LWORK >= NB*( N+NRHS+1 ),
  433. *> where NB is the optimal block size for CGEQP3RK returned
  434. *> by ILAENV. Minimal block size MINNB=2.
  435. *>
  436. *> NOTE: The decision, whether to use unblocked BLAS 2
  437. *> or blocked BLAS 3 code is based not only on the dimension
  438. *> LWORK of the availbale workspace WORK, but also also on the
  439. *> matrix A dimension N via crossover point NX returned
  440. *> by ILAENV. (For N less than NX, unblocked code should be
  441. *> used.)
  442. *>
  443. *> If LWORK = -1, then a workspace query is assumed;
  444. *> the routine only calculates the optimal size of the WORK
  445. *> array, returns this value as the first entry of the WORK
  446. *> array, and no error message related to LWORK is issued
  447. *> by XERBLA.
  448. *> \endverbatim
  449. *>
  450. *> \param[out] RWORK
  451. *> \verbatim
  452. *> RWORK is REAL array, dimension (2*N)
  453. *> \endverbatim
  454. *>
  455. *> \param[out] IWORK
  456. *> \verbatim
  457. *> IWORK is INTEGER array, dimension (N-1).
  458. *> Is a work array. ( IWORK is used to store indices
  459. *> of "bad" columns for norm downdating in the residual
  460. *> matrix in the blocked step auxiliary subroutine CLAQP3RK ).
  461. *> \endverbatim
  462. *>
  463. *> \param[out] INFO
  464. *> \verbatim
  465. *> INFO is INTEGER
  466. *> 1) INFO = 0: successful exit.
  467. *> 2) INFO < 0: if INFO = -i, the i-th argument had an
  468. *> illegal value.
  469. *> 3) If INFO = j_1, where 1 <= j_1 <= N, then NaN was
  470. *> detected and the routine stops the computation.
  471. *> The j_1-th column of the matrix A or the j_1-th
  472. *> element of array TAU contains the first occurrence
  473. *> of NaN in the factorization step K+1 ( when K columns
  474. *> have been factorized ).
  475. *>
  476. *> On exit:
  477. *> K is set to the number of
  478. *> factorized columns without
  479. *> exception.
  480. *> MAXC2NRMK is set to NaN.
  481. *> RELMAXC2NRMK is set to NaN.
  482. *> TAU(K+1:min(M,N)) is not set and contains undefined
  483. *> elements. If j_1=K+1, TAU(K+1)
  484. *> may contain NaN.
  485. *> 4) If INFO = j_2, where N+1 <= j_2 <= 2*N, then no NaN
  486. *> was detected, but +Inf (or -Inf) was detected and
  487. *> the routine continues the computation until completion.
  488. *> The (j_2-N)-th column of the matrix A contains the first
  489. *> occurrence of +Inf (or -Inf) in the factorization
  490. *> step K+1 ( when K columns have been factorized ).
  491. *> \endverbatim
  492. *
  493. * Authors:
  494. * ========
  495. *
  496. *> \author Univ. of Tennessee
  497. *> \author Univ. of California Berkeley
  498. *> \author Univ. of Colorado Denver
  499. *> \author NAG Ltd.
  500. *
  501. *> \ingroup geqp3rk
  502. *
  503. *> \par Further Details:
  504. * =====================
  505. *
  506. *> \verbatim
  507. *> CGEQP3RK is based on the same BLAS3 Householder QR factorization
  508. *> algorithm with column pivoting as in CGEQP3 routine which uses
  509. *> CLARFG routine to generate Householder reflectors
  510. *> for QR factorization.
  511. *>
  512. *> We can also write:
  513. *>
  514. *> A = A_approx(K) + A_residual(K)
  515. *>
  516. *> The low rank approximation matrix A(K)_approx from
  517. *> the truncated QR factorization of rank K of the matrix A is:
  518. *>
  519. *> A(K)_approx = Q(K) * ( R(K)_approx ) * P(K)**T
  520. *> ( 0 0 )
  521. *>
  522. *> = Q(K) * ( R11(K) R12(K) ) * P(K)**T
  523. *> ( 0 0 )
  524. *>
  525. *> The residual A_residual(K) of the matrix A is:
  526. *>
  527. *> A_residual(K) = Q(K) * ( 0 0 ) * P(K)**T =
  528. *> ( 0 R(K)_residual )
  529. *>
  530. *> = Q(K) * ( 0 0 ) * P(K)**T
  531. *> ( 0 R22(K) )
  532. *>
  533. *> The truncated (rank K) factorization guarantees that
  534. *> the maximum column 2-norm of A_residual(K) is less than
  535. *> or equal to MAXC2NRMK up to roundoff error.
  536. *>
  537. *> NOTE: An approximation of the null vectors
  538. *> of A can be easily computed from R11(K)
  539. *> and R12(K):
  540. *>
  541. *> Null( A(K) )_approx = P * ( inv(R11(K)) * R12(K) )
  542. *> ( -I )
  543. *>
  544. *> \endverbatim
  545. *
  546. *> \par References:
  547. * ================
  548. *> [1] A Level 3 BLAS QR factorization algorithm with column pivoting developed in 1996.
  549. *> G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain.
  550. *> X. Sun, Computer Science Dept., Duke University, USA.
  551. *> C. H. Bischof, Math. and Comp. Sci. Div., Argonne National Lab, USA.
  552. *> A BLAS-3 version of the QR factorization with column pivoting.
  553. *> LAPACK Working Note 114
  554. *> \htmlonly
  555. *> <a href="https://www.netlib.org/lapack/lawnspdf/lawn114.pdf">https://www.netlib.org/lapack/lawnspdf/lawn114.pdf</a>
  556. *> \endhtmlonly
  557. *> and in
  558. *> SIAM J. Sci. Comput., 19(5):1486-1494, Sept. 1998.
  559. *> \htmlonly
  560. *> <a href="https://doi.org/10.1137/S1064827595296732">https://doi.org/10.1137/S1064827595296732</a>
  561. *> \endhtmlonly
  562. *>
  563. *> [2] A partial column norm updating strategy developed in 2006.
  564. *> Z. Drmac and Z. Bujanovic, Dept. of Math., University of Zagreb, Croatia.
  565. *> On the failure of rank revealing QR factorization software – a case study.
  566. *> LAPACK Working Note 176.
  567. *> \htmlonly
  568. *> <a href="http://www.netlib.org/lapack/lawnspdf/lawn176.pdf">http://www.netlib.org/lapack/lawnspdf/lawn176.pdf</a>
  569. *> \endhtmlonly
  570. *> and in
  571. *> ACM Trans. Math. Softw. 35, 2, Article 12 (July 2008), 28 pages.
  572. *> \htmlonly
  573. *> <a href="https://doi.org/10.1145/1377612.1377616">https://doi.org/10.1145/1377612.1377616</a>
  574. *> \endhtmlonly
  575. *
  576. *> \par Contributors:
  577. * ==================
  578. *>
  579. *> \verbatim
  580. *>
  581. *> November 2023, Igor Kozachenko, James Demmel,
  582. *> EECS Department,
  583. *> University of California, Berkeley, USA.
  584. *>
  585. *> \endverbatim
  586. *
  587. * =====================================================================
  588. SUBROUTINE CGEQP3RK( M, N, NRHS, KMAX, ABSTOL, RELTOL, A, LDA,
  589. $ K, MAXC2NRMK, RELMAXC2NRMK, JPIV, TAU,
  590. $ WORK, LWORK, RWORK, IWORK, INFO )
  591. IMPLICIT NONE
  592. *
  593. * -- LAPACK computational routine --
  594. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  595. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  596. *
  597. * .. Scalar Arguments ..
  598. INTEGER INFO, K, KF, KMAX, LDA, LWORK, M, N, NRHS
  599. REAL ABSTOL, MAXC2NRMK, RELMAXC2NRMK, RELTOL
  600. * ..
  601. * .. Array Arguments ..
  602. INTEGER IWORK( * ), JPIV( * )
  603. REAL RWORK( * )
  604. COMPLEX A( LDA, * ), TAU( * ), WORK( * )
  605. * ..
  606. *
  607. * =====================================================================
  608. *
  609. * .. Parameters ..
  610. INTEGER INB, INBMIN, IXOVER
  611. PARAMETER ( INB = 1, INBMIN = 2, IXOVER = 3 )
  612. REAL ZERO, ONE, TWO
  613. PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0 )
  614. COMPLEX CZERO
  615. PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ) )
  616. * ..
  617. * .. Local Scalars ..
  618. LOGICAL LQUERY, DONE
  619. INTEGER IINFO, IOFFSET, IWS, J, JB, JBF, JMAXB, JMAX,
  620. $ JMAXC2NRM, KP1, LWKOPT, MINMN, N_SUB, NB,
  621. $ NBMIN, NX
  622. REAL EPS, HUGEVAL, MAXC2NRM, SAFMIN
  623. * ..
  624. * .. External Subroutines ..
  625. EXTERNAL CLAQP2RK, CLAQP3RK, XERBLA
  626. * ..
  627. * .. External Functions ..
  628. LOGICAL SISNAN
  629. INTEGER ISAMAX, ILAENV
  630. REAL SLAMCH, SCNRM2
  631. EXTERNAL SISNAN, SLAMCH, SCNRM2, ISAMAX, ILAENV
  632. * ..
  633. * .. Intrinsic Functions ..
  634. INTRINSIC CMPLX, MAX, MIN
  635. * ..
  636. * .. Executable Statements ..
  637. *
  638. * Test input arguments
  639. * ====================
  640. *
  641. INFO = 0
  642. LQUERY = ( LWORK.EQ.-1 )
  643. IF( M.LT.0 ) THEN
  644. INFO = -1
  645. ELSE IF( N.LT.0 ) THEN
  646. INFO = -2
  647. ELSE IF( NRHS.LT.0 ) THEN
  648. INFO = -3
  649. ELSE IF( KMAX.LT.0 ) THEN
  650. INFO = -4
  651. ELSE IF( SISNAN( ABSTOL ) ) THEN
  652. INFO = -5
  653. ELSE IF( SISNAN( RELTOL ) ) THEN
  654. INFO = -6
  655. ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  656. INFO = -8
  657. END IF
  658. *
  659. * If the input parameters M, N, NRHS, KMAX, LDA are valid:
  660. * a) Test the input workspace size LWORK for the minimum
  661. * size requirement IWS.
  662. * b) Determine the optimal block size NB and optimal
  663. * workspace size LWKOPT to be returned in WORK(1)
  664. * in case of (1) LWORK < IWS, (2) LQUERY = .TRUE.,
  665. * (3) when routine exits.
  666. * Here, IWS is the miminum workspace required for unblocked
  667. * code.
  668. *
  669. IF( INFO.EQ.0 ) THEN
  670. MINMN = MIN( M, N )
  671. IF( MINMN.EQ.0 ) THEN
  672. IWS = 1
  673. LWKOPT = 1
  674. ELSE
  675. *
  676. * Minimal workspace size in case of using only unblocked
  677. * BLAS 2 code in CLAQP2RK.
  678. * 1) CLAQP2RK: N+NRHS-1 to use in WORK array that is used
  679. * in CLARF subroutine inside CLAQP2RK to apply an
  680. * elementary reflector from the left.
  681. * TOTAL_WORK_SIZE = 3*N + NRHS - 1
  682. *
  683. IWS = N + NRHS - 1
  684. *
  685. * Assign to NB optimal block size.
  686. *
  687. NB = ILAENV( INB, 'CGEQP3RK', ' ', M, N, -1, -1 )
  688. *
  689. * A formula for the optimal workspace size in case of using
  690. * both unblocked BLAS 2 in CLAQP2RK and blocked BLAS 3 code
  691. * in CLAQP3RK.
  692. * 1) CGEQP3RK, CLAQP2RK, CLAQP3RK: 2*N to store full and
  693. * partial column 2-norms.
  694. * 2) CLAQP2RK: N+NRHS-1 to use in WORK array that is used
  695. * in CLARF subroutine to apply an elementary reflector
  696. * from the left.
  697. * 3) CLAQP3RK: NB*(N+NRHS) to use in the work array F that
  698. * is used to apply a block reflector from
  699. * the left.
  700. * 4) CLAQP3RK: NB to use in the auxilixary array AUX.
  701. * Sizes (2) and ((3) + (4)) should intersect, therefore
  702. * TOTAL_WORK_SIZE = 2*N + NB*( N+NRHS+1 ), given NBMIN=2.
  703. *
  704. LWKOPT = 2*N + NB*( N+NRHS+1 )
  705. END IF
  706. WORK( 1 ) = CMPLX( LWKOPT )
  707. *
  708. IF( ( LWORK.LT.IWS ) .AND. .NOT.LQUERY ) THEN
  709. INFO = -15
  710. END IF
  711. END IF
  712. *
  713. * NOTE: The optimal workspace size is returned in WORK(1), if
  714. * the input parameters M, N, NRHS, KMAX, LDA are valid.
  715. *
  716. IF( INFO.NE.0 ) THEN
  717. CALL XERBLA( 'CGEQP3RK', -INFO )
  718. RETURN
  719. ELSE IF( LQUERY ) THEN
  720. RETURN
  721. END IF
  722. *
  723. * Quick return if possible for M=0 or N=0.
  724. *
  725. IF( MINMN.EQ.0 ) THEN
  726. K = 0
  727. MAXC2NRMK = ZERO
  728. RELMAXC2NRMK = ZERO
  729. WORK( 1 ) = CMPLX( LWKOPT )
  730. RETURN
  731. END IF
  732. *
  733. * ==================================================================
  734. *
  735. * Initialize column pivot array JPIV.
  736. *
  737. DO J = 1, N
  738. JPIV( J ) = J
  739. END DO
  740. *
  741. * ==================================================================
  742. *
  743. * Initialize storage for partial and exact column 2-norms.
  744. * a) The elements WORK(1:N) are used to store partial column
  745. * 2-norms of the matrix A, and may decrease in each computation
  746. * step; initialize to the values of complete columns 2-norms.
  747. * b) The elements WORK(N+1:2*N) are used to store complete column
  748. * 2-norms of the matrix A, they are not changed during the
  749. * computation; initialize the values of complete columns 2-norms.
  750. *
  751. DO J = 1, N
  752. RWORK( J ) = SCNRM2( M, A( 1, J ), 1 )
  753. RWORK( N+J ) = RWORK( J )
  754. END DO
  755. *
  756. * ==================================================================
  757. *
  758. * Compute the pivot column index and the maximum column 2-norm
  759. * for the whole original matrix stored in A(1:M,1:N).
  760. *
  761. KP1 = ISAMAX( N, RWORK( 1 ), 1 )
  762. *
  763. * ==================================================================.
  764. *
  765. IF( SISNAN( MAXC2NRM ) ) THEN
  766. *
  767. * Check if the matrix A contains NaN, set INFO parameter
  768. * to the column number where the first NaN is found and return
  769. * from the routine.
  770. *
  771. K = 0
  772. INFO = KP1
  773. *
  774. * Set MAXC2NRMK and RELMAXC2NRMK to NaN.
  775. *
  776. MAXC2NRMK = MAXC2NRM
  777. RELMAXC2NRMK = MAXC2NRM
  778. *
  779. * Array TAU is not set and contains undefined elements.
  780. *
  781. WORK( 1 ) = CMPLX( LWKOPT )
  782. RETURN
  783. END IF
  784. *
  785. * ===================================================================
  786. *
  787. IF( MAXC2NRM.EQ.ZERO ) THEN
  788. *
  789. * Check is the matrix A is a zero matrix, set array TAU and
  790. * return from the routine.
  791. *
  792. K = 0
  793. MAXC2NRMK = ZERO
  794. RELMAXC2NRMK = ZERO
  795. *
  796. DO J = 1, MINMN
  797. TAU( J ) = CZERO
  798. END DO
  799. *
  800. WORK( 1 ) = CMPLX( LWKOPT )
  801. RETURN
  802. *
  803. END IF
  804. *
  805. * ===================================================================
  806. *
  807. HUGEVAL = SLAMCH( 'Overflow' )
  808. *
  809. IF( MAXC2NRM.GT.HUGEVAL ) THEN
  810. *
  811. * Check if the matrix A contains +Inf or -Inf, set INFO parameter
  812. * to the column number, where the first +/-Inf is found plus N,
  813. * and continue the computation.
  814. *
  815. INFO = N + KP1
  816. *
  817. END IF
  818. *
  819. * ==================================================================
  820. *
  821. * Quick return if possible for the case when the first
  822. * stopping criterion is satisfied, i.e. KMAX = 0.
  823. *
  824. IF( KMAX.EQ.0 ) THEN
  825. K = 0
  826. MAXC2NRMK = MAXC2NRM
  827. RELMAXC2NRMK = ONE
  828. DO J = 1, MINMN
  829. TAU( J ) = CZERO
  830. END DO
  831. WORK( 1 ) = CMPLX( LWKOPT )
  832. RETURN
  833. END IF
  834. *
  835. * ==================================================================
  836. *
  837. EPS = SLAMCH('Epsilon')
  838. *
  839. * Adjust ABSTOL
  840. *
  841. IF( ABSTOL.GE.ZERO ) THEN
  842. SAFMIN = SLAMCH('Safe minimum')
  843. ABSTOL = MAX( ABSTOL, TWO*SAFMIN )
  844. END IF
  845. *
  846. * Adjust RELTOL
  847. *
  848. IF( RELTOL.GE.ZERO ) THEN
  849. RELTOL = MAX( RELTOL, EPS )
  850. END IF
  851. *
  852. * ===================================================================
  853. *
  854. * JMAX is the maximum index of the column to be factorized,
  855. * which is also limited by the first stopping criterion KMAX.
  856. *
  857. JMAX = MIN( KMAX, MINMN )
  858. *
  859. * ===================================================================
  860. *
  861. * Quick return if possible for the case when the second or third
  862. * stopping criterion for the whole original matrix is satified,
  863. * i.e. MAXC2NRM <= ABSTOL or RELMAXC2NRM <= RELTOL
  864. * (which is ONE <= RELTOL).
  865. *
  866. IF( MAXC2NRM.LE.ABSTOL .OR. ONE.LE.RELTOL ) THEN
  867. *
  868. K = 0
  869. MAXC2NRMK = MAXC2NRM
  870. RELMAXC2NRMK = ONE
  871. *
  872. DO J = 1, MINMN
  873. TAU( J ) = CZERO
  874. END DO
  875. *
  876. WORK( 1 ) = CMPLX( LWKOPT )
  877. RETURN
  878. END IF
  879. *
  880. * ==================================================================
  881. * Factorize columns
  882. * ==================================================================
  883. *
  884. * Determine the block size.
  885. *
  886. NBMIN = 2
  887. NX = 0
  888. *
  889. IF( ( NB.GT.1 ) .AND. ( NB.LT.MINMN ) ) THEN
  890. *
  891. * Determine when to cross over from blocked to unblocked code.
  892. * (for N less than NX, unblocked code should be used).
  893. *
  894. NX = MAX( 0, ILAENV( IXOVER, 'CGEQP3RK', ' ', M, N, -1, -1 ) )
  895. *
  896. IF( NX.LT.MINMN ) THEN
  897. *
  898. * Determine if workspace is large enough for blocked code.
  899. *
  900. IF( LWORK.LT.LWKOPT ) THEN
  901. *
  902. * Not enough workspace to use optimal block size that
  903. * is currently stored in NB.
  904. * Reduce NB and determine the minimum value of NB.
  905. *
  906. NB = ( LWORK-2*N ) / ( N+1 )
  907. NBMIN = MAX( 2, ILAENV( INBMIN, 'CGEQP3RK', ' ', M, N,
  908. $ -1, -1 ) )
  909. *
  910. END IF
  911. END IF
  912. END IF
  913. *
  914. * ==================================================================
  915. *
  916. * DONE is the boolean flag to rerpresent the case when the
  917. * factorization completed in the block factorization routine,
  918. * before the end of the block.
  919. *
  920. DONE = .FALSE.
  921. *
  922. * J is the column index.
  923. *
  924. J = 1
  925. *
  926. * (1) Use blocked code initially.
  927. *
  928. * JMAXB is the maximum column index of the block, when the
  929. * blocked code is used, is also limited by the first stopping
  930. * criterion KMAX.
  931. *
  932. JMAXB = MIN( KMAX, MINMN - NX )
  933. *
  934. IF( NB.GE.NBMIN .AND. NB.LT.JMAX .AND. JMAXB.GT.0 ) THEN
  935. *
  936. * Loop over the column blocks of the matrix A(1:M,1:JMAXB). Here:
  937. * J is the column index of a column block;
  938. * JB is the column block size to pass to block factorization
  939. * routine in a loop step;
  940. * JBF is the number of columns that were actually factorized
  941. * that was returned by the block factorization routine
  942. * in a loop step, JBF <= JB;
  943. * N_SUB is the number of columns in the submatrix;
  944. * IOFFSET is the number of rows that should not be factorized.
  945. *
  946. DO WHILE( J.LE.JMAXB )
  947. *
  948. JB = MIN( NB, JMAXB-J+1 )
  949. N_SUB = N-J+1
  950. IOFFSET = J-1
  951. *
  952. * Factorize JB columns among the columns A(J:N).
  953. *
  954. CALL CLAQP3RK( M, N_SUB, NRHS, IOFFSET, JB, ABSTOL,
  955. $ RELTOL, KP1, MAXC2NRM, A( 1, J ), LDA,
  956. $ DONE, JBF, MAXC2NRMK, RELMAXC2NRMK,
  957. $ JPIV( J ), TAU( J ),
  958. $ RWORK( J ), RWORK( N+J ),
  959. $ WORK( 1 ), WORK( JB+1 ),
  960. $ N+NRHS-J+1, IWORK, IINFO )
  961. *
  962. * Set INFO on the first occurence of Inf.
  963. *
  964. IF( IINFO.GT.N_SUB .AND. INFO.EQ.0 ) THEN
  965. INFO = 2*IOFFSET + IINFO
  966. END IF
  967. *
  968. IF( DONE ) THEN
  969. *
  970. * Either the submatrix is zero before the end of the
  971. * column block, or ABSTOL or RELTOL criterion is
  972. * satisfied before the end of the column block, we can
  973. * return from the routine. Perform the following before
  974. * returning:
  975. * a) Set the number of factorized columns K,
  976. * K = IOFFSET + JBF from the last call of blocked
  977. * routine.
  978. * NOTE: 1) MAXC2NRMK and RELMAXC2NRMK are returned
  979. * by the block factorization routine;
  980. * 2) The remaining TAUs are set to ZERO by the
  981. * block factorization routine.
  982. *
  983. K = IOFFSET + JBF
  984. *
  985. * Set INFO on the first occurrence of NaN, NaN takes
  986. * prcedence over Inf.
  987. *
  988. IF( IINFO.LE.N_SUB .AND. IINFO.GT.0 ) THEN
  989. INFO = IOFFSET + IINFO
  990. END IF
  991. *
  992. * Return from the routine.
  993. *
  994. WORK( 1 ) = CMPLX( LWKOPT )
  995. *
  996. RETURN
  997. *
  998. END IF
  999. *
  1000. J = J + JBF
  1001. *
  1002. END DO
  1003. *
  1004. END IF
  1005. *
  1006. * Use unblocked code to factor the last or only block.
  1007. * J = JMAX+1 means we factorized the maximum possible number of
  1008. * columns, that is in ELSE clause we need to compute
  1009. * the MAXC2NORM and RELMAXC2NORM to return after we processed
  1010. * the blocks.
  1011. *
  1012. IF( J.LE.JMAX ) THEN
  1013. *
  1014. * N_SUB is the number of columns in the submatrix;
  1015. * IOFFSET is the number of rows that should not be factorized.
  1016. *
  1017. N_SUB = N-J+1
  1018. IOFFSET = J-1
  1019. *
  1020. CALL CLAQP2RK( M, N_SUB, NRHS, IOFFSET, JMAX-J+1,
  1021. $ ABSTOL, RELTOL, KP1, MAXC2NRM, A( 1, J ), LDA,
  1022. $ KF, MAXC2NRMK, RELMAXC2NRMK, JPIV( J ),
  1023. $ TAU( J ), RWORK( J ), RWORK( N+J ),
  1024. $ WORK( 1 ), IINFO )
  1025. *
  1026. * ABSTOL or RELTOL criterion is satisfied when the number of
  1027. * the factorized columns KF is smaller then the number
  1028. * of columns JMAX-J+1 supplied to be factorized by the
  1029. * unblocked routine, we can return from
  1030. * the routine. Perform the following before returning:
  1031. * a) Set the number of factorized columns K,
  1032. * b) MAXC2NRMK and RELMAXC2NRMK are returned by the
  1033. * unblocked factorization routine above.
  1034. *
  1035. K = J - 1 + KF
  1036. *
  1037. * Set INFO on the first exception occurence.
  1038. *
  1039. * Set INFO on the first exception occurence of Inf or NaN,
  1040. * (NaN takes precedence over Inf).
  1041. *
  1042. IF( IINFO.GT.N_SUB .AND. INFO.EQ.0 ) THEN
  1043. INFO = 2*IOFFSET + IINFO
  1044. ELSE IF( IINFO.LE.N_SUB .AND. IINFO.GT.0 ) THEN
  1045. INFO = IOFFSET + IINFO
  1046. END IF
  1047. *
  1048. ELSE
  1049. *
  1050. * Compute the return values for blocked code.
  1051. *
  1052. * Set the number of factorized columns if the unblocked routine
  1053. * was not called.
  1054. *
  1055. K = JMAX
  1056. *
  1057. * If there exits a residual matrix after the blocked code:
  1058. * 1) compute the values of MAXC2NRMK, RELMAXC2NRMK of the
  1059. * residual matrix, otherwise set them to ZERO;
  1060. * 2) Set TAU(K+1:MINMN) to ZERO.
  1061. *
  1062. IF( K.LT.MINMN ) THEN
  1063. JMAXC2NRM = K + ISAMAX( N-K, RWORK( K+1 ), 1 )
  1064. MAXC2NRMK = RWORK( JMAXC2NRM )
  1065. IF( K.EQ.0 ) THEN
  1066. RELMAXC2NRMK = ONE
  1067. ELSE
  1068. RELMAXC2NRMK = MAXC2NRMK / MAXC2NRM
  1069. END IF
  1070. *
  1071. DO J = K + 1, MINMN
  1072. TAU( J ) = CZERO
  1073. END DO
  1074. *
  1075. ELSE
  1076. MAXC2NRMK = ZERO
  1077. RELMAXC2NRMK = ZERO
  1078. *
  1079. END IF
  1080. *
  1081. * END IF( J.LE.JMAX ) THEN
  1082. *
  1083. END IF
  1084. *
  1085. WORK( 1 ) = CMPLX( LWKOPT )
  1086. *
  1087. RETURN
  1088. *
  1089. * End of CGEQP3RK
  1090. *
  1091. END