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.

clalsa.c 34 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. #if defined(_WIN64)
  18. typedef long long BLASLONG;
  19. typedef unsigned long long BLASULONG;
  20. #else
  21. typedef long BLASLONG;
  22. typedef unsigned long BLASULONG;
  23. #endif
  24. #ifdef LAPACK_ILP64
  25. typedef BLASLONG blasint;
  26. #if defined(_WIN64)
  27. #define blasabs(x) llabs(x)
  28. #else
  29. #define blasabs(x) labs(x)
  30. #endif
  31. #else
  32. typedef int blasint;
  33. #define blasabs(x) abs(x)
  34. #endif
  35. typedef blasint integer;
  36. typedef unsigned int uinteger;
  37. typedef char *address;
  38. typedef short int shortint;
  39. typedef float real;
  40. typedef double doublereal;
  41. typedef struct { real r, i; } complex;
  42. typedef struct { doublereal r, i; } doublecomplex;
  43. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  44. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  46. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  47. #define pCf(z) (*_pCf(z))
  48. #define pCd(z) (*_pCd(z))
  49. typedef int logical;
  50. typedef short int shortlogical;
  51. typedef char logical1;
  52. typedef char integer1;
  53. #define TRUE_ (1)
  54. #define FALSE_ (0)
  55. /* Extern is for use with -E */
  56. #ifndef Extern
  57. #define Extern extern
  58. #endif
  59. /* I/O stuff */
  60. typedef int flag;
  61. typedef int ftnlen;
  62. typedef int ftnint;
  63. /*external read, write*/
  64. typedef struct
  65. { flag cierr;
  66. ftnint ciunit;
  67. flag ciend;
  68. char *cifmt;
  69. ftnint cirec;
  70. } cilist;
  71. /*internal read, write*/
  72. typedef struct
  73. { flag icierr;
  74. char *iciunit;
  75. flag iciend;
  76. char *icifmt;
  77. ftnint icirlen;
  78. ftnint icirnum;
  79. } icilist;
  80. /*open*/
  81. typedef struct
  82. { flag oerr;
  83. ftnint ounit;
  84. char *ofnm;
  85. ftnlen ofnmlen;
  86. char *osta;
  87. char *oacc;
  88. char *ofm;
  89. ftnint orl;
  90. char *oblnk;
  91. } olist;
  92. /*close*/
  93. typedef struct
  94. { flag cerr;
  95. ftnint cunit;
  96. char *csta;
  97. } cllist;
  98. /*rewind, backspace, endfile*/
  99. typedef struct
  100. { flag aerr;
  101. ftnint aunit;
  102. } alist;
  103. /* inquire */
  104. typedef struct
  105. { flag inerr;
  106. ftnint inunit;
  107. char *infile;
  108. ftnlen infilen;
  109. ftnint *inex; /*parameters in standard's order*/
  110. ftnint *inopen;
  111. ftnint *innum;
  112. ftnint *innamed;
  113. char *inname;
  114. ftnlen innamlen;
  115. char *inacc;
  116. ftnlen inacclen;
  117. char *inseq;
  118. ftnlen inseqlen;
  119. char *indir;
  120. ftnlen indirlen;
  121. char *infmt;
  122. ftnlen infmtlen;
  123. char *inform;
  124. ftnint informlen;
  125. char *inunf;
  126. ftnlen inunflen;
  127. ftnint *inrecl;
  128. ftnint *innrec;
  129. char *inblank;
  130. ftnlen inblanklen;
  131. } inlist;
  132. #define VOID void
  133. union Multitype { /* for multiple entry points */
  134. integer1 g;
  135. shortint h;
  136. integer i;
  137. /* longint j; */
  138. real r;
  139. doublereal d;
  140. complex c;
  141. doublecomplex z;
  142. };
  143. typedef union Multitype Multitype;
  144. struct Vardesc { /* for Namelist */
  145. char *name;
  146. char *addr;
  147. ftnlen *dims;
  148. int type;
  149. };
  150. typedef struct Vardesc Vardesc;
  151. struct Namelist {
  152. char *name;
  153. Vardesc **vars;
  154. int nvars;
  155. };
  156. typedef struct Namelist Namelist;
  157. #define abs(x) ((x) >= 0 ? (x) : -(x))
  158. #define dabs(x) (fabs(x))
  159. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  160. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  161. #define dmin(a,b) (f2cmin(a,b))
  162. #define dmax(a,b) (f2cmax(a,b))
  163. #define bit_test(a,b) ((a) >> (b) & 1)
  164. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  165. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  166. #define abort_() { sig_die("Fortran abort routine called", 1); }
  167. #define c_abs(z) (cabsf(Cf(z)))
  168. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  169. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  170. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  171. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  172. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  173. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  174. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  175. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  176. #define d_abs(x) (fabs(*(x)))
  177. #define d_acos(x) (acos(*(x)))
  178. #define d_asin(x) (asin(*(x)))
  179. #define d_atan(x) (atan(*(x)))
  180. #define d_atn2(x, y) (atan2(*(x),*(y)))
  181. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  182. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  183. #define d_cos(x) (cos(*(x)))
  184. #define d_cosh(x) (cosh(*(x)))
  185. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  186. #define d_exp(x) (exp(*(x)))
  187. #define d_imag(z) (cimag(Cd(z)))
  188. #define r_imag(z) (cimag(Cf(z)))
  189. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  190. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  191. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  192. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  193. #define d_log(x) (log(*(x)))
  194. #define d_mod(x, y) (fmod(*(x), *(y)))
  195. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  196. #define d_nint(x) u_nint(*(x))
  197. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  198. #define d_sign(a,b) u_sign(*(a),*(b))
  199. #define r_sign(a,b) u_sign(*(a),*(b))
  200. #define d_sin(x) (sin(*(x)))
  201. #define d_sinh(x) (sinh(*(x)))
  202. #define d_sqrt(x) (sqrt(*(x)))
  203. #define d_tan(x) (tan(*(x)))
  204. #define d_tanh(x) (tanh(*(x)))
  205. #define i_abs(x) abs(*(x))
  206. #define i_dnnt(x) ((integer)u_nint(*(x)))
  207. #define i_len(s, n) (n)
  208. #define i_nint(x) ((integer)u_nint(*(x)))
  209. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  210. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  211. #define pow_si(B,E) spow_ui(*(B),*(E))
  212. #define pow_ri(B,E) spow_ui(*(B),*(E))
  213. #define pow_di(B,E) dpow_ui(*(B),*(E))
  214. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  215. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  216. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  217. #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
  218. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  219. #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
  220. #define sig_die(s, kill) { exit(1); }
  221. #define s_stop(s, n) {exit(0);}
  222. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  223. #define z_abs(z) (cabs(Cd(z)))
  224. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  225. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  226. #define myexit_() break;
  227. #define mycycle() continue;
  228. #define myceiling(w) {ceil(w)}
  229. #define myhuge(w) {HUGE_VAL}
  230. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  231. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  232. /* procedure parameter types for -A and -C++ */
  233. #define F2C_proc_par_types 1
  234. #ifdef __cplusplus
  235. typedef logical (*L_fp)(...);
  236. #else
  237. typedef logical (*L_fp)();
  238. #endif
  239. static float spow_ui(float x, integer n) {
  240. float pow=1.0; unsigned long int u;
  241. if(n != 0) {
  242. if(n < 0) n = -n, x = 1/x;
  243. for(u = n; ; ) {
  244. if(u & 01) pow *= x;
  245. if(u >>= 1) x *= x;
  246. else break;
  247. }
  248. }
  249. return pow;
  250. }
  251. static double dpow_ui(double x, integer n) {
  252. double pow=1.0; unsigned long int u;
  253. if(n != 0) {
  254. if(n < 0) n = -n, x = 1/x;
  255. for(u = n; ; ) {
  256. if(u & 01) pow *= x;
  257. if(u >>= 1) x *= x;
  258. else break;
  259. }
  260. }
  261. return pow;
  262. }
  263. static _Complex float cpow_ui(_Complex float x, integer n) {
  264. _Complex float pow=1.0; unsigned long int u;
  265. if(n != 0) {
  266. if(n < 0) n = -n, x = 1/x;
  267. for(u = n; ; ) {
  268. if(u & 01) pow *= x;
  269. if(u >>= 1) x *= x;
  270. else break;
  271. }
  272. }
  273. return pow;
  274. }
  275. static _Complex double zpow_ui(_Complex double x, integer n) {
  276. _Complex double pow=1.0; unsigned long int u;
  277. if(n != 0) {
  278. if(n < 0) n = -n, x = 1/x;
  279. for(u = n; ; ) {
  280. if(u & 01) pow *= x;
  281. if(u >>= 1) x *= x;
  282. else break;
  283. }
  284. }
  285. return pow;
  286. }
  287. static integer pow_ii(integer x, integer n) {
  288. integer pow; unsigned long int u;
  289. if (n <= 0) {
  290. if (n == 0 || x == 1) pow = 1;
  291. else if (x != -1) pow = x == 0 ? 1/x : 0;
  292. else n = -n;
  293. }
  294. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  295. u = n;
  296. for(pow = 1; ; ) {
  297. if(u & 01) pow *= x;
  298. if(u >>= 1) x *= x;
  299. else break;
  300. }
  301. }
  302. return pow;
  303. }
  304. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  305. {
  306. double m; integer i, mi;
  307. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  308. if (w[i-1]>m) mi=i ,m=w[i-1];
  309. return mi-s+1;
  310. }
  311. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  312. {
  313. float m; integer i, mi;
  314. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  315. if (w[i-1]>m) mi=i ,m=w[i-1];
  316. return mi-s+1;
  317. }
  318. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  319. integer n = *n_, incx = *incx_, incy = *incy_, i;
  320. _Complex float zdotc = 0.0;
  321. if (incx == 1 && incy == 1) {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  324. }
  325. } else {
  326. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  327. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  328. }
  329. }
  330. pCf(z) = zdotc;
  331. }
  332. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  333. integer n = *n_, incx = *incx_, incy = *incy_, i;
  334. _Complex double zdotc = 0.0;
  335. if (incx == 1 && incy == 1) {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  338. }
  339. } else {
  340. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  341. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  342. }
  343. }
  344. pCd(z) = zdotc;
  345. }
  346. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  347. integer n = *n_, incx = *incx_, incy = *incy_, i;
  348. _Complex float zdotc = 0.0;
  349. if (incx == 1 && incy == 1) {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cf(&x[i]) * Cf(&y[i]);
  352. }
  353. } else {
  354. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  355. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  356. }
  357. }
  358. pCf(z) = zdotc;
  359. }
  360. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  361. integer n = *n_, incx = *incx_, incy = *incy_, i;
  362. _Complex double zdotc = 0.0;
  363. if (incx == 1 && incy == 1) {
  364. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  365. zdotc += Cd(&x[i]) * Cd(&y[i]);
  366. }
  367. } else {
  368. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  369. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  370. }
  371. }
  372. pCd(z) = zdotc;
  373. }
  374. #endif
  375. /* -- translated by f2c (version 20000121).
  376. You must link the resulting object file with the libraries:
  377. -lf2c -lm (in that order)
  378. */
  379. /* Table of constant values */
  380. static real c_b9 = 1.f;
  381. static real c_b10 = 0.f;
  382. static integer c__2 = 2;
  383. /* > \brief \b CLALSA computes the SVD of the coefficient matrix in compact form. Used by sgelsd. */
  384. /* =========== DOCUMENTATION =========== */
  385. /* Online html documentation available at */
  386. /* http://www.netlib.org/lapack/explore-html/ */
  387. /* > \htmlonly */
  388. /* > Download CLALSA + dependencies */
  389. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clalsa.
  390. f"> */
  391. /* > [TGZ]</a> */
  392. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clalsa.
  393. f"> */
  394. /* > [ZIP]</a> */
  395. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clalsa.
  396. f"> */
  397. /* > [TXT]</a> */
  398. /* > \endhtmlonly */
  399. /* Definition: */
  400. /* =========== */
  401. /* SUBROUTINE CLALSA( ICOMPQ, SMLSIZ, N, NRHS, B, LDB, BX, LDBX, U, */
  402. /* LDU, VT, K, DIFL, DIFR, Z, POLES, GIVPTR, */
  403. /* GIVCOL, LDGCOL, PERM, GIVNUM, C, S, RWORK, */
  404. /* IWORK, INFO ) */
  405. /* INTEGER ICOMPQ, INFO, LDB, LDBX, LDGCOL, LDU, N, NRHS, */
  406. /* $ SMLSIZ */
  407. /* INTEGER GIVCOL( LDGCOL, * ), GIVPTR( * ), IWORK( * ), */
  408. /* $ K( * ), PERM( LDGCOL, * ) */
  409. /* REAL C( * ), DIFL( LDU, * ), DIFR( LDU, * ), */
  410. /* $ GIVNUM( LDU, * ), POLES( LDU, * ), RWORK( * ), */
  411. /* $ S( * ), U( LDU, * ), VT( LDU, * ), Z( LDU, * ) */
  412. /* COMPLEX B( LDB, * ), BX( LDBX, * ) */
  413. /* > \par Purpose: */
  414. /* ============= */
  415. /* > */
  416. /* > \verbatim */
  417. /* > */
  418. /* > CLALSA is an itermediate step in solving the least squares problem */
  419. /* > by computing the SVD of the coefficient matrix in compact form (The */
  420. /* > singular vectors are computed as products of simple orthorgonal */
  421. /* > matrices.). */
  422. /* > */
  423. /* > If ICOMPQ = 0, CLALSA applies the inverse of the left singular vector */
  424. /* > matrix of an upper bidiagonal matrix to the right hand side; and if */
  425. /* > ICOMPQ = 1, CLALSA applies the right singular vector matrix to the */
  426. /* > right hand side. The singular vector matrices were generated in */
  427. /* > compact form by CLALSA. */
  428. /* > \endverbatim */
  429. /* Arguments: */
  430. /* ========== */
  431. /* > \param[in] ICOMPQ */
  432. /* > \verbatim */
  433. /* > ICOMPQ is INTEGER */
  434. /* > Specifies whether the left or the right singular vector */
  435. /* > matrix is involved. */
  436. /* > = 0: Left singular vector matrix */
  437. /* > = 1: Right singular vector matrix */
  438. /* > \endverbatim */
  439. /* > */
  440. /* > \param[in] SMLSIZ */
  441. /* > \verbatim */
  442. /* > SMLSIZ is INTEGER */
  443. /* > The maximum size of the subproblems at the bottom of the */
  444. /* > computation tree. */
  445. /* > \endverbatim */
  446. /* > */
  447. /* > \param[in] N */
  448. /* > \verbatim */
  449. /* > N is INTEGER */
  450. /* > The row and column dimensions of the upper bidiagonal matrix. */
  451. /* > \endverbatim */
  452. /* > */
  453. /* > \param[in] NRHS */
  454. /* > \verbatim */
  455. /* > NRHS is INTEGER */
  456. /* > The number of columns of B and BX. NRHS must be at least 1. */
  457. /* > \endverbatim */
  458. /* > */
  459. /* > \param[in,out] B */
  460. /* > \verbatim */
  461. /* > B is COMPLEX array, dimension ( LDB, NRHS ) */
  462. /* > On input, B contains the right hand sides of the least */
  463. /* > squares problem in rows 1 through M. */
  464. /* > On output, B contains the solution X in rows 1 through N. */
  465. /* > \endverbatim */
  466. /* > */
  467. /* > \param[in] LDB */
  468. /* > \verbatim */
  469. /* > LDB is INTEGER */
  470. /* > The leading dimension of B in the calling subprogram. */
  471. /* > LDB must be at least f2cmax(1,MAX( M, N ) ). */
  472. /* > \endverbatim */
  473. /* > */
  474. /* > \param[out] BX */
  475. /* > \verbatim */
  476. /* > BX is COMPLEX array, dimension ( LDBX, NRHS ) */
  477. /* > On exit, the result of applying the left or right singular */
  478. /* > vector matrix to B. */
  479. /* > \endverbatim */
  480. /* > */
  481. /* > \param[in] LDBX */
  482. /* > \verbatim */
  483. /* > LDBX is INTEGER */
  484. /* > The leading dimension of BX. */
  485. /* > \endverbatim */
  486. /* > */
  487. /* > \param[in] U */
  488. /* > \verbatim */
  489. /* > U is REAL array, dimension ( LDU, SMLSIZ ). */
  490. /* > On entry, U contains the left singular vector matrices of all */
  491. /* > subproblems at the bottom level. */
  492. /* > \endverbatim */
  493. /* > */
  494. /* > \param[in] LDU */
  495. /* > \verbatim */
  496. /* > LDU is INTEGER, LDU = > N. */
  497. /* > The leading dimension of arrays U, VT, DIFL, DIFR, */
  498. /* > POLES, GIVNUM, and Z. */
  499. /* > \endverbatim */
  500. /* > */
  501. /* > \param[in] VT */
  502. /* > \verbatim */
  503. /* > VT is REAL array, dimension ( LDU, SMLSIZ+1 ). */
  504. /* > On entry, VT**H contains the right singular vector matrices of */
  505. /* > all subproblems at the bottom level. */
  506. /* > \endverbatim */
  507. /* > */
  508. /* > \param[in] K */
  509. /* > \verbatim */
  510. /* > K is INTEGER array, dimension ( N ). */
  511. /* > \endverbatim */
  512. /* > */
  513. /* > \param[in] DIFL */
  514. /* > \verbatim */
  515. /* > DIFL is REAL array, dimension ( LDU, NLVL ). */
  516. /* > where NLVL = INT(log_2 (N/(SMLSIZ+1))) + 1. */
  517. /* > \endverbatim */
  518. /* > */
  519. /* > \param[in] DIFR */
  520. /* > \verbatim */
  521. /* > DIFR is REAL array, dimension ( LDU, 2 * NLVL ). */
  522. /* > On entry, DIFL(*, I) and DIFR(*, 2 * I -1) record */
  523. /* > distances between singular values on the I-th level and */
  524. /* > singular values on the (I -1)-th level, and DIFR(*, 2 * I) */
  525. /* > record the normalizing factors of the right singular vectors */
  526. /* > matrices of subproblems on I-th level. */
  527. /* > \endverbatim */
  528. /* > */
  529. /* > \param[in] Z */
  530. /* > \verbatim */
  531. /* > Z is REAL array, dimension ( LDU, NLVL ). */
  532. /* > On entry, Z(1, I) contains the components of the deflation- */
  533. /* > adjusted updating row vector for subproblems on the I-th */
  534. /* > level. */
  535. /* > \endverbatim */
  536. /* > */
  537. /* > \param[in] POLES */
  538. /* > \verbatim */
  539. /* > POLES is REAL array, dimension ( LDU, 2 * NLVL ). */
  540. /* > On entry, POLES(*, 2 * I -1: 2 * I) contains the new and old */
  541. /* > singular values involved in the secular equations on the I-th */
  542. /* > level. */
  543. /* > \endverbatim */
  544. /* > */
  545. /* > \param[in] GIVPTR */
  546. /* > \verbatim */
  547. /* > GIVPTR is INTEGER array, dimension ( N ). */
  548. /* > On entry, GIVPTR( I ) records the number of Givens */
  549. /* > rotations performed on the I-th problem on the computation */
  550. /* > tree. */
  551. /* > \endverbatim */
  552. /* > */
  553. /* > \param[in] GIVCOL */
  554. /* > \verbatim */
  555. /* > GIVCOL is INTEGER array, dimension ( LDGCOL, 2 * NLVL ). */
  556. /* > On entry, for each I, GIVCOL(*, 2 * I - 1: 2 * I) records the */
  557. /* > locations of Givens rotations performed on the I-th level on */
  558. /* > the computation tree. */
  559. /* > \endverbatim */
  560. /* > */
  561. /* > \param[in] LDGCOL */
  562. /* > \verbatim */
  563. /* > LDGCOL is INTEGER, LDGCOL = > N. */
  564. /* > The leading dimension of arrays GIVCOL and PERM. */
  565. /* > \endverbatim */
  566. /* > */
  567. /* > \param[in] PERM */
  568. /* > \verbatim */
  569. /* > PERM is INTEGER array, dimension ( LDGCOL, NLVL ). */
  570. /* > On entry, PERM(*, I) records permutations done on the I-th */
  571. /* > level of the computation tree. */
  572. /* > \endverbatim */
  573. /* > */
  574. /* > \param[in] GIVNUM */
  575. /* > \verbatim */
  576. /* > GIVNUM is REAL array, dimension ( LDU, 2 * NLVL ). */
  577. /* > On entry, GIVNUM(*, 2 *I -1 : 2 * I) records the C- and S- */
  578. /* > values of Givens rotations performed on the I-th level on the */
  579. /* > computation tree. */
  580. /* > \endverbatim */
  581. /* > */
  582. /* > \param[in] C */
  583. /* > \verbatim */
  584. /* > C is REAL array, dimension ( N ). */
  585. /* > On entry, if the I-th subproblem is not square, */
  586. /* > C( I ) contains the C-value of a Givens rotation related to */
  587. /* > the right null space of the I-th subproblem. */
  588. /* > \endverbatim */
  589. /* > */
  590. /* > \param[in] S */
  591. /* > \verbatim */
  592. /* > S is REAL array, dimension ( N ). */
  593. /* > On entry, if the I-th subproblem is not square, */
  594. /* > S( I ) contains the S-value of a Givens rotation related to */
  595. /* > the right null space of the I-th subproblem. */
  596. /* > \endverbatim */
  597. /* > */
  598. /* > \param[out] RWORK */
  599. /* > \verbatim */
  600. /* > RWORK is REAL array, dimension at least */
  601. /* > MAX( (SMLSZ+1)*NRHS*3, N*(1+NRHS) + 2*NRHS ). */
  602. /* > \endverbatim */
  603. /* > */
  604. /* > \param[out] IWORK */
  605. /* > \verbatim */
  606. /* > IWORK is INTEGER array, dimension (3*N) */
  607. /* > \endverbatim */
  608. /* > */
  609. /* > \param[out] INFO */
  610. /* > \verbatim */
  611. /* > INFO is INTEGER */
  612. /* > = 0: successful exit. */
  613. /* > < 0: if INFO = -i, the i-th argument had an illegal value. */
  614. /* > \endverbatim */
  615. /* Authors: */
  616. /* ======== */
  617. /* > \author Univ. of Tennessee */
  618. /* > \author Univ. of California Berkeley */
  619. /* > \author Univ. of Colorado Denver */
  620. /* > \author NAG Ltd. */
  621. /* > \date June 2017 */
  622. /* > \ingroup complexOTHERcomputational */
  623. /* > \par Contributors: */
  624. /* ================== */
  625. /* > */
  626. /* > Ming Gu and Ren-Cang Li, Computer Science Division, University of */
  627. /* > California at Berkeley, USA \n */
  628. /* > Osni Marques, LBNL/NERSC, USA \n */
  629. /* ===================================================================== */
  630. /* Subroutine */ int clalsa_(integer *icompq, integer *smlsiz, integer *n,
  631. integer *nrhs, complex *b, integer *ldb, complex *bx, integer *ldbx,
  632. real *u, integer *ldu, real *vt, integer *k, real *difl, real *difr,
  633. real *z__, real *poles, integer *givptr, integer *givcol, integer *
  634. ldgcol, integer *perm, real *givnum, real *c__, real *s, real *rwork,
  635. integer *iwork, integer *info)
  636. {
  637. /* System generated locals */
  638. integer givcol_dim1, givcol_offset, perm_dim1, perm_offset, difl_dim1,
  639. difl_offset, difr_dim1, difr_offset, givnum_dim1, givnum_offset,
  640. poles_dim1, poles_offset, u_dim1, u_offset, vt_dim1, vt_offset,
  641. z_dim1, z_offset, b_dim1, b_offset, bx_dim1, bx_offset, i__1,
  642. i__2, i__3, i__4, i__5, i__6;
  643. complex q__1;
  644. /* Local variables */
  645. integer jcol, nlvl, sqre, jrow, i__, j, jimag, jreal, inode, ndiml;
  646. extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *,
  647. integer *, real *, real *, integer *, real *, integer *, real *,
  648. real *, integer *);
  649. integer ndimr;
  650. extern /* Subroutine */ int ccopy_(integer *, complex *, integer *,
  651. complex *, integer *);
  652. integer i1;
  653. extern /* Subroutine */ int clals0_(integer *, integer *, integer *,
  654. integer *, integer *, complex *, integer *, complex *, integer *,
  655. integer *, integer *, integer *, integer *, real *, integer *,
  656. real *, real *, real *, real *, integer *, real *, real *, real *,
  657. integer *);
  658. integer ic, lf, nd, ll, nl, nr;
  659. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), slasdt_(
  660. integer *, integer *, integer *, integer *, integer *, integer *,
  661. integer *);
  662. integer im1, nlf, nrf, lvl, ndb1, nlp1, lvl2, nrp1;
  663. /* -- LAPACK computational routine (version 3.7.1) -- */
  664. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  665. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  666. /* June 2017 */
  667. /* ===================================================================== */
  668. /* Test the input parameters. */
  669. /* Parameter adjustments */
  670. b_dim1 = *ldb;
  671. b_offset = 1 + b_dim1 * 1;
  672. b -= b_offset;
  673. bx_dim1 = *ldbx;
  674. bx_offset = 1 + bx_dim1 * 1;
  675. bx -= bx_offset;
  676. givnum_dim1 = *ldu;
  677. givnum_offset = 1 + givnum_dim1 * 1;
  678. givnum -= givnum_offset;
  679. poles_dim1 = *ldu;
  680. poles_offset = 1 + poles_dim1 * 1;
  681. poles -= poles_offset;
  682. z_dim1 = *ldu;
  683. z_offset = 1 + z_dim1 * 1;
  684. z__ -= z_offset;
  685. difr_dim1 = *ldu;
  686. difr_offset = 1 + difr_dim1 * 1;
  687. difr -= difr_offset;
  688. difl_dim1 = *ldu;
  689. difl_offset = 1 + difl_dim1 * 1;
  690. difl -= difl_offset;
  691. vt_dim1 = *ldu;
  692. vt_offset = 1 + vt_dim1 * 1;
  693. vt -= vt_offset;
  694. u_dim1 = *ldu;
  695. u_offset = 1 + u_dim1 * 1;
  696. u -= u_offset;
  697. --k;
  698. --givptr;
  699. perm_dim1 = *ldgcol;
  700. perm_offset = 1 + perm_dim1 * 1;
  701. perm -= perm_offset;
  702. givcol_dim1 = *ldgcol;
  703. givcol_offset = 1 + givcol_dim1 * 1;
  704. givcol -= givcol_offset;
  705. --c__;
  706. --s;
  707. --rwork;
  708. --iwork;
  709. /* Function Body */
  710. *info = 0;
  711. if (*icompq < 0 || *icompq > 1) {
  712. *info = -1;
  713. } else if (*smlsiz < 3) {
  714. *info = -2;
  715. } else if (*n < *smlsiz) {
  716. *info = -3;
  717. } else if (*nrhs < 1) {
  718. *info = -4;
  719. } else if (*ldb < *n) {
  720. *info = -6;
  721. } else if (*ldbx < *n) {
  722. *info = -8;
  723. } else if (*ldu < *n) {
  724. *info = -10;
  725. } else if (*ldgcol < *n) {
  726. *info = -19;
  727. }
  728. if (*info != 0) {
  729. i__1 = -(*info);
  730. xerbla_("CLALSA", &i__1, (ftnlen)6);
  731. return 0;
  732. }
  733. /* Book-keeping and setting up the computation tree. */
  734. inode = 1;
  735. ndiml = inode + *n;
  736. ndimr = ndiml + *n;
  737. slasdt_(n, &nlvl, &nd, &iwork[inode], &iwork[ndiml], &iwork[ndimr],
  738. smlsiz);
  739. /* The following code applies back the left singular vector factors. */
  740. /* For applying back the right singular vector factors, go to 170. */
  741. if (*icompq == 1) {
  742. goto L170;
  743. }
  744. /* The nodes on the bottom level of the tree were solved */
  745. /* by SLASDQ. The corresponding left and right singular vector */
  746. /* matrices are in explicit form. First apply back the left */
  747. /* singular vector matrices. */
  748. ndb1 = (nd + 1) / 2;
  749. i__1 = nd;
  750. for (i__ = ndb1; i__ <= i__1; ++i__) {
  751. /* IC : center row of each node */
  752. /* NL : number of rows of left subproblem */
  753. /* NR : number of rows of right subproblem */
  754. /* NLF: starting row of the left subproblem */
  755. /* NRF: starting row of the right subproblem */
  756. i1 = i__ - 1;
  757. ic = iwork[inode + i1];
  758. nl = iwork[ndiml + i1];
  759. nr = iwork[ndimr + i1];
  760. nlf = ic - nl;
  761. nrf = ic + 1;
  762. /* Since B and BX are complex, the following call to SGEMM */
  763. /* is performed in two steps (real and imaginary parts). */
  764. /* CALL SGEMM( 'T', 'N', NL, NRHS, NL, ONE, U( NLF, 1 ), LDU, */
  765. /* $ B( NLF, 1 ), LDB, ZERO, BX( NLF, 1 ), LDBX ) */
  766. j = nl * *nrhs << 1;
  767. i__2 = *nrhs;
  768. for (jcol = 1; jcol <= i__2; ++jcol) {
  769. i__3 = nlf + nl - 1;
  770. for (jrow = nlf; jrow <= i__3; ++jrow) {
  771. ++j;
  772. i__4 = jrow + jcol * b_dim1;
  773. rwork[j] = b[i__4].r;
  774. /* L10: */
  775. }
  776. /* L20: */
  777. }
  778. sgemm_("T", "N", &nl, nrhs, &nl, &c_b9, &u[nlf + u_dim1], ldu, &rwork[
  779. (nl * *nrhs << 1) + 1], &nl, &c_b10, &rwork[1], &nl);
  780. j = nl * *nrhs << 1;
  781. i__2 = *nrhs;
  782. for (jcol = 1; jcol <= i__2; ++jcol) {
  783. i__3 = nlf + nl - 1;
  784. for (jrow = nlf; jrow <= i__3; ++jrow) {
  785. ++j;
  786. rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
  787. /* L30: */
  788. }
  789. /* L40: */
  790. }
  791. sgemm_("T", "N", &nl, nrhs, &nl, &c_b9, &u[nlf + u_dim1], ldu, &rwork[
  792. (nl * *nrhs << 1) + 1], &nl, &c_b10, &rwork[nl * *nrhs + 1], &
  793. nl);
  794. jreal = 0;
  795. jimag = nl * *nrhs;
  796. i__2 = *nrhs;
  797. for (jcol = 1; jcol <= i__2; ++jcol) {
  798. i__3 = nlf + nl - 1;
  799. for (jrow = nlf; jrow <= i__3; ++jrow) {
  800. ++jreal;
  801. ++jimag;
  802. i__4 = jrow + jcol * bx_dim1;
  803. i__5 = jreal;
  804. i__6 = jimag;
  805. q__1.r = rwork[i__5], q__1.i = rwork[i__6];
  806. bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
  807. /* L50: */
  808. }
  809. /* L60: */
  810. }
  811. /* Since B and BX are complex, the following call to SGEMM */
  812. /* is performed in two steps (real and imaginary parts). */
  813. /* CALL SGEMM( 'T', 'N', NR, NRHS, NR, ONE, U( NRF, 1 ), LDU, */
  814. /* $ B( NRF, 1 ), LDB, ZERO, BX( NRF, 1 ), LDBX ) */
  815. j = nr * *nrhs << 1;
  816. i__2 = *nrhs;
  817. for (jcol = 1; jcol <= i__2; ++jcol) {
  818. i__3 = nrf + nr - 1;
  819. for (jrow = nrf; jrow <= i__3; ++jrow) {
  820. ++j;
  821. i__4 = jrow + jcol * b_dim1;
  822. rwork[j] = b[i__4].r;
  823. /* L70: */
  824. }
  825. /* L80: */
  826. }
  827. sgemm_("T", "N", &nr, nrhs, &nr, &c_b9, &u[nrf + u_dim1], ldu, &rwork[
  828. (nr * *nrhs << 1) + 1], &nr, &c_b10, &rwork[1], &nr);
  829. j = nr * *nrhs << 1;
  830. i__2 = *nrhs;
  831. for (jcol = 1; jcol <= i__2; ++jcol) {
  832. i__3 = nrf + nr - 1;
  833. for (jrow = nrf; jrow <= i__3; ++jrow) {
  834. ++j;
  835. rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
  836. /* L90: */
  837. }
  838. /* L100: */
  839. }
  840. sgemm_("T", "N", &nr, nrhs, &nr, &c_b9, &u[nrf + u_dim1], ldu, &rwork[
  841. (nr * *nrhs << 1) + 1], &nr, &c_b10, &rwork[nr * *nrhs + 1], &
  842. nr);
  843. jreal = 0;
  844. jimag = nr * *nrhs;
  845. i__2 = *nrhs;
  846. for (jcol = 1; jcol <= i__2; ++jcol) {
  847. i__3 = nrf + nr - 1;
  848. for (jrow = nrf; jrow <= i__3; ++jrow) {
  849. ++jreal;
  850. ++jimag;
  851. i__4 = jrow + jcol * bx_dim1;
  852. i__5 = jreal;
  853. i__6 = jimag;
  854. q__1.r = rwork[i__5], q__1.i = rwork[i__6];
  855. bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
  856. /* L110: */
  857. }
  858. /* L120: */
  859. }
  860. /* L130: */
  861. }
  862. /* Next copy the rows of B that correspond to unchanged rows */
  863. /* in the bidiagonal matrix to BX. */
  864. i__1 = nd;
  865. for (i__ = 1; i__ <= i__1; ++i__) {
  866. ic = iwork[inode + i__ - 1];
  867. ccopy_(nrhs, &b[ic + b_dim1], ldb, &bx[ic + bx_dim1], ldbx);
  868. /* L140: */
  869. }
  870. /* Finally go through the left singular vector matrices of all */
  871. /* the other subproblems bottom-up on the tree. */
  872. j = pow_ii(&c__2, &nlvl);
  873. sqre = 0;
  874. for (lvl = nlvl; lvl >= 1; --lvl) {
  875. lvl2 = (lvl << 1) - 1;
  876. /* find the first node LF and last node LL on */
  877. /* the current level LVL */
  878. if (lvl == 1) {
  879. lf = 1;
  880. ll = 1;
  881. } else {
  882. i__1 = lvl - 1;
  883. lf = pow_ii(&c__2, &i__1);
  884. ll = (lf << 1) - 1;
  885. }
  886. i__1 = ll;
  887. for (i__ = lf; i__ <= i__1; ++i__) {
  888. im1 = i__ - 1;
  889. ic = iwork[inode + im1];
  890. nl = iwork[ndiml + im1];
  891. nr = iwork[ndimr + im1];
  892. nlf = ic - nl;
  893. nrf = ic + 1;
  894. --j;
  895. clals0_(icompq, &nl, &nr, &sqre, nrhs, &bx[nlf + bx_dim1], ldbx, &
  896. b[nlf + b_dim1], ldb, &perm[nlf + lvl * perm_dim1], &
  897. givptr[j], &givcol[nlf + lvl2 * givcol_dim1], ldgcol, &
  898. givnum[nlf + lvl2 * givnum_dim1], ldu, &poles[nlf + lvl2 *
  899. poles_dim1], &difl[nlf + lvl * difl_dim1], &difr[nlf +
  900. lvl2 * difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[
  901. j], &s[j], &rwork[1], info);
  902. /* L150: */
  903. }
  904. /* L160: */
  905. }
  906. goto L330;
  907. /* ICOMPQ = 1: applying back the right singular vector factors. */
  908. L170:
  909. /* First now go through the right singular vector matrices of all */
  910. /* the tree nodes top-down. */
  911. j = 0;
  912. i__1 = nlvl;
  913. for (lvl = 1; lvl <= i__1; ++lvl) {
  914. lvl2 = (lvl << 1) - 1;
  915. /* Find the first node LF and last node LL on */
  916. /* the current level LVL. */
  917. if (lvl == 1) {
  918. lf = 1;
  919. ll = 1;
  920. } else {
  921. i__2 = lvl - 1;
  922. lf = pow_ii(&c__2, &i__2);
  923. ll = (lf << 1) - 1;
  924. }
  925. i__2 = lf;
  926. for (i__ = ll; i__ >= i__2; --i__) {
  927. im1 = i__ - 1;
  928. ic = iwork[inode + im1];
  929. nl = iwork[ndiml + im1];
  930. nr = iwork[ndimr + im1];
  931. nlf = ic - nl;
  932. nrf = ic + 1;
  933. if (i__ == ll) {
  934. sqre = 0;
  935. } else {
  936. sqre = 1;
  937. }
  938. ++j;
  939. clals0_(icompq, &nl, &nr, &sqre, nrhs, &b[nlf + b_dim1], ldb, &bx[
  940. nlf + bx_dim1], ldbx, &perm[nlf + lvl * perm_dim1], &
  941. givptr[j], &givcol[nlf + lvl2 * givcol_dim1], ldgcol, &
  942. givnum[nlf + lvl2 * givnum_dim1], ldu, &poles[nlf + lvl2 *
  943. poles_dim1], &difl[nlf + lvl * difl_dim1], &difr[nlf +
  944. lvl2 * difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[
  945. j], &s[j], &rwork[1], info);
  946. /* L180: */
  947. }
  948. /* L190: */
  949. }
  950. /* The nodes on the bottom level of the tree were solved */
  951. /* by SLASDQ. The corresponding right singular vector */
  952. /* matrices are in explicit form. Apply them back. */
  953. ndb1 = (nd + 1) / 2;
  954. i__1 = nd;
  955. for (i__ = ndb1; i__ <= i__1; ++i__) {
  956. i1 = i__ - 1;
  957. ic = iwork[inode + i1];
  958. nl = iwork[ndiml + i1];
  959. nr = iwork[ndimr + i1];
  960. nlp1 = nl + 1;
  961. if (i__ == nd) {
  962. nrp1 = nr;
  963. } else {
  964. nrp1 = nr + 1;
  965. }
  966. nlf = ic - nl;
  967. nrf = ic + 1;
  968. /* Since B and BX are complex, the following call to SGEMM is */
  969. /* performed in two steps (real and imaginary parts). */
  970. /* CALL SGEMM( 'T', 'N', NLP1, NRHS, NLP1, ONE, VT( NLF, 1 ), LDU, */
  971. /* $ B( NLF, 1 ), LDB, ZERO, BX( NLF, 1 ), LDBX ) */
  972. j = nlp1 * *nrhs << 1;
  973. i__2 = *nrhs;
  974. for (jcol = 1; jcol <= i__2; ++jcol) {
  975. i__3 = nlf + nlp1 - 1;
  976. for (jrow = nlf; jrow <= i__3; ++jrow) {
  977. ++j;
  978. i__4 = jrow + jcol * b_dim1;
  979. rwork[j] = b[i__4].r;
  980. /* L200: */
  981. }
  982. /* L210: */
  983. }
  984. sgemm_("T", "N", &nlp1, nrhs, &nlp1, &c_b9, &vt[nlf + vt_dim1], ldu, &
  985. rwork[(nlp1 * *nrhs << 1) + 1], &nlp1, &c_b10, &rwork[1], &
  986. nlp1);
  987. j = nlp1 * *nrhs << 1;
  988. i__2 = *nrhs;
  989. for (jcol = 1; jcol <= i__2; ++jcol) {
  990. i__3 = nlf + nlp1 - 1;
  991. for (jrow = nlf; jrow <= i__3; ++jrow) {
  992. ++j;
  993. rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
  994. /* L220: */
  995. }
  996. /* L230: */
  997. }
  998. sgemm_("T", "N", &nlp1, nrhs, &nlp1, &c_b9, &vt[nlf + vt_dim1], ldu, &
  999. rwork[(nlp1 * *nrhs << 1) + 1], &nlp1, &c_b10, &rwork[nlp1 * *
  1000. nrhs + 1], &nlp1);
  1001. jreal = 0;
  1002. jimag = nlp1 * *nrhs;
  1003. i__2 = *nrhs;
  1004. for (jcol = 1; jcol <= i__2; ++jcol) {
  1005. i__3 = nlf + nlp1 - 1;
  1006. for (jrow = nlf; jrow <= i__3; ++jrow) {
  1007. ++jreal;
  1008. ++jimag;
  1009. i__4 = jrow + jcol * bx_dim1;
  1010. i__5 = jreal;
  1011. i__6 = jimag;
  1012. q__1.r = rwork[i__5], q__1.i = rwork[i__6];
  1013. bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
  1014. /* L240: */
  1015. }
  1016. /* L250: */
  1017. }
  1018. /* Since B and BX are complex, the following call to SGEMM is */
  1019. /* performed in two steps (real and imaginary parts). */
  1020. /* CALL SGEMM( 'T', 'N', NRP1, NRHS, NRP1, ONE, VT( NRF, 1 ), LDU, */
  1021. /* $ B( NRF, 1 ), LDB, ZERO, BX( NRF, 1 ), LDBX ) */
  1022. j = nrp1 * *nrhs << 1;
  1023. i__2 = *nrhs;
  1024. for (jcol = 1; jcol <= i__2; ++jcol) {
  1025. i__3 = nrf + nrp1 - 1;
  1026. for (jrow = nrf; jrow <= i__3; ++jrow) {
  1027. ++j;
  1028. i__4 = jrow + jcol * b_dim1;
  1029. rwork[j] = b[i__4].r;
  1030. /* L260: */
  1031. }
  1032. /* L270: */
  1033. }
  1034. sgemm_("T", "N", &nrp1, nrhs, &nrp1, &c_b9, &vt[nrf + vt_dim1], ldu, &
  1035. rwork[(nrp1 * *nrhs << 1) + 1], &nrp1, &c_b10, &rwork[1], &
  1036. nrp1);
  1037. j = nrp1 * *nrhs << 1;
  1038. i__2 = *nrhs;
  1039. for (jcol = 1; jcol <= i__2; ++jcol) {
  1040. i__3 = nrf + nrp1 - 1;
  1041. for (jrow = nrf; jrow <= i__3; ++jrow) {
  1042. ++j;
  1043. rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
  1044. /* L280: */
  1045. }
  1046. /* L290: */
  1047. }
  1048. sgemm_("T", "N", &nrp1, nrhs, &nrp1, &c_b9, &vt[nrf + vt_dim1], ldu, &
  1049. rwork[(nrp1 * *nrhs << 1) + 1], &nrp1, &c_b10, &rwork[nrp1 * *
  1050. nrhs + 1], &nrp1);
  1051. jreal = 0;
  1052. jimag = nrp1 * *nrhs;
  1053. i__2 = *nrhs;
  1054. for (jcol = 1; jcol <= i__2; ++jcol) {
  1055. i__3 = nrf + nrp1 - 1;
  1056. for (jrow = nrf; jrow <= i__3; ++jrow) {
  1057. ++jreal;
  1058. ++jimag;
  1059. i__4 = jrow + jcol * bx_dim1;
  1060. i__5 = jreal;
  1061. i__6 = jimag;
  1062. q__1.r = rwork[i__5], q__1.i = rwork[i__6];
  1063. bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
  1064. /* L300: */
  1065. }
  1066. /* L310: */
  1067. }
  1068. /* L320: */
  1069. }
  1070. L330:
  1071. return 0;
  1072. /* End of CLALSA */
  1073. } /* clalsa_ */