dgsvj0.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. /* dgsvj0.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Table of constant values */
  14. static integer c__1 = 1;
  15. static integer c__0 = 0;
  16. static doublereal c_b42 = 1.;
  17. /* Subroutine */ int _starpu_dgsvj0_(char *jobv, integer *m, integer *n, doublereal *
  18. a, integer *lda, doublereal *d__, doublereal *sva, integer *mv,
  19. doublereal *v, integer *ldv, doublereal *eps, doublereal *sfmin,
  20. doublereal *tol, integer *nsweep, doublereal *work, integer *lwork,
  21. integer *info)
  22. {
  23. /* System generated locals */
  24. integer a_dim1, a_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4, i__5,
  25. i__6;
  26. doublereal d__1, d__2;
  27. /* Builtin functions */
  28. double sqrt(doublereal), d_sign(doublereal *, doublereal *);
  29. /* Local variables */
  30. doublereal bigtheta;
  31. integer pskipped, i__, p, q;
  32. doublereal t, rootsfmin, cs, sn;
  33. integer ir1, jbc;
  34. doublereal big;
  35. integer kbl, igl, ibr, jgl, nbl, mvl;
  36. doublereal aapp, aapq, aaqq;
  37. extern doublereal _starpu_ddot_(integer *, doublereal *, integer *, doublereal *,
  38. integer *);
  39. integer ierr;
  40. doublereal aapp0;
  41. extern doublereal _starpu_dnrm2_(integer *, doublereal *, integer *);
  42. doublereal temp1, apoaq, aqoap;
  43. extern logical _starpu_lsame_(char *, char *);
  44. doublereal theta, small;
  45. extern /* Subroutine */ int _starpu_dcopy_(integer *, doublereal *, integer *,
  46. doublereal *, integer *);
  47. doublereal fastr[5];
  48. extern /* Subroutine */ int _starpu_dswap_(integer *, doublereal *, integer *,
  49. doublereal *, integer *);
  50. logical applv, rsvec;
  51. extern /* Subroutine */ int _starpu_daxpy_(integer *, doublereal *, doublereal *,
  52. integer *, doublereal *, integer *), _starpu_drotm_(integer *, doublereal
  53. *, integer *, doublereal *, integer *, doublereal *);
  54. logical rotok;
  55. extern /* Subroutine */ int _starpu_dlascl_(char *, integer *, integer *,
  56. doublereal *, doublereal *, integer *, integer *, doublereal *,
  57. integer *, integer *);
  58. extern integer _starpu_idamax_(integer *, doublereal *, integer *);
  59. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  60. integer ijblsk, swband, blskip;
  61. doublereal mxaapq;
  62. extern /* Subroutine */ int _starpu_dlassq_(integer *, doublereal *, integer *,
  63. doublereal *, doublereal *);
  64. doublereal thsign, mxsinj;
  65. integer emptsw, notrot, iswrot, lkahead;
  66. doublereal rootbig, rooteps;
  67. integer rowskip;
  68. doublereal roottol;
  69. /* -- LAPACK routine (version 3.2) -- */
  70. /* -- Contributed by Zlatko Drmac of the University of Zagreb and -- */
  71. /* -- Kresimir Veselic of the Fernuniversitaet Hagen -- */
  72. /* -- November 2008 -- */
  73. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  74. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  75. /* This routine is also part of SIGMA (version 1.23, October 23. 2008.) */
  76. /* SIGMA is a library of algorithms for highly accurate algorithms for */
  77. /* computation of SVD, PSVD, QSVD, (H,K)-SVD, and for solution of the */
  78. /* eigenvalue problems Hx = lambda M x, H M x = lambda x with H, M > 0. */
  79. /* Scalar Arguments */
  80. /* Array Arguments */
  81. /* .. */
  82. /* Purpose */
  83. /* ~~~~~~~ */
  84. /* DGSVJ0 is called from DGESVJ as a pre-processor and that is its main */
  85. /* purpose. It applies Jacobi rotations in the same way as DGESVJ does, but */
  86. /* it does not check convergence (stopping criterion). Few tuning */
  87. /* parameters (marked by [TP]) are available for the implementer. */
  88. /* Further details */
  89. /* ~~~~~~~~~~~~~~~ */
  90. /* DGSVJ0 is used just to enable SGESVJ to call a simplified version of */
  91. /* itself to work on a submatrix of the original matrix. */
  92. /* Contributors */
  93. /* ~~~~~~~~~~~~ */
  94. /* Zlatko Drmac (Zagreb, Croatia) and Kresimir Veselic (Hagen, Germany) */
  95. /* Bugs, Examples and Comments */
  96. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  97. /* Please report all bugs and send interesting test examples and comments to */
  98. /* drmac@math.hr. Thank you. */
  99. /* Arguments */
  100. /* ~~~~~~~~~ */
  101. /* JOBV (input) CHARACTER*1 */
  102. /* Specifies whether the output from this procedure is used */
  103. /* to compute the matrix V: */
  104. /* = 'V': the product of the Jacobi rotations is accumulated */
  105. /* by postmulyiplying the N-by-N array V. */
  106. /* (See the description of V.) */
  107. /* = 'A': the product of the Jacobi rotations is accumulated */
  108. /* by postmulyiplying the MV-by-N array V. */
  109. /* (See the descriptions of MV and V.) */
  110. /* = 'N': the Jacobi rotations are not accumulated. */
  111. /* M (input) INTEGER */
  112. /* The number of rows of the input matrix A. M >= 0. */
  113. /* N (input) INTEGER */
  114. /* The number of columns of the input matrix A. */
  115. /* M >= N >= 0. */
  116. /* A (input/output) REAL array, dimension (LDA,N) */
  117. /* On entry, M-by-N matrix A, such that A*diag(D) represents */
  118. /* the input matrix. */
  119. /* On exit, */
  120. /* A_onexit * D_onexit represents the input matrix A*diag(D) */
  121. /* post-multiplied by a sequence of Jacobi rotations, where the */
  122. /* rotation threshold and the total number of sweeps are given in */
  123. /* TOL and NSWEEP, respectively. */
  124. /* (See the descriptions of D, TOL and NSWEEP.) */
  125. /* LDA (input) INTEGER */
  126. /* The leading dimension of the array A. LDA >= max(1,M). */
  127. /* D (input/workspace/output) REAL array, dimension (N) */
  128. /* The array D accumulates the scaling factors from the fast scaled */
  129. /* Jacobi rotations. */
  130. /* On entry, A*diag(D) represents the input matrix. */
  131. /* On exit, A_onexit*diag(D_onexit) represents the input matrix */
  132. /* post-multiplied by a sequence of Jacobi rotations, where the */
  133. /* rotation threshold and the total number of sweeps are given in */
  134. /* TOL and NSWEEP, respectively. */
  135. /* (See the descriptions of A, TOL and NSWEEP.) */
  136. /* SVA (input/workspace/output) REAL array, dimension (N) */
  137. /* On entry, SVA contains the Euclidean norms of the columns of */
  138. /* the matrix A*diag(D). */
  139. /* On exit, SVA contains the Euclidean norms of the columns of */
  140. /* the matrix onexit*diag(D_onexit). */
  141. /* MV (input) INTEGER */
  142. /* If JOBV .EQ. 'A', then MV rows of V are post-multipled by a */
  143. /* sequence of Jacobi rotations. */
  144. /* If JOBV = 'N', then MV is not referenced. */
  145. /* V (input/output) REAL array, dimension (LDV,N) */
  146. /* If JOBV .EQ. 'V' then N rows of V are post-multipled by a */
  147. /* sequence of Jacobi rotations. */
  148. /* If JOBV .EQ. 'A' then MV rows of V are post-multipled by a */
  149. /* sequence of Jacobi rotations. */
  150. /* If JOBV = 'N', then V is not referenced. */
  151. /* LDV (input) INTEGER */
  152. /* The leading dimension of the array V, LDV >= 1. */
  153. /* If JOBV = 'V', LDV .GE. N. */
  154. /* If JOBV = 'A', LDV .GE. MV. */
  155. /* EPS (input) INTEGER */
  156. /* EPS = SLAMCH('Epsilon') */
  157. /* SFMIN (input) INTEGER */
  158. /* SFMIN = SLAMCH('Safe Minimum') */
  159. /* TOL (input) REAL */
  160. /* TOL is the threshold for Jacobi rotations. For a pair */
  161. /* A(:,p), A(:,q) of pivot columns, the Jacobi rotation is */
  162. /* applied only if DABS(COS(angle(A(:,p),A(:,q)))) .GT. TOL. */
  163. /* NSWEEP (input) INTEGER */
  164. /* NSWEEP is the number of sweeps of Jacobi rotations to be */
  165. /* performed. */
  166. /* WORK (workspace) REAL array, dimension LWORK. */
  167. /* LWORK (input) INTEGER */
  168. /* LWORK is the dimension of WORK. LWORK .GE. M. */
  169. /* INFO (output) INTEGER */
  170. /* = 0 : successful exit. */
  171. /* < 0 : if INFO = -i, then the i-th argument had an illegal value */
  172. /* Local Parameters */
  173. /* Local Scalars */
  174. /* Local Arrays */
  175. /* Intrinsic Functions */
  176. /* External Functions */
  177. /* External Subroutines */
  178. /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| */
  179. /* Parameter adjustments */
  180. --sva;
  181. --d__;
  182. a_dim1 = *lda;
  183. a_offset = 1 + a_dim1;
  184. a -= a_offset;
  185. v_dim1 = *ldv;
  186. v_offset = 1 + v_dim1;
  187. v -= v_offset;
  188. --work;
  189. /* Function Body */
  190. applv = _starpu_lsame_(jobv, "A");
  191. rsvec = _starpu_lsame_(jobv, "V");
  192. if (! (rsvec || applv || _starpu_lsame_(jobv, "N"))) {
  193. *info = -1;
  194. } else if (*m < 0) {
  195. *info = -2;
  196. } else if (*n < 0 || *n > *m) {
  197. *info = -3;
  198. } else if (*lda < *m) {
  199. *info = -5;
  200. } else if (*mv < 0) {
  201. *info = -8;
  202. } else if (*ldv < *m) {
  203. *info = -10;
  204. } else if (*tol <= *eps) {
  205. *info = -13;
  206. } else if (*nsweep < 0) {
  207. *info = -14;
  208. } else if (*lwork < *m) {
  209. *info = -16;
  210. } else {
  211. *info = 0;
  212. }
  213. /* #:( */
  214. if (*info != 0) {
  215. i__1 = -(*info);
  216. _starpu_xerbla_("DGSVJ0", &i__1);
  217. return 0;
  218. }
  219. if (rsvec) {
  220. mvl = *n;
  221. } else if (applv) {
  222. mvl = *mv;
  223. }
  224. rsvec = rsvec || applv;
  225. rooteps = sqrt(*eps);
  226. rootsfmin = sqrt(*sfmin);
  227. small = *sfmin / *eps;
  228. big = 1. / *sfmin;
  229. rootbig = 1. / rootsfmin;
  230. bigtheta = 1. / rooteps;
  231. roottol = sqrt(*tol);
  232. /* -#- Row-cyclic Jacobi SVD algorithm with column pivoting -#- */
  233. emptsw = *n * (*n - 1) / 2;
  234. notrot = 0;
  235. fastr[0] = 0.;
  236. /* -#- Row-cyclic pivot strategy with de Rijk's pivoting -#- */
  237. swband = 0;
  238. /* [TP] SWBAND is a tuning parameter. It is meaningful and effective */
  239. /* if SGESVJ is used as a computational routine in the preconditioned */
  240. /* Jacobi SVD algorithm SGESVJ. For sweeps i=1:SWBAND the procedure */
  241. /* ...... */
  242. kbl = min(8,*n);
  243. /* [TP] KBL is a tuning parameter that defines the tile size in the */
  244. /* tiling of the p-q loops of pivot pairs. In general, an optimal */
  245. /* value of KBL depends on the matrix dimensions and on the */
  246. /* parameters of the computer's memory. */
  247. nbl = *n / kbl;
  248. if (nbl * kbl != *n) {
  249. ++nbl;
  250. }
  251. /* Computing 2nd power */
  252. i__1 = kbl;
  253. blskip = i__1 * i__1 + 1;
  254. /* [TP] BLKSKIP is a tuning parameter that depends on SWBAND and KBL. */
  255. rowskip = min(5,kbl);
  256. /* [TP] ROWSKIP is a tuning parameter. */
  257. lkahead = 1;
  258. /* [TP] LKAHEAD is a tuning parameter. */
  259. swband = 0;
  260. pskipped = 0;
  261. i__1 = *nsweep;
  262. for (i__ = 1; i__ <= i__1; ++i__) {
  263. /* .. go go go ... */
  264. mxaapq = 0.;
  265. mxsinj = 0.;
  266. iswrot = 0;
  267. notrot = 0;
  268. pskipped = 0;
  269. i__2 = nbl;
  270. for (ibr = 1; ibr <= i__2; ++ibr) {
  271. igl = (ibr - 1) * kbl + 1;
  272. /* Computing MIN */
  273. i__4 = lkahead, i__5 = nbl - ibr;
  274. i__3 = min(i__4,i__5);
  275. for (ir1 = 0; ir1 <= i__3; ++ir1) {
  276. igl += ir1 * kbl;
  277. /* Computing MIN */
  278. i__5 = igl + kbl - 1, i__6 = *n - 1;
  279. i__4 = min(i__5,i__6);
  280. for (p = igl; p <= i__4; ++p) {
  281. /* .. de Rijk's pivoting */
  282. i__5 = *n - p + 1;
  283. q = _starpu_idamax_(&i__5, &sva[p], &c__1) + p - 1;
  284. if (p != q) {
  285. _starpu_dswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 +
  286. 1], &c__1);
  287. if (rsvec) {
  288. _starpu_dswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  289. v_dim1 + 1], &c__1);
  290. }
  291. temp1 = sva[p];
  292. sva[p] = sva[q];
  293. sva[q] = temp1;
  294. temp1 = d__[p];
  295. d__[p] = d__[q];
  296. d__[q] = temp1;
  297. }
  298. if (ir1 == 0) {
  299. /* Column norms are periodically updated by explicit */
  300. /* norm computation. */
  301. /* Caveat: */
  302. /* Some BLAS implementations compute DNRM2(M,A(1,p),1) */
  303. /* as DSQRT(DDOT(M,A(1,p),1,A(1,p),1)), which may result in */
  304. /* overflow for ||A(:,p)||_2 > DSQRT(overflow_threshold), and */
  305. /* undeflow for ||A(:,p)||_2 < DSQRT(underflow_threshold). */
  306. /* Hence, DNRM2 cannot be trusted, not even in the case when */
  307. /* the true norm is far from the under(over)flow boundaries. */
  308. /* If properly implemented DNRM2 is available, the IF-THEN-ELSE */
  309. /* below should read "AAPP = DNRM2( M, A(1,p), 1 ) * D(p)". */
  310. if (sva[p] < rootbig && sva[p] > rootsfmin) {
  311. sva[p] = _starpu_dnrm2_(m, &a[p * a_dim1 + 1], &c__1) *
  312. d__[p];
  313. } else {
  314. temp1 = 0.;
  315. aapp = 0.;
  316. _starpu_dlassq_(m, &a[p * a_dim1 + 1], &c__1, &temp1, &
  317. aapp);
  318. sva[p] = temp1 * sqrt(aapp) * d__[p];
  319. }
  320. aapp = sva[p];
  321. } else {
  322. aapp = sva[p];
  323. }
  324. if (aapp > 0.) {
  325. pskipped = 0;
  326. /* Computing MIN */
  327. i__6 = igl + kbl - 1;
  328. i__5 = min(i__6,*n);
  329. for (q = p + 1; q <= i__5; ++q) {
  330. aaqq = sva[q];
  331. if (aaqq > 0.) {
  332. aapp0 = aapp;
  333. if (aaqq >= 1.) {
  334. rotok = small * aapp <= aaqq;
  335. if (aapp < big / aaqq) {
  336. aapq = _starpu_ddot_(m, &a[p * a_dim1 + 1], &
  337. c__1, &a[q * a_dim1 + 1], &
  338. c__1) * d__[p] * d__[q] /
  339. aaqq / aapp;
  340. } else {
  341. _starpu_dcopy_(m, &a[p * a_dim1 + 1], &c__1, &
  342. work[1], &c__1);
  343. _starpu_dlascl_("G", &c__0, &c__0, &aapp, &
  344. d__[p], m, &c__1, &work[1],
  345. lda, &ierr);
  346. aapq = _starpu_ddot_(m, &work[1], &c__1, &a[q
  347. * a_dim1 + 1], &c__1) * d__[q]
  348. / aaqq;
  349. }
  350. } else {
  351. rotok = aapp <= aaqq / small;
  352. if (aapp > small / aaqq) {
  353. aapq = _starpu_ddot_(m, &a[p * a_dim1 + 1], &
  354. c__1, &a[q * a_dim1 + 1], &
  355. c__1) * d__[p] * d__[q] /
  356. aaqq / aapp;
  357. } else {
  358. _starpu_dcopy_(m, &a[q * a_dim1 + 1], &c__1, &
  359. work[1], &c__1);
  360. _starpu_dlascl_("G", &c__0, &c__0, &aaqq, &
  361. d__[q], m, &c__1, &work[1],
  362. lda, &ierr);
  363. aapq = _starpu_ddot_(m, &work[1], &c__1, &a[p
  364. * a_dim1 + 1], &c__1) * d__[p]
  365. / aapp;
  366. }
  367. }
  368. /* Computing MAX */
  369. d__1 = mxaapq, d__2 = abs(aapq);
  370. mxaapq = max(d__1,d__2);
  371. /* TO rotate or NOT to rotate, THAT is the question ... */
  372. if (abs(aapq) > *tol) {
  373. /* .. rotate */
  374. /* ROTATED = ROTATED + ONE */
  375. if (ir1 == 0) {
  376. notrot = 0;
  377. pskipped = 0;
  378. ++iswrot;
  379. }
  380. if (rotok) {
  381. aqoap = aaqq / aapp;
  382. apoaq = aapp / aaqq;
  383. theta = (d__1 = aqoap - apoaq, abs(
  384. d__1)) * -.5 / aapq;
  385. if (abs(theta) > bigtheta) {
  386. t = .5 / theta;
  387. fastr[2] = t * d__[p] / d__[q];
  388. fastr[3] = -t * d__[q] / d__[p];
  389. _starpu_drotm_(m, &a[p * a_dim1 + 1], &
  390. c__1, &a[q * a_dim1 + 1],
  391. &c__1, fastr);
  392. if (rsvec) {
  393. _starpu_drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  394. v_dim1 + 1], &c__1, fastr);
  395. }
  396. /* Computing MAX */
  397. d__1 = 0., d__2 = t * apoaq *
  398. aapq + 1.;
  399. sva[q] = aaqq * sqrt((max(d__1,
  400. d__2)));
  401. aapp *= sqrt(1. - t * aqoap *
  402. aapq);
  403. /* Computing MAX */
  404. d__1 = mxsinj, d__2 = abs(t);
  405. mxsinj = max(d__1,d__2);
  406. } else {
  407. /* .. choose correct signum for THETA and rotate */
  408. thsign = -d_sign(&c_b42, &aapq);
  409. t = 1. / (theta + thsign * sqrt(
  410. theta * theta + 1.));
  411. cs = sqrt(1. / (t * t + 1.));
  412. sn = t * cs;
  413. /* Computing MAX */
  414. d__1 = mxsinj, d__2 = abs(sn);
  415. mxsinj = max(d__1,d__2);
  416. /* Computing MAX */
  417. d__1 = 0., d__2 = t * apoaq *
  418. aapq + 1.;
  419. sva[q] = aaqq * sqrt((max(d__1,
  420. d__2)));
  421. /* Computing MAX */
  422. d__1 = 0., d__2 = 1. - t * aqoap *
  423. aapq;
  424. aapp *= sqrt((max(d__1,d__2)));
  425. apoaq = d__[p] / d__[q];
  426. aqoap = d__[q] / d__[p];
  427. if (d__[p] >= 1.) {
  428. if (d__[q] >= 1.) {
  429. fastr[2] = t * apoaq;
  430. fastr[3] = -t * aqoap;
  431. d__[p] *= cs;
  432. d__[q] *= cs;
  433. _starpu_drotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q *
  434. a_dim1 + 1], &c__1, fastr);
  435. if (rsvec) {
  436. _starpu_drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
  437. q * v_dim1 + 1], &c__1, fastr);
  438. }
  439. } else {
  440. d__1 = -t * aqoap;
  441. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
  442. p * a_dim1 + 1], &c__1);
  443. d__1 = cs * sn * apoaq;
  444. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
  445. q * a_dim1 + 1], &c__1);
  446. d__[p] *= cs;
  447. d__[q] /= cs;
  448. if (rsvec) {
  449. d__1 = -t * aqoap;
  450. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
  451. c__1, &v[p * v_dim1 + 1], &c__1);
  452. d__1 = cs * sn * apoaq;
  453. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
  454. c__1, &v[q * v_dim1 + 1], &c__1);
  455. }
  456. }
  457. } else {
  458. if (d__[q] >= 1.) {
  459. d__1 = t * apoaq;
  460. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
  461. q * a_dim1 + 1], &c__1);
  462. d__1 = -cs * sn * aqoap;
  463. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
  464. p * a_dim1 + 1], &c__1);
  465. d__[p] /= cs;
  466. d__[q] *= cs;
  467. if (rsvec) {
  468. d__1 = t * apoaq;
  469. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
  470. c__1, &v[q * v_dim1 + 1], &c__1);
  471. d__1 = -cs * sn * aqoap;
  472. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
  473. c__1, &v[p * v_dim1 + 1], &c__1);
  474. }
  475. } else {
  476. if (d__[p] >= d__[q]) {
  477. d__1 = -t * aqoap;
  478. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
  479. &a[p * a_dim1 + 1], &c__1);
  480. d__1 = cs * sn * apoaq;
  481. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
  482. &a[q * a_dim1 + 1], &c__1);
  483. d__[p] *= cs;
  484. d__[q] /= cs;
  485. if (rsvec) {
  486. d__1 = -t * aqoap;
  487. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
  488. &c__1, &v[p * v_dim1 + 1], &
  489. c__1);
  490. d__1 = cs * sn * apoaq;
  491. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
  492. &c__1, &v[q * v_dim1 + 1], &
  493. c__1);
  494. }
  495. } else {
  496. d__1 = t * apoaq;
  497. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
  498. &a[q * a_dim1 + 1], &c__1);
  499. d__1 = -cs * sn * aqoap;
  500. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
  501. &a[p * a_dim1 + 1], &c__1);
  502. d__[p] /= cs;
  503. d__[q] *= cs;
  504. if (rsvec) {
  505. d__1 = t * apoaq;
  506. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
  507. &c__1, &v[q * v_dim1 + 1], &
  508. c__1);
  509. d__1 = -cs * sn * aqoap;
  510. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
  511. &c__1, &v[p * v_dim1 + 1], &
  512. c__1);
  513. }
  514. }
  515. }
  516. }
  517. }
  518. } else {
  519. /* .. have to use modified Gram-Schmidt like transformation */
  520. _starpu_dcopy_(m, &a[p * a_dim1 + 1], &c__1, &
  521. work[1], &c__1);
  522. _starpu_dlascl_("G", &c__0, &c__0, &aapp, &
  523. c_b42, m, &c__1, &work[1],
  524. lda, &ierr);
  525. _starpu_dlascl_("G", &c__0, &c__0, &aaqq, &
  526. c_b42, m, &c__1, &a[q *
  527. a_dim1 + 1], lda, &ierr);
  528. temp1 = -aapq * d__[p] / d__[q];
  529. _starpu_daxpy_(m, &temp1, &work[1], &c__1, &a[
  530. q * a_dim1 + 1], &c__1);
  531. _starpu_dlascl_("G", &c__0, &c__0, &c_b42, &
  532. aaqq, m, &c__1, &a[q * a_dim1
  533. + 1], lda, &ierr);
  534. /* Computing MAX */
  535. d__1 = 0., d__2 = 1. - aapq * aapq;
  536. sva[q] = aaqq * sqrt((max(d__1,d__2)))
  537. ;
  538. mxsinj = max(mxsinj,*sfmin);
  539. }
  540. /* END IF ROTOK THEN ... ELSE */
  541. /* In the case of cancellation in updating SVA(q), SVA(p) */
  542. /* recompute SVA(q), SVA(p). */
  543. /* Computing 2nd power */
  544. d__1 = sva[q] / aaqq;
  545. if (d__1 * d__1 <= rooteps) {
  546. if (aaqq < rootbig && aaqq >
  547. rootsfmin) {
  548. sva[q] = _starpu_dnrm2_(m, &a[q * a_dim1
  549. + 1], &c__1) * d__[q];
  550. } else {
  551. t = 0.;
  552. aaqq = 0.;
  553. _starpu_dlassq_(m, &a[q * a_dim1 + 1], &
  554. c__1, &t, &aaqq);
  555. sva[q] = t * sqrt(aaqq) * d__[q];
  556. }
  557. }
  558. if (aapp / aapp0 <= rooteps) {
  559. if (aapp < rootbig && aapp >
  560. rootsfmin) {
  561. aapp = _starpu_dnrm2_(m, &a[p * a_dim1 +
  562. 1], &c__1) * d__[p];
  563. } else {
  564. t = 0.;
  565. aapp = 0.;
  566. _starpu_dlassq_(m, &a[p * a_dim1 + 1], &
  567. c__1, &t, &aapp);
  568. aapp = t * sqrt(aapp) * d__[p];
  569. }
  570. sva[p] = aapp;
  571. }
  572. } else {
  573. /* A(:,p) and A(:,q) already numerically orthogonal */
  574. if (ir1 == 0) {
  575. ++notrot;
  576. }
  577. ++pskipped;
  578. }
  579. } else {
  580. /* A(:,q) is zero column */
  581. if (ir1 == 0) {
  582. ++notrot;
  583. }
  584. ++pskipped;
  585. }
  586. if (i__ <= swband && pskipped > rowskip) {
  587. if (ir1 == 0) {
  588. aapp = -aapp;
  589. }
  590. notrot = 0;
  591. goto L2103;
  592. }
  593. /* L2002: */
  594. }
  595. /* END q-LOOP */
  596. L2103:
  597. /* bailed out of q-loop */
  598. sva[p] = aapp;
  599. } else {
  600. sva[p] = aapp;
  601. if (ir1 == 0 && aapp == 0.) {
  602. /* Computing MIN */
  603. i__5 = igl + kbl - 1;
  604. notrot = notrot + min(i__5,*n) - p;
  605. }
  606. }
  607. /* L2001: */
  608. }
  609. /* end of the p-loop */
  610. /* end of doing the block ( ibr, ibr ) */
  611. /* L1002: */
  612. }
  613. /* end of ir1-loop */
  614. /* ........................................................ */
  615. /* ... go to the off diagonal blocks */
  616. igl = (ibr - 1) * kbl + 1;
  617. i__3 = nbl;
  618. for (jbc = ibr + 1; jbc <= i__3; ++jbc) {
  619. jgl = (jbc - 1) * kbl + 1;
  620. /* doing the block at ( ibr, jbc ) */
  621. ijblsk = 0;
  622. /* Computing MIN */
  623. i__5 = igl + kbl - 1;
  624. i__4 = min(i__5,*n);
  625. for (p = igl; p <= i__4; ++p) {
  626. aapp = sva[p];
  627. if (aapp > 0.) {
  628. pskipped = 0;
  629. /* Computing MIN */
  630. i__6 = jgl + kbl - 1;
  631. i__5 = min(i__6,*n);
  632. for (q = jgl; q <= i__5; ++q) {
  633. aaqq = sva[q];
  634. if (aaqq > 0.) {
  635. aapp0 = aapp;
  636. /* -#- M x 2 Jacobi SVD -#- */
  637. /* -#- Safe Gram matrix computation -#- */
  638. if (aaqq >= 1.) {
  639. if (aapp >= aaqq) {
  640. rotok = small * aapp <= aaqq;
  641. } else {
  642. rotok = small * aaqq <= aapp;
  643. }
  644. if (aapp < big / aaqq) {
  645. aapq = _starpu_ddot_(m, &a[p * a_dim1 + 1], &
  646. c__1, &a[q * a_dim1 + 1], &
  647. c__1) * d__[p] * d__[q] /
  648. aaqq / aapp;
  649. } else {
  650. _starpu_dcopy_(m, &a[p * a_dim1 + 1], &c__1, &
  651. work[1], &c__1);
  652. _starpu_dlascl_("G", &c__0, &c__0, &aapp, &
  653. d__[p], m, &c__1, &work[1],
  654. lda, &ierr);
  655. aapq = _starpu_ddot_(m, &work[1], &c__1, &a[q
  656. * a_dim1 + 1], &c__1) * d__[q]
  657. / aaqq;
  658. }
  659. } else {
  660. if (aapp >= aaqq) {
  661. rotok = aapp <= aaqq / small;
  662. } else {
  663. rotok = aaqq <= aapp / small;
  664. }
  665. if (aapp > small / aaqq) {
  666. aapq = _starpu_ddot_(m, &a[p * a_dim1 + 1], &
  667. c__1, &a[q * a_dim1 + 1], &
  668. c__1) * d__[p] * d__[q] /
  669. aaqq / aapp;
  670. } else {
  671. _starpu_dcopy_(m, &a[q * a_dim1 + 1], &c__1, &
  672. work[1], &c__1);
  673. _starpu_dlascl_("G", &c__0, &c__0, &aaqq, &
  674. d__[q], m, &c__1, &work[1],
  675. lda, &ierr);
  676. aapq = _starpu_ddot_(m, &work[1], &c__1, &a[p
  677. * a_dim1 + 1], &c__1) * d__[p]
  678. / aapp;
  679. }
  680. }
  681. /* Computing MAX */
  682. d__1 = mxaapq, d__2 = abs(aapq);
  683. mxaapq = max(d__1,d__2);
  684. /* TO rotate or NOT to rotate, THAT is the question ... */
  685. if (abs(aapq) > *tol) {
  686. notrot = 0;
  687. /* ROTATED = ROTATED + 1 */
  688. pskipped = 0;
  689. ++iswrot;
  690. if (rotok) {
  691. aqoap = aaqq / aapp;
  692. apoaq = aapp / aaqq;
  693. theta = (d__1 = aqoap - apoaq, abs(
  694. d__1)) * -.5 / aapq;
  695. if (aaqq > aapp0) {
  696. theta = -theta;
  697. }
  698. if (abs(theta) > bigtheta) {
  699. t = .5 / theta;
  700. fastr[2] = t * d__[p] / d__[q];
  701. fastr[3] = -t * d__[q] / d__[p];
  702. _starpu_drotm_(m, &a[p * a_dim1 + 1], &
  703. c__1, &a[q * a_dim1 + 1],
  704. &c__1, fastr);
  705. if (rsvec) {
  706. _starpu_drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  707. v_dim1 + 1], &c__1, fastr);
  708. }
  709. /* Computing MAX */
  710. d__1 = 0., d__2 = t * apoaq *
  711. aapq + 1.;
  712. sva[q] = aaqq * sqrt((max(d__1,
  713. d__2)));
  714. /* Computing MAX */
  715. d__1 = 0., d__2 = 1. - t * aqoap *
  716. aapq;
  717. aapp *= sqrt((max(d__1,d__2)));
  718. /* Computing MAX */
  719. d__1 = mxsinj, d__2 = abs(t);
  720. mxsinj = max(d__1,d__2);
  721. } else {
  722. /* .. choose correct signum for THETA and rotate */
  723. thsign = -d_sign(&c_b42, &aapq);
  724. if (aaqq > aapp0) {
  725. thsign = -thsign;
  726. }
  727. t = 1. / (theta + thsign * sqrt(
  728. theta * theta + 1.));
  729. cs = sqrt(1. / (t * t + 1.));
  730. sn = t * cs;
  731. /* Computing MAX */
  732. d__1 = mxsinj, d__2 = abs(sn);
  733. mxsinj = max(d__1,d__2);
  734. /* Computing MAX */
  735. d__1 = 0., d__2 = t * apoaq *
  736. aapq + 1.;
  737. sva[q] = aaqq * sqrt((max(d__1,
  738. d__2)));
  739. aapp *= sqrt(1. - t * aqoap *
  740. aapq);
  741. apoaq = d__[p] / d__[q];
  742. aqoap = d__[q] / d__[p];
  743. if (d__[p] >= 1.) {
  744. if (d__[q] >= 1.) {
  745. fastr[2] = t * apoaq;
  746. fastr[3] = -t * aqoap;
  747. d__[p] *= cs;
  748. d__[q] *= cs;
  749. _starpu_drotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q *
  750. a_dim1 + 1], &c__1, fastr);
  751. if (rsvec) {
  752. _starpu_drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
  753. q * v_dim1 + 1], &c__1, fastr);
  754. }
  755. } else {
  756. d__1 = -t * aqoap;
  757. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
  758. p * a_dim1 + 1], &c__1);
  759. d__1 = cs * sn * apoaq;
  760. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
  761. q * a_dim1 + 1], &c__1);
  762. if (rsvec) {
  763. d__1 = -t * aqoap;
  764. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
  765. c__1, &v[p * v_dim1 + 1], &c__1);
  766. d__1 = cs * sn * apoaq;
  767. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
  768. c__1, &v[q * v_dim1 + 1], &c__1);
  769. }
  770. d__[p] *= cs;
  771. d__[q] /= cs;
  772. }
  773. } else {
  774. if (d__[q] >= 1.) {
  775. d__1 = t * apoaq;
  776. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
  777. q * a_dim1 + 1], &c__1);
  778. d__1 = -cs * sn * aqoap;
  779. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
  780. p * a_dim1 + 1], &c__1);
  781. if (rsvec) {
  782. d__1 = t * apoaq;
  783. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
  784. c__1, &v[q * v_dim1 + 1], &c__1);
  785. d__1 = -cs * sn * aqoap;
  786. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
  787. c__1, &v[p * v_dim1 + 1], &c__1);
  788. }
  789. d__[p] /= cs;
  790. d__[q] *= cs;
  791. } else {
  792. if (d__[p] >= d__[q]) {
  793. d__1 = -t * aqoap;
  794. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
  795. &a[p * a_dim1 + 1], &c__1);
  796. d__1 = cs * sn * apoaq;
  797. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
  798. &a[q * a_dim1 + 1], &c__1);
  799. d__[p] *= cs;
  800. d__[q] /= cs;
  801. if (rsvec) {
  802. d__1 = -t * aqoap;
  803. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
  804. &c__1, &v[p * v_dim1 + 1], &
  805. c__1);
  806. d__1 = cs * sn * apoaq;
  807. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
  808. &c__1, &v[q * v_dim1 + 1], &
  809. c__1);
  810. }
  811. } else {
  812. d__1 = t * apoaq;
  813. _starpu_daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
  814. &a[q * a_dim1 + 1], &c__1);
  815. d__1 = -cs * sn * aqoap;
  816. _starpu_daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
  817. &a[p * a_dim1 + 1], &c__1);
  818. d__[p] /= cs;
  819. d__[q] *= cs;
  820. if (rsvec) {
  821. d__1 = t * apoaq;
  822. _starpu_daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
  823. &c__1, &v[q * v_dim1 + 1], &
  824. c__1);
  825. d__1 = -cs * sn * aqoap;
  826. _starpu_daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
  827. &c__1, &v[p * v_dim1 + 1], &
  828. c__1);
  829. }
  830. }
  831. }
  832. }
  833. }
  834. } else {
  835. if (aapp > aaqq) {
  836. _starpu_dcopy_(m, &a[p * a_dim1 + 1], &
  837. c__1, &work[1], &c__1);
  838. _starpu_dlascl_("G", &c__0, &c__0, &aapp,
  839. &c_b42, m, &c__1, &work[1]
  840. , lda, &ierr);
  841. _starpu_dlascl_("G", &c__0, &c__0, &aaqq,
  842. &c_b42, m, &c__1, &a[q *
  843. a_dim1 + 1], lda, &ierr);
  844. temp1 = -aapq * d__[p] / d__[q];
  845. _starpu_daxpy_(m, &temp1, &work[1], &c__1,
  846. &a[q * a_dim1 + 1], &
  847. c__1);
  848. _starpu_dlascl_("G", &c__0, &c__0, &c_b42,
  849. &aaqq, m, &c__1, &a[q *
  850. a_dim1 + 1], lda, &ierr);
  851. /* Computing MAX */
  852. d__1 = 0., d__2 = 1. - aapq *
  853. aapq;
  854. sva[q] = aaqq * sqrt((max(d__1,
  855. d__2)));
  856. mxsinj = max(mxsinj,*sfmin);
  857. } else {
  858. _starpu_dcopy_(m, &a[q * a_dim1 + 1], &
  859. c__1, &work[1], &c__1);
  860. _starpu_dlascl_("G", &c__0, &c__0, &aaqq,
  861. &c_b42, m, &c__1, &work[1]
  862. , lda, &ierr);
  863. _starpu_dlascl_("G", &c__0, &c__0, &aapp,
  864. &c_b42, m, &c__1, &a[p *
  865. a_dim1 + 1], lda, &ierr);
  866. temp1 = -aapq * d__[q] / d__[p];
  867. _starpu_daxpy_(m, &temp1, &work[1], &c__1,
  868. &a[p * a_dim1 + 1], &
  869. c__1);
  870. _starpu_dlascl_("G", &c__0, &c__0, &c_b42,
  871. &aapp, m, &c__1, &a[p *
  872. a_dim1 + 1], lda, &ierr);
  873. /* Computing MAX */
  874. d__1 = 0., d__2 = 1. - aapq *
  875. aapq;
  876. sva[p] = aapp * sqrt((max(d__1,
  877. d__2)));
  878. mxsinj = max(mxsinj,*sfmin);
  879. }
  880. }
  881. /* END IF ROTOK THEN ... ELSE */
  882. /* In the case of cancellation in updating SVA(q) */
  883. /* .. recompute SVA(q) */
  884. /* Computing 2nd power */
  885. d__1 = sva[q] / aaqq;
  886. if (d__1 * d__1 <= rooteps) {
  887. if (aaqq < rootbig && aaqq >
  888. rootsfmin) {
  889. sva[q] = _starpu_dnrm2_(m, &a[q * a_dim1
  890. + 1], &c__1) * d__[q];
  891. } else {
  892. t = 0.;
  893. aaqq = 0.;
  894. _starpu_dlassq_(m, &a[q * a_dim1 + 1], &
  895. c__1, &t, &aaqq);
  896. sva[q] = t * sqrt(aaqq) * d__[q];
  897. }
  898. }
  899. /* Computing 2nd power */
  900. d__1 = aapp / aapp0;
  901. if (d__1 * d__1 <= rooteps) {
  902. if (aapp < rootbig && aapp >
  903. rootsfmin) {
  904. aapp = _starpu_dnrm2_(m, &a[p * a_dim1 +
  905. 1], &c__1) * d__[p];
  906. } else {
  907. t = 0.;
  908. aapp = 0.;
  909. _starpu_dlassq_(m, &a[p * a_dim1 + 1], &
  910. c__1, &t, &aapp);
  911. aapp = t * sqrt(aapp) * d__[p];
  912. }
  913. sva[p] = aapp;
  914. }
  915. /* end of OK rotation */
  916. } else {
  917. ++notrot;
  918. ++pskipped;
  919. ++ijblsk;
  920. }
  921. } else {
  922. ++notrot;
  923. ++pskipped;
  924. ++ijblsk;
  925. }
  926. if (i__ <= swband && ijblsk >= blskip) {
  927. sva[p] = aapp;
  928. notrot = 0;
  929. goto L2011;
  930. }
  931. if (i__ <= swband && pskipped > rowskip) {
  932. aapp = -aapp;
  933. notrot = 0;
  934. goto L2203;
  935. }
  936. /* L2200: */
  937. }
  938. /* end of the q-loop */
  939. L2203:
  940. sva[p] = aapp;
  941. } else {
  942. if (aapp == 0.) {
  943. /* Computing MIN */
  944. i__5 = jgl + kbl - 1;
  945. notrot = notrot + min(i__5,*n) - jgl + 1;
  946. }
  947. if (aapp < 0.) {
  948. notrot = 0;
  949. }
  950. }
  951. /* L2100: */
  952. }
  953. /* end of the p-loop */
  954. /* L2010: */
  955. }
  956. /* end of the jbc-loop */
  957. L2011:
  958. /* 2011 bailed out of the jbc-loop */
  959. /* Computing MIN */
  960. i__4 = igl + kbl - 1;
  961. i__3 = min(i__4,*n);
  962. for (p = igl; p <= i__3; ++p) {
  963. sva[p] = (d__1 = sva[p], abs(d__1));
  964. /* L2012: */
  965. }
  966. /* L2000: */
  967. }
  968. /* 2000 :: end of the ibr-loop */
  969. /* .. update SVA(N) */
  970. if (sva[*n] < rootbig && sva[*n] > rootsfmin) {
  971. sva[*n] = _starpu_dnrm2_(m, &a[*n * a_dim1 + 1], &c__1) * d__[*n];
  972. } else {
  973. t = 0.;
  974. aapp = 0.;
  975. _starpu_dlassq_(m, &a[*n * a_dim1 + 1], &c__1, &t, &aapp);
  976. sva[*n] = t * sqrt(aapp) * d__[*n];
  977. }
  978. /* Additional steering devices */
  979. if (i__ < swband && (mxaapq <= roottol || iswrot <= *n)) {
  980. swband = i__;
  981. }
  982. if (i__ > swband + 1 && mxaapq < (doublereal) (*n) * *tol && (
  983. doublereal) (*n) * mxaapq * mxsinj < *tol) {
  984. goto L1994;
  985. }
  986. if (notrot >= emptsw) {
  987. goto L1994;
  988. }
  989. /* L1993: */
  990. }
  991. /* end i=1:NSWEEP loop */
  992. /* #:) Reaching this point means that the procedure has comleted the given */
  993. /* number of iterations. */
  994. *info = *nsweep - 1;
  995. goto L1995;
  996. L1994:
  997. /* #:) Reaching this point means that during the i-th sweep all pivots were */
  998. /* below the given tolerance, causing early exit. */
  999. *info = 0;
  1000. /* #:) INFO = 0 confirms successful iterations. */
  1001. L1995:
  1002. /* Sort the vector D. */
  1003. i__1 = *n - 1;
  1004. for (p = 1; p <= i__1; ++p) {
  1005. i__2 = *n - p + 1;
  1006. q = _starpu_idamax_(&i__2, &sva[p], &c__1) + p - 1;
  1007. if (p != q) {
  1008. temp1 = sva[p];
  1009. sva[p] = sva[q];
  1010. sva[q] = temp1;
  1011. temp1 = d__[p];
  1012. d__[p] = d__[q];
  1013. d__[q] = temp1;
  1014. _starpu_dswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 + 1], &c__1);
  1015. if (rsvec) {
  1016. _starpu_dswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * v_dim1 + 1], &
  1017. c__1);
  1018. }
  1019. }
  1020. /* L5991: */
  1021. }
  1022. return 0;
  1023. /* .. */
  1024. /* .. END OF DGSVJ0 */
  1025. /* .. */
  1026. } /* _starpu_dgsvj0_ */