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.

dgeqp3rk.f 39 kB

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