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.

cgsvj0.c 46 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667
  1. #include <math.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <complex.h>
  6. #ifdef complex
  7. #undef complex
  8. #endif
  9. #ifdef I
  10. #undef I
  11. #endif
  12. #if defined(_WIN64)
  13. typedef long long BLASLONG;
  14. typedef unsigned long long BLASULONG;
  15. #else
  16. typedef long BLASLONG;
  17. typedef unsigned long BLASULONG;
  18. #endif
  19. #ifdef LAPACK_ILP64
  20. typedef BLASLONG blasint;
  21. #if defined(_WIN64)
  22. #define blasabs(x) llabs(x)
  23. #else
  24. #define blasabs(x) labs(x)
  25. #endif
  26. #else
  27. typedef int blasint;
  28. #define blasabs(x) abs(x)
  29. #endif
  30. typedef blasint integer;
  31. typedef unsigned int uinteger;
  32. typedef char *address;
  33. typedef short int shortint;
  34. typedef float real;
  35. typedef double doublereal;
  36. typedef struct { real r, i; } complex;
  37. typedef struct { doublereal r, i; } doublecomplex;
  38. #ifdef _MSC_VER
  39. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  40. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  41. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  42. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  43. #else
  44. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  46. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  47. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  48. #endif
  49. #define pCf(z) (*_pCf(z))
  50. #define pCd(z) (*_pCd(z))
  51. typedef blasint logical;
  52. typedef char logical1;
  53. typedef char integer1;
  54. #define TRUE_ (1)
  55. #define FALSE_ (0)
  56. /* Extern is for use with -E */
  57. #ifndef Extern
  58. #define Extern extern
  59. #endif
  60. /* I/O stuff */
  61. typedef int flag;
  62. typedef int ftnlen;
  63. typedef int ftnint;
  64. /*external read, write*/
  65. typedef struct
  66. { flag cierr;
  67. ftnint ciunit;
  68. flag ciend;
  69. char *cifmt;
  70. ftnint cirec;
  71. } cilist;
  72. /*internal read, write*/
  73. typedef struct
  74. { flag icierr;
  75. char *iciunit;
  76. flag iciend;
  77. char *icifmt;
  78. ftnint icirlen;
  79. ftnint icirnum;
  80. } icilist;
  81. /*open*/
  82. typedef struct
  83. { flag oerr;
  84. ftnint ounit;
  85. char *ofnm;
  86. ftnlen ofnmlen;
  87. char *osta;
  88. char *oacc;
  89. char *ofm;
  90. ftnint orl;
  91. char *oblnk;
  92. } olist;
  93. /*close*/
  94. typedef struct
  95. { flag cerr;
  96. ftnint cunit;
  97. char *csta;
  98. } cllist;
  99. /*rewind, backspace, endfile*/
  100. typedef struct
  101. { flag aerr;
  102. ftnint aunit;
  103. } alist;
  104. /* inquire */
  105. typedef struct
  106. { flag inerr;
  107. ftnint inunit;
  108. char *infile;
  109. ftnlen infilen;
  110. ftnint *inex; /*parameters in standard's order*/
  111. ftnint *inopen;
  112. ftnint *innum;
  113. ftnint *innamed;
  114. char *inname;
  115. ftnlen innamlen;
  116. char *inacc;
  117. ftnlen inacclen;
  118. char *inseq;
  119. ftnlen inseqlen;
  120. char *indir;
  121. ftnlen indirlen;
  122. char *infmt;
  123. ftnlen infmtlen;
  124. char *inform;
  125. ftnint informlen;
  126. char *inunf;
  127. ftnlen inunflen;
  128. ftnint *inrecl;
  129. ftnint *innrec;
  130. char *inblank;
  131. ftnlen inblanklen;
  132. } inlist;
  133. #define VOID void
  134. union Multitype { /* for multiple entry points */
  135. integer1 g;
  136. shortint h;
  137. integer i;
  138. /* longint j; */
  139. real r;
  140. doublereal d;
  141. complex c;
  142. doublecomplex z;
  143. };
  144. typedef union Multitype Multitype;
  145. struct Vardesc { /* for Namelist */
  146. char *name;
  147. char *addr;
  148. ftnlen *dims;
  149. int type;
  150. };
  151. typedef struct Vardesc Vardesc;
  152. struct Namelist {
  153. char *name;
  154. Vardesc **vars;
  155. int nvars;
  156. };
  157. typedef struct Namelist Namelist;
  158. #define abs(x) ((x) >= 0 ? (x) : -(x))
  159. #define dabs(x) (fabs(x))
  160. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  161. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  162. #define dmin(a,b) (f2cmin(a,b))
  163. #define dmax(a,b) (f2cmax(a,b))
  164. #define bit_test(a,b) ((a) >> (b) & 1)
  165. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  166. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  167. #define abort_() { sig_die("Fortran abort routine called", 1); }
  168. #define c_abs(z) (cabsf(Cf(z)))
  169. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  170. #ifdef _MSC_VER
  171. #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
  172. #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
  173. #else
  174. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  175. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  176. #endif
  177. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  178. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  179. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  180. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  181. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  182. #define d_abs(x) (fabs(*(x)))
  183. #define d_acos(x) (acos(*(x)))
  184. #define d_asin(x) (asin(*(x)))
  185. #define d_atan(x) (atan(*(x)))
  186. #define d_atn2(x, y) (atan2(*(x),*(y)))
  187. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  188. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  189. #define d_cos(x) (cos(*(x)))
  190. #define d_cosh(x) (cosh(*(x)))
  191. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  192. #define d_exp(x) (exp(*(x)))
  193. #define d_imag(z) (cimag(Cd(z)))
  194. #define r_imag(z) (cimagf(Cf(z)))
  195. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  196. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  198. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define d_log(x) (log(*(x)))
  200. #define d_mod(x, y) (fmod(*(x), *(y)))
  201. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  202. #define d_nint(x) u_nint(*(x))
  203. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  204. #define d_sign(a,b) u_sign(*(a),*(b))
  205. #define r_sign(a,b) u_sign(*(a),*(b))
  206. #define d_sin(x) (sin(*(x)))
  207. #define d_sinh(x) (sinh(*(x)))
  208. #define d_sqrt(x) (sqrt(*(x)))
  209. #define d_tan(x) (tan(*(x)))
  210. #define d_tanh(x) (tanh(*(x)))
  211. #define i_abs(x) abs(*(x))
  212. #define i_dnnt(x) ((integer)u_nint(*(x)))
  213. #define i_len(s, n) (n)
  214. #define i_nint(x) ((integer)u_nint(*(x)))
  215. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  216. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  217. #define pow_si(B,E) spow_ui(*(B),*(E))
  218. #define pow_ri(B,E) spow_ui(*(B),*(E))
  219. #define pow_di(B,E) dpow_ui(*(B),*(E))
  220. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  221. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  222. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  223. #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++ = ' '; }
  224. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  225. #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]; }
  226. #define sig_die(s, kill) { exit(1); }
  227. #define s_stop(s, n) {exit(0);}
  228. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  229. #define z_abs(z) (cabs(Cd(z)))
  230. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  231. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  232. #define myexit_() break;
  233. #define mycycle() continue;
  234. #define myceiling(w) {ceil(w)}
  235. #define myhuge(w) {HUGE_VAL}
  236. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  237. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  238. /* procedure parameter types for -A and -C++ */
  239. #ifdef __cplusplus
  240. typedef logical (*L_fp)(...);
  241. #else
  242. typedef logical (*L_fp)();
  243. #endif
  244. static float spow_ui(float x, integer n) {
  245. float pow=1.0; unsigned long int u;
  246. if(n != 0) {
  247. if(n < 0) n = -n, x = 1/x;
  248. for(u = n; ; ) {
  249. if(u & 01) pow *= x;
  250. if(u >>= 1) x *= x;
  251. else break;
  252. }
  253. }
  254. return pow;
  255. }
  256. static double dpow_ui(double x, integer n) {
  257. double pow=1.0; unsigned long int u;
  258. if(n != 0) {
  259. if(n < 0) n = -n, x = 1/x;
  260. for(u = n; ; ) {
  261. if(u & 01) pow *= x;
  262. if(u >>= 1) x *= x;
  263. else break;
  264. }
  265. }
  266. return pow;
  267. }
  268. #ifdef _MSC_VER
  269. static _Fcomplex cpow_ui(complex x, integer n) {
  270. complex pow={1.0,0.0}; unsigned long int u;
  271. if(n != 0) {
  272. if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
  273. for(u = n; ; ) {
  274. if(u & 01) pow.r *= x.r, pow.i *= x.i;
  275. if(u >>= 1) x.r *= x.r, x.i *= x.i;
  276. else break;
  277. }
  278. }
  279. _Fcomplex p={pow.r, pow.i};
  280. return p;
  281. }
  282. #else
  283. static _Complex float cpow_ui(_Complex float x, integer n) {
  284. _Complex float pow=1.0; unsigned long int u;
  285. if(n != 0) {
  286. if(n < 0) n = -n, x = 1/x;
  287. for(u = n; ; ) {
  288. if(u & 01) pow *= x;
  289. if(u >>= 1) x *= x;
  290. else break;
  291. }
  292. }
  293. return pow;
  294. }
  295. #endif
  296. #ifdef _MSC_VER
  297. static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
  298. _Dcomplex pow={1.0,0.0}; unsigned long int u;
  299. if(n != 0) {
  300. if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
  301. for(u = n; ; ) {
  302. if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
  303. if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
  304. else break;
  305. }
  306. }
  307. _Dcomplex p = {pow._Val[0], pow._Val[1]};
  308. return p;
  309. }
  310. #else
  311. static _Complex double zpow_ui(_Complex double x, integer n) {
  312. _Complex double pow=1.0; unsigned long int u;
  313. if(n != 0) {
  314. if(n < 0) n = -n, x = 1/x;
  315. for(u = n; ; ) {
  316. if(u & 01) pow *= x;
  317. if(u >>= 1) x *= x;
  318. else break;
  319. }
  320. }
  321. return pow;
  322. }
  323. #endif
  324. static integer pow_ii(integer x, integer n) {
  325. integer pow; unsigned long int u;
  326. if (n <= 0) {
  327. if (n == 0 || x == 1) pow = 1;
  328. else if (x != -1) pow = x == 0 ? 1/x : 0;
  329. else n = -n;
  330. }
  331. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  332. u = n;
  333. for(pow = 1; ; ) {
  334. if(u & 01) pow *= x;
  335. if(u >>= 1) x *= x;
  336. else break;
  337. }
  338. }
  339. return pow;
  340. }
  341. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  342. {
  343. double m; integer i, mi;
  344. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  345. if (w[i-1]>m) mi=i ,m=w[i-1];
  346. return mi-s+1;
  347. }
  348. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  349. {
  350. float m; integer i, mi;
  351. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  352. if (w[i-1]>m) mi=i ,m=w[i-1];
  353. return mi-s+1;
  354. }
  355. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  356. integer n = *n_, incx = *incx_, incy = *incy_, i;
  357. #ifdef _MSC_VER
  358. _Fcomplex zdotc = {0.0, 0.0};
  359. if (incx == 1 && incy == 1) {
  360. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  361. zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
  362. zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
  363. }
  364. } else {
  365. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  366. zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
  367. zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
  368. }
  369. }
  370. pCf(z) = zdotc;
  371. }
  372. #else
  373. _Complex float zdotc = 0.0;
  374. if (incx == 1 && incy == 1) {
  375. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  376. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  377. }
  378. } else {
  379. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  380. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  381. }
  382. }
  383. pCf(z) = zdotc;
  384. }
  385. #endif
  386. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  387. integer n = *n_, incx = *incx_, incy = *incy_, i;
  388. #ifdef _MSC_VER
  389. _Dcomplex zdotc = {0.0, 0.0};
  390. if (incx == 1 && incy == 1) {
  391. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  392. zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
  393. zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
  394. }
  395. } else {
  396. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  397. zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
  398. zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
  399. }
  400. }
  401. pCd(z) = zdotc;
  402. }
  403. #else
  404. _Complex double zdotc = 0.0;
  405. if (incx == 1 && incy == 1) {
  406. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  407. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  408. }
  409. } else {
  410. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  411. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  412. }
  413. }
  414. pCd(z) = zdotc;
  415. }
  416. #endif
  417. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  418. integer n = *n_, incx = *incx_, incy = *incy_, i;
  419. #ifdef _MSC_VER
  420. _Fcomplex zdotc = {0.0, 0.0};
  421. if (incx == 1 && incy == 1) {
  422. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  423. zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
  424. zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
  425. }
  426. } else {
  427. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  428. zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
  429. zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
  430. }
  431. }
  432. pCf(z) = zdotc;
  433. }
  434. #else
  435. _Complex float zdotc = 0.0;
  436. if (incx == 1 && incy == 1) {
  437. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  438. zdotc += Cf(&x[i]) * Cf(&y[i]);
  439. }
  440. } else {
  441. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  442. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  443. }
  444. }
  445. pCf(z) = zdotc;
  446. }
  447. #endif
  448. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  449. integer n = *n_, incx = *incx_, incy = *incy_, i;
  450. #ifdef _MSC_VER
  451. _Dcomplex zdotc = {0.0, 0.0};
  452. if (incx == 1 && incy == 1) {
  453. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  454. zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
  455. zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
  456. }
  457. } else {
  458. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  459. zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
  460. zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
  461. }
  462. }
  463. pCd(z) = zdotc;
  464. }
  465. #else
  466. _Complex double zdotc = 0.0;
  467. if (incx == 1 && incy == 1) {
  468. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  469. zdotc += Cd(&x[i]) * Cd(&y[i]);
  470. }
  471. } else {
  472. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  473. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  474. }
  475. }
  476. pCd(z) = zdotc;
  477. }
  478. #endif
  479. /* -- translated by f2c (version 20000121).
  480. You must link the resulting object file with the libraries:
  481. -lf2c -lm (in that order)
  482. */
  483. /* Table of constant values */
  484. static integer c__1 = 1;
  485. static integer c__0 = 0;
  486. static real c_b27 = 1.f;
  487. /* > \brief \b CGSVJ0 pre-processor for the routine cgesvj. */
  488. /* =========== DOCUMENTATION =========== */
  489. /* Online html documentation available at */
  490. /* http://www.netlib.org/lapack/explore-html/ */
  491. /* > \htmlonly */
  492. /* > Download CGSVJ0 + dependencies */
  493. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgsvj0.
  494. f"> */
  495. /* > [TGZ]</a> */
  496. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgsvj0.
  497. f"> */
  498. /* > [ZIP]</a> */
  499. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgsvj0.
  500. f"> */
  501. /* > [TXT]</a> */
  502. /* > \endhtmlonly */
  503. /* Definition: */
  504. /* =========== */
  505. /* SUBROUTINE CGSVJ0( JOBV, M, N, A, LDA, D, SVA, MV, V, LDV, EPS, */
  506. /* SFMIN, TOL, NSWEEP, WORK, LWORK, INFO ) */
  507. /* INTEGER INFO, LDA, LDV, LWORK, M, MV, N, NSWEEP */
  508. /* REAL EPS, SFMIN, TOL */
  509. /* CHARACTER*1 JOBV */
  510. /* COMPLEX A( LDA, * ), D( N ), V( LDV, * ), WORK( LWORK ) */
  511. /* REAL SVA( N ) */
  512. /* > \par Purpose: */
  513. /* ============= */
  514. /* > */
  515. /* > \verbatim */
  516. /* > */
  517. /* > CGSVJ0 is called from CGESVJ as a pre-processor and that is its main */
  518. /* > purpose. It applies Jacobi rotations in the same way as CGESVJ does, but */
  519. /* > it does not check convergence (stopping criterion). Few tuning */
  520. /* > parameters (marked by [TP]) are available for the implementer. */
  521. /* > \endverbatim */
  522. /* Arguments: */
  523. /* ========== */
  524. /* > \param[in] JOBV */
  525. /* > \verbatim */
  526. /* > JOBV is CHARACTER*1 */
  527. /* > Specifies whether the output from this procedure is used */
  528. /* > to compute the matrix V: */
  529. /* > = 'V': the product of the Jacobi rotations is accumulated */
  530. /* > by postmulyiplying the N-by-N array V. */
  531. /* > (See the description of V.) */
  532. /* > = 'A': the product of the Jacobi rotations is accumulated */
  533. /* > by postmulyiplying the MV-by-N array V. */
  534. /* > (See the descriptions of MV and V.) */
  535. /* > = 'N': the Jacobi rotations are not accumulated. */
  536. /* > \endverbatim */
  537. /* > */
  538. /* > \param[in] M */
  539. /* > \verbatim */
  540. /* > M is INTEGER */
  541. /* > The number of rows of the input matrix A. M >= 0. */
  542. /* > \endverbatim */
  543. /* > */
  544. /* > \param[in] N */
  545. /* > \verbatim */
  546. /* > N is INTEGER */
  547. /* > The number of columns of the input matrix A. */
  548. /* > M >= N >= 0. */
  549. /* > \endverbatim */
  550. /* > */
  551. /* > \param[in,out] A */
  552. /* > \verbatim */
  553. /* > A is COMPLEX array, dimension (LDA,N) */
  554. /* > On entry, M-by-N matrix A, such that A*diag(D) represents */
  555. /* > the input matrix. */
  556. /* > On exit, */
  557. /* > A_onexit * diag(D_onexit) represents the input matrix A*diag(D) */
  558. /* > post-multiplied by a sequence of Jacobi rotations, where the */
  559. /* > rotation threshold and the total number of sweeps are given in */
  560. /* > TOL and NSWEEP, respectively. */
  561. /* > (See the descriptions of D, TOL and NSWEEP.) */
  562. /* > \endverbatim */
  563. /* > */
  564. /* > \param[in] LDA */
  565. /* > \verbatim */
  566. /* > LDA is INTEGER */
  567. /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */
  568. /* > \endverbatim */
  569. /* > */
  570. /* > \param[in,out] D */
  571. /* > \verbatim */
  572. /* > D is COMPLEX array, dimension (N) */
  573. /* > The array D accumulates the scaling factors from the complex scaled */
  574. /* > Jacobi rotations. */
  575. /* > On entry, A*diag(D) represents the input matrix. */
  576. /* > On exit, A_onexit*diag(D_onexit) represents the input matrix */
  577. /* > post-multiplied by a sequence of Jacobi rotations, where the */
  578. /* > rotation threshold and the total number of sweeps are given in */
  579. /* > TOL and NSWEEP, respectively. */
  580. /* > (See the descriptions of A, TOL and NSWEEP.) */
  581. /* > \endverbatim */
  582. /* > */
  583. /* > \param[in,out] SVA */
  584. /* > \verbatim */
  585. /* > SVA is REAL array, dimension (N) */
  586. /* > On entry, SVA contains the Euclidean norms of the columns of */
  587. /* > the matrix A*diag(D). */
  588. /* > On exit, SVA contains the Euclidean norms of the columns of */
  589. /* > the matrix A_onexit*diag(D_onexit). */
  590. /* > \endverbatim */
  591. /* > */
  592. /* > \param[in] MV */
  593. /* > \verbatim */
  594. /* > MV is INTEGER */
  595. /* > If JOBV = 'A', then MV rows of V are post-multipled by a */
  596. /* > sequence of Jacobi rotations. */
  597. /* > If JOBV = 'N', then MV is not referenced. */
  598. /* > \endverbatim */
  599. /* > */
  600. /* > \param[in,out] V */
  601. /* > \verbatim */
  602. /* > V is COMPLEX array, dimension (LDV,N) */
  603. /* > If JOBV = 'V' then N rows of V are post-multipled by a */
  604. /* > sequence of Jacobi rotations. */
  605. /* > If JOBV = 'A' then MV rows of V are post-multipled by a */
  606. /* > sequence of Jacobi rotations. */
  607. /* > If JOBV = 'N', then V is not referenced. */
  608. /* > \endverbatim */
  609. /* > */
  610. /* > \param[in] LDV */
  611. /* > \verbatim */
  612. /* > LDV is INTEGER */
  613. /* > The leading dimension of the array V, LDV >= 1. */
  614. /* > If JOBV = 'V', LDV >= N. */
  615. /* > If JOBV = 'A', LDV >= MV. */
  616. /* > \endverbatim */
  617. /* > */
  618. /* > \param[in] EPS */
  619. /* > \verbatim */
  620. /* > EPS is REAL */
  621. /* > EPS = SLAMCH('Epsilon') */
  622. /* > \endverbatim */
  623. /* > */
  624. /* > \param[in] SFMIN */
  625. /* > \verbatim */
  626. /* > SFMIN is REAL */
  627. /* > SFMIN = SLAMCH('Safe Minimum') */
  628. /* > \endverbatim */
  629. /* > */
  630. /* > \param[in] TOL */
  631. /* > \verbatim */
  632. /* > TOL is REAL */
  633. /* > TOL is the threshold for Jacobi rotations. For a pair */
  634. /* > A(:,p), A(:,q) of pivot columns, the Jacobi rotation is */
  635. /* > applied only if ABS(COS(angle(A(:,p),A(:,q)))) > TOL. */
  636. /* > \endverbatim */
  637. /* > */
  638. /* > \param[in] NSWEEP */
  639. /* > \verbatim */
  640. /* > NSWEEP is INTEGER */
  641. /* > NSWEEP is the number of sweeps of Jacobi rotations to be */
  642. /* > performed. */
  643. /* > \endverbatim */
  644. /* > */
  645. /* > \param[out] WORK */
  646. /* > \verbatim */
  647. /* > WORK is COMPLEX array, dimension (LWORK) */
  648. /* > \endverbatim */
  649. /* > */
  650. /* > \param[in] LWORK */
  651. /* > \verbatim */
  652. /* > LWORK is INTEGER */
  653. /* > LWORK is the dimension of WORK. LWORK >= M. */
  654. /* > \endverbatim */
  655. /* > */
  656. /* > \param[out] INFO */
  657. /* > \verbatim */
  658. /* > INFO is INTEGER */
  659. /* > = 0: successful exit. */
  660. /* > < 0: if INFO = -i, then the i-th argument had an illegal value */
  661. /* > \endverbatim */
  662. /* Authors: */
  663. /* ======== */
  664. /* > \author Univ. of Tennessee */
  665. /* > \author Univ. of California Berkeley */
  666. /* > \author Univ. of Colorado Denver */
  667. /* > \author NAG Ltd. */
  668. /* > \date June 2016 */
  669. /* > \ingroup complexOTHERcomputational */
  670. /* > \par Further Details: */
  671. /* ===================== */
  672. /* > */
  673. /* > CGSVJ0 is used just to enable CGESVJ to call a simplified version of */
  674. /* > itself to work on a submatrix of the original matrix. */
  675. /* > */
  676. /* > \par Contributor: */
  677. /* ================== */
  678. /* > */
  679. /* > Zlatko Drmac (Zagreb, Croatia) */
  680. /* > */
  681. /* > \par Bugs, Examples and Comments: */
  682. /* ================================= */
  683. /* > */
  684. /* > Please report all bugs and send interesting test examples and comments to */
  685. /* > drmac@math.hr. Thank you. */
  686. /* ===================================================================== */
  687. /* Subroutine */ void cgsvj0_(char *jobv, integer *m, integer *n, complex *a,
  688. integer *lda, complex *d__, real *sva, integer *mv, complex *v,
  689. integer *ldv, real *eps, real *sfmin, real *tol, integer *nsweep,
  690. complex *work, integer *lwork, integer *info)
  691. {
  692. /* System generated locals */
  693. integer a_dim1, a_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4, i__5,
  694. i__6, i__7;
  695. real r__1, r__2;
  696. complex q__1, q__2, q__3;
  697. /* Local variables */
  698. real aapp;
  699. complex aapq;
  700. real aaqq;
  701. integer ierr;
  702. real bigtheta;
  703. extern /* Subroutine */ void crot_(integer *, complex *, integer *,
  704. complex *, integer *, real *, complex *);
  705. complex ompq;
  706. integer pskipped;
  707. real aapp0, aapq1, temp1;
  708. integer i__, p, q;
  709. real t;
  710. extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer
  711. *, complex *, integer *);
  712. real apoaq, aqoap;
  713. extern logical lsame_(char *, char *);
  714. real theta, small;
  715. extern /* Subroutine */ void ccopy_(integer *, complex *, integer *,
  716. complex *, integer *), cswap_(integer *, complex *, integer *,
  717. complex *, integer *);
  718. logical applv, rsvec;
  719. extern /* Subroutine */ void caxpy_(integer *, complex *, complex *,
  720. integer *, complex *, integer *);
  721. logical rotok;
  722. real rootsfmin;
  723. extern real scnrm2_(integer *, complex *, integer *);
  724. real cs, sn;
  725. extern /* Subroutine */ void clascl_(char *, integer *, integer *, real *,
  726. real *, integer *, integer *, complex *, integer *, integer *);
  727. extern int xerbla_(char *, integer *, ftnlen);
  728. integer ijblsk, swband;
  729. extern integer isamax_(integer *, real *, integer *);
  730. integer blskip;
  731. extern /* Subroutine */ void classq_(integer *, complex *, integer *, real
  732. *, real *);
  733. real mxaapq, thsign, mxsinj;
  734. integer ir1, emptsw, notrot, iswrot, jbc;
  735. real big;
  736. integer kbl, lkahead, igl, ibr, jgl, nbl, mvl;
  737. real rootbig, rooteps;
  738. integer rowskip;
  739. real roottol;
  740. /* -- LAPACK computational routine (version 3.8.0) -- */
  741. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  742. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  743. /* June 2016 */
  744. /* ===================================================================== */
  745. /* from BLAS */
  746. /* from LAPACK */
  747. /* Test the input parameters. */
  748. /* Parameter adjustments */
  749. --sva;
  750. --d__;
  751. a_dim1 = *lda;
  752. a_offset = 1 + a_dim1 * 1;
  753. a -= a_offset;
  754. v_dim1 = *ldv;
  755. v_offset = 1 + v_dim1 * 1;
  756. v -= v_offset;
  757. --work;
  758. /* Function Body */
  759. applv = lsame_(jobv, "A");
  760. rsvec = lsame_(jobv, "V");
  761. if (! (rsvec || applv || lsame_(jobv, "N"))) {
  762. *info = -1;
  763. } else if (*m < 0) {
  764. *info = -2;
  765. } else if (*n < 0 || *n > *m) {
  766. *info = -3;
  767. } else if (*lda < *m) {
  768. *info = -5;
  769. } else if ((rsvec || applv) && *mv < 0) {
  770. *info = -8;
  771. } else if (rsvec && *ldv < *n || applv && *ldv < *mv) {
  772. *info = -10;
  773. } else if (*tol <= *eps) {
  774. *info = -13;
  775. } else if (*nsweep < 0) {
  776. *info = -14;
  777. } else if (*lwork < *m) {
  778. *info = -16;
  779. } else {
  780. *info = 0;
  781. }
  782. /* #:( */
  783. if (*info != 0) {
  784. i__1 = -(*info);
  785. xerbla_("CGSVJ0", &i__1, (ftnlen)6);
  786. return;
  787. }
  788. if (rsvec) {
  789. mvl = *n;
  790. } else if (applv) {
  791. mvl = *mv;
  792. }
  793. rsvec = rsvec || applv;
  794. rooteps = sqrt(*eps);
  795. rootsfmin = sqrt(*sfmin);
  796. small = *sfmin / *eps;
  797. big = 1.f / *sfmin;
  798. rootbig = 1.f / rootsfmin;
  799. bigtheta = 1.f / rooteps;
  800. roottol = sqrt(*tol);
  801. emptsw = *n * (*n - 1) / 2;
  802. notrot = 0;
  803. swband = 0;
  804. /* [TP] SWBAND is a tuning parameter [TP]. It is meaningful and effective */
  805. /* if CGESVJ is used as a computational routine in the preconditioned */
  806. /* Jacobi SVD algorithm CGEJSV. For sweeps i=1:SWBAND the procedure */
  807. /* works on pivots inside a band-like region around the diagonal. */
  808. /* The boundaries are determined dynamically, based on the number of */
  809. /* pivots above a threshold. */
  810. kbl = f2cmin(8,*n);
  811. /* [TP] KBL is a tuning parameter that defines the tile size in the */
  812. /* tiling of the p-q loops of pivot pairs. In general, an optimal */
  813. /* value of KBL depends on the matrix dimensions and on the */
  814. /* parameters of the computer's memory. */
  815. nbl = *n / kbl;
  816. if (nbl * kbl != *n) {
  817. ++nbl;
  818. }
  819. /* Computing 2nd power */
  820. i__1 = kbl;
  821. blskip = i__1 * i__1;
  822. /* [TP] BLKSKIP is a tuning parameter that depends on SWBAND and KBL. */
  823. rowskip = f2cmin(5,kbl);
  824. /* [TP] ROWSKIP is a tuning parameter. */
  825. lkahead = 1;
  826. /* [TP] LKAHEAD is a tuning parameter. */
  827. /* Quasi block transformations, using the lower (upper) triangular */
  828. /* structure of the input matrix. The quasi-block-cycling usually */
  829. /* invokes cubic convergence. Big part of this cycle is done inside */
  830. /* canonical subspaces of dimensions less than M. */
  831. i__1 = *nsweep;
  832. for (i__ = 1; i__ <= i__1; ++i__) {
  833. mxaapq = 0.f;
  834. mxsinj = 0.f;
  835. iswrot = 0;
  836. notrot = 0;
  837. pskipped = 0;
  838. /* Each sweep is unrolled using KBL-by-KBL tiles over the pivot pairs */
  839. /* 1 <= p < q <= N. This is the first step toward a blocked implementation */
  840. /* of the rotations. New implementation, based on block transformations, */
  841. /* is under development. */
  842. i__2 = nbl;
  843. for (ibr = 1; ibr <= i__2; ++ibr) {
  844. igl = (ibr - 1) * kbl + 1;
  845. /* Computing MIN */
  846. i__4 = lkahead, i__5 = nbl - ibr;
  847. i__3 = f2cmin(i__4,i__5);
  848. for (ir1 = 0; ir1 <= i__3; ++ir1) {
  849. igl += ir1 * kbl;
  850. /* Computing MIN */
  851. i__5 = igl + kbl - 1, i__6 = *n - 1;
  852. i__4 = f2cmin(i__5,i__6);
  853. for (p = igl; p <= i__4; ++p) {
  854. i__5 = *n - p + 1;
  855. q = isamax_(&i__5, &sva[p], &c__1) + p - 1;
  856. if (p != q) {
  857. cswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 +
  858. 1], &c__1);
  859. if (rsvec) {
  860. cswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  861. v_dim1 + 1], &c__1);
  862. }
  863. temp1 = sva[p];
  864. sva[p] = sva[q];
  865. sva[q] = temp1;
  866. i__5 = p;
  867. aapq.r = d__[i__5].r, aapq.i = d__[i__5].i;
  868. i__5 = p;
  869. i__6 = q;
  870. d__[i__5].r = d__[i__6].r, d__[i__5].i = d__[i__6].i;
  871. i__5 = q;
  872. d__[i__5].r = aapq.r, d__[i__5].i = aapq.i;
  873. }
  874. if (ir1 == 0) {
  875. /* Column norms are periodically updated by explicit */
  876. /* norm computation. */
  877. /* Caveat: */
  878. /* Unfortunately, some BLAS implementations compute SNCRM2(M,A(1,p),1) */
  879. /* as SQRT(S=CDOTC(M,A(1,p),1,A(1,p),1)), which may cause the result to */
  880. /* overflow for ||A(:,p)||_2 > SQRT(overflow_threshold), and to */
  881. /* underflow for ||A(:,p)||_2 < SQRT(underflow_threshold). */
  882. /* Hence, SCNRM2 cannot be trusted, not even in the case when */
  883. /* the true norm is far from the under(over)flow boundaries. */
  884. /* If properly implemented SCNRM2 is available, the IF-THEN-ELSE-END IF */
  885. /* below should be replaced with "AAPP = SCNRM2( M, A(1,p), 1 )". */
  886. if (sva[p] < rootbig && sva[p] > rootsfmin) {
  887. sva[p] = scnrm2_(m, &a[p * a_dim1 + 1], &c__1);
  888. } else {
  889. temp1 = 0.f;
  890. aapp = 1.f;
  891. classq_(m, &a[p * a_dim1 + 1], &c__1, &temp1, &
  892. aapp);
  893. sva[p] = temp1 * sqrt(aapp);
  894. }
  895. aapp = sva[p];
  896. } else {
  897. aapp = sva[p];
  898. }
  899. if (aapp > 0.f) {
  900. pskipped = 0;
  901. /* Computing MIN */
  902. i__6 = igl + kbl - 1;
  903. i__5 = f2cmin(i__6,*n);
  904. for (q = p + 1; q <= i__5; ++q) {
  905. aaqq = sva[q];
  906. if (aaqq > 0.f) {
  907. aapp0 = aapp;
  908. if (aaqq >= 1.f) {
  909. rotok = small * aapp <= aaqq;
  910. if (aapp < big / aaqq) {
  911. cdotc_(&q__3, m, &a[p * a_dim1 + 1], &
  912. c__1, &a[q * a_dim1 + 1], &
  913. c__1);
  914. q__2.r = q__3.r / aaqq, q__2.i =
  915. q__3.i / aaqq;
  916. q__1.r = q__2.r / aapp, q__1.i =
  917. q__2.i / aapp;
  918. aapq.r = q__1.r, aapq.i = q__1.i;
  919. } else {
  920. ccopy_(m, &a[p * a_dim1 + 1], &c__1, &
  921. work[1], &c__1);
  922. clascl_("G", &c__0, &c__0, &aapp, &
  923. c_b27, m, &c__1, &work[1],
  924. lda, &ierr);
  925. cdotc_(&q__2, m, &work[1], &c__1, &a[
  926. q * a_dim1 + 1], &c__1);
  927. q__1.r = q__2.r / aaqq, q__1.i =
  928. q__2.i / aaqq;
  929. aapq.r = q__1.r, aapq.i = q__1.i;
  930. }
  931. } else {
  932. rotok = aapp <= aaqq / small;
  933. if (aapp > small / aaqq) {
  934. cdotc_(&q__3, m, &a[p * a_dim1 + 1], &
  935. c__1, &a[q * a_dim1 + 1], &
  936. c__1);
  937. q__2.r = q__3.r / aapp, q__2.i =
  938. q__3.i / aapp;
  939. q__1.r = q__2.r / aaqq, q__1.i =
  940. q__2.i / aaqq;
  941. aapq.r = q__1.r, aapq.i = q__1.i;
  942. } else {
  943. ccopy_(m, &a[q * a_dim1 + 1], &c__1, &
  944. work[1], &c__1);
  945. clascl_("G", &c__0, &c__0, &aaqq, &
  946. c_b27, m, &c__1, &work[1],
  947. lda, &ierr);
  948. cdotc_(&q__2, m, &a[p * a_dim1 + 1], &
  949. c__1, &work[1], &c__1);
  950. q__1.r = q__2.r / aapp, q__1.i =
  951. q__2.i / aapp;
  952. aapq.r = q__1.r, aapq.i = q__1.i;
  953. }
  954. }
  955. /* AAPQ = AAPQ * CONJG( CWORK(p) ) * CWORK(q) */
  956. aapq1 = -c_abs(&aapq);
  957. /* Computing MAX */
  958. r__1 = mxaapq, r__2 = -aapq1;
  959. mxaapq = f2cmax(r__1,r__2);
  960. /* TO rotate or NOT to rotate, THAT is the question ... */
  961. if (abs(aapq1) > *tol) {
  962. r__1 = c_abs(&aapq);
  963. q__1.r = aapq.r / r__1, q__1.i = aapq.i /
  964. r__1;
  965. ompq.r = q__1.r, ompq.i = q__1.i;
  966. /* [RTD] ROTATED = ROTATED + ONE */
  967. if (ir1 == 0) {
  968. notrot = 0;
  969. pskipped = 0;
  970. ++iswrot;
  971. }
  972. if (rotok) {
  973. aqoap = aaqq / aapp;
  974. apoaq = aapp / aaqq;
  975. theta = (r__1 = aqoap - apoaq, abs(
  976. r__1)) * -.5f / aapq1;
  977. if (abs(theta) > bigtheta) {
  978. t = .5f / theta;
  979. cs = 1.f;
  980. r_cnjg(&q__2, &ompq);
  981. q__1.r = t * q__2.r, q__1.i = t *
  982. q__2.i;
  983. crot_(m, &a[p * a_dim1 + 1], &
  984. c__1, &a[q * a_dim1 + 1],
  985. &c__1, &cs, &q__1);
  986. if (rsvec) {
  987. r_cnjg(&q__2, &ompq);
  988. q__1.r = t * q__2.r, q__1.i = t * q__2.i;
  989. crot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  990. v_dim1 + 1], &c__1, &cs, &q__1);
  991. }
  992. /* Computing MAX */
  993. r__1 = 0.f, r__2 = t * apoaq *
  994. aapq1 + 1.f;
  995. sva[q] = aaqq * sqrt((f2cmax(r__1,
  996. r__2)));
  997. /* Computing MAX */
  998. r__1 = 0.f, r__2 = 1.f - t *
  999. aqoap * aapq1;
  1000. aapp *= sqrt((f2cmax(r__1,r__2)));
  1001. /* Computing MAX */
  1002. r__1 = mxsinj, r__2 = abs(t);
  1003. mxsinj = f2cmax(r__1,r__2);
  1004. } else {
  1005. thsign = -r_sign(&c_b27, &aapq1);
  1006. t = 1.f / (theta + thsign * sqrt(
  1007. theta * theta + 1.f));
  1008. cs = sqrt(1.f / (t * t + 1.f));
  1009. sn = t * cs;
  1010. /* Computing MAX */
  1011. r__1 = mxsinj, r__2 = abs(sn);
  1012. mxsinj = f2cmax(r__1,r__2);
  1013. /* Computing MAX */
  1014. r__1 = 0.f, r__2 = t * apoaq *
  1015. aapq1 + 1.f;
  1016. sva[q] = aaqq * sqrt((f2cmax(r__1,
  1017. r__2)));
  1018. /* Computing MAX */
  1019. r__1 = 0.f, r__2 = 1.f - t *
  1020. aqoap * aapq1;
  1021. aapp *= sqrt((f2cmax(r__1,r__2)));
  1022. r_cnjg(&q__2, &ompq);
  1023. q__1.r = sn * q__2.r, q__1.i = sn
  1024. * q__2.i;
  1025. crot_(m, &a[p * a_dim1 + 1], &
  1026. c__1, &a[q * a_dim1 + 1],
  1027. &c__1, &cs, &q__1);
  1028. if (rsvec) {
  1029. r_cnjg(&q__2, &ompq);
  1030. q__1.r = sn * q__2.r, q__1.i = sn * q__2.i;
  1031. crot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  1032. v_dim1 + 1], &c__1, &cs, &q__1);
  1033. }
  1034. }
  1035. i__6 = p;
  1036. i__7 = q;
  1037. q__2.r = -d__[i__7].r, q__2.i = -d__[
  1038. i__7].i;
  1039. q__1.r = q__2.r * ompq.r - q__2.i *
  1040. ompq.i, q__1.i = q__2.r *
  1041. ompq.i + q__2.i * ompq.r;
  1042. d__[i__6].r = q__1.r, d__[i__6].i =
  1043. q__1.i;
  1044. } else {
  1045. ccopy_(m, &a[p * a_dim1 + 1], &c__1, &
  1046. work[1], &c__1);
  1047. clascl_("G", &c__0, &c__0, &aapp, &
  1048. c_b27, m, &c__1, &work[1],
  1049. lda, &ierr);
  1050. clascl_("G", &c__0, &c__0, &aaqq, &
  1051. c_b27, m, &c__1, &a[q *
  1052. a_dim1 + 1], lda, &ierr);
  1053. q__1.r = -aapq.r, q__1.i = -aapq.i;
  1054. caxpy_(m, &q__1, &work[1], &c__1, &a[
  1055. q * a_dim1 + 1], &c__1);
  1056. clascl_("G", &c__0, &c__0, &c_b27, &
  1057. aaqq, m, &c__1, &a[q * a_dim1
  1058. + 1], lda, &ierr);
  1059. /* Computing MAX */
  1060. r__1 = 0.f, r__2 = 1.f - aapq1 *
  1061. aapq1;
  1062. sva[q] = aaqq * sqrt((f2cmax(r__1,r__2)))
  1063. ;
  1064. mxsinj = f2cmax(mxsinj,*sfmin);
  1065. }
  1066. /* END IF ROTOK THEN ... ELSE */
  1067. /* In the case of cancellation in updating SVA(q), SVA(p) */
  1068. /* recompute SVA(q), SVA(p). */
  1069. /* Computing 2nd power */
  1070. r__1 = sva[q] / aaqq;
  1071. if (r__1 * r__1 <= rooteps) {
  1072. if (aaqq < rootbig && aaqq >
  1073. rootsfmin) {
  1074. sva[q] = scnrm2_(m, &a[q * a_dim1
  1075. + 1], &c__1);
  1076. } else {
  1077. t = 0.f;
  1078. aaqq = 1.f;
  1079. classq_(m, &a[q * a_dim1 + 1], &
  1080. c__1, &t, &aaqq);
  1081. sva[q] = t * sqrt(aaqq);
  1082. }
  1083. }
  1084. if (aapp / aapp0 <= rooteps) {
  1085. if (aapp < rootbig && aapp >
  1086. rootsfmin) {
  1087. aapp = scnrm2_(m, &a[p * a_dim1 +
  1088. 1], &c__1);
  1089. } else {
  1090. t = 0.f;
  1091. aapp = 1.f;
  1092. classq_(m, &a[p * a_dim1 + 1], &
  1093. c__1, &t, &aapp);
  1094. aapp = t * sqrt(aapp);
  1095. }
  1096. sva[p] = aapp;
  1097. }
  1098. } else {
  1099. /* A(:,p) and A(:,q) already numerically orthogonal */
  1100. if (ir1 == 0) {
  1101. ++notrot;
  1102. }
  1103. /* [RTD] SKIPPED = SKIPPED + 1 */
  1104. ++pskipped;
  1105. }
  1106. } else {
  1107. /* A(:,q) is zero column */
  1108. if (ir1 == 0) {
  1109. ++notrot;
  1110. }
  1111. ++pskipped;
  1112. }
  1113. if (i__ <= swband && pskipped > rowskip) {
  1114. if (ir1 == 0) {
  1115. aapp = -aapp;
  1116. }
  1117. notrot = 0;
  1118. goto L2103;
  1119. }
  1120. /* L2002: */
  1121. }
  1122. /* END q-LOOP */
  1123. L2103:
  1124. /* bailed out of q-loop */
  1125. sva[p] = aapp;
  1126. } else {
  1127. sva[p] = aapp;
  1128. if (ir1 == 0 && aapp == 0.f) {
  1129. /* Computing MIN */
  1130. i__5 = igl + kbl - 1;
  1131. notrot = notrot + f2cmin(i__5,*n) - p;
  1132. }
  1133. }
  1134. /* L2001: */
  1135. }
  1136. /* end of the p-loop */
  1137. /* end of doing the block ( ibr, ibr ) */
  1138. /* L1002: */
  1139. }
  1140. /* end of ir1-loop */
  1141. /* ... go to the off diagonal blocks */
  1142. igl = (ibr - 1) * kbl + 1;
  1143. i__3 = nbl;
  1144. for (jbc = ibr + 1; jbc <= i__3; ++jbc) {
  1145. jgl = (jbc - 1) * kbl + 1;
  1146. /* doing the block at ( ibr, jbc ) */
  1147. ijblsk = 0;
  1148. /* Computing MIN */
  1149. i__5 = igl + kbl - 1;
  1150. i__4 = f2cmin(i__5,*n);
  1151. for (p = igl; p <= i__4; ++p) {
  1152. aapp = sva[p];
  1153. if (aapp > 0.f) {
  1154. pskipped = 0;
  1155. /* Computing MIN */
  1156. i__6 = jgl + kbl - 1;
  1157. i__5 = f2cmin(i__6,*n);
  1158. for (q = jgl; q <= i__5; ++q) {
  1159. aaqq = sva[q];
  1160. if (aaqq > 0.f) {
  1161. aapp0 = aapp;
  1162. /* Safe Gram matrix computation */
  1163. if (aaqq >= 1.f) {
  1164. if (aapp >= aaqq) {
  1165. rotok = small * aapp <= aaqq;
  1166. } else {
  1167. rotok = small * aaqq <= aapp;
  1168. }
  1169. if (aapp < big / aaqq) {
  1170. cdotc_(&q__3, m, &a[p * a_dim1 + 1], &
  1171. c__1, &a[q * a_dim1 + 1], &
  1172. c__1);
  1173. q__2.r = q__3.r / aaqq, q__2.i =
  1174. q__3.i / aaqq;
  1175. q__1.r = q__2.r / aapp, q__1.i =
  1176. q__2.i / aapp;
  1177. aapq.r = q__1.r, aapq.i = q__1.i;
  1178. } else {
  1179. ccopy_(m, &a[p * a_dim1 + 1], &c__1, &
  1180. work[1], &c__1);
  1181. clascl_("G", &c__0, &c__0, &aapp, &
  1182. c_b27, m, &c__1, &work[1],
  1183. lda, &ierr);
  1184. cdotc_(&q__2, m, &work[1], &c__1, &a[
  1185. q * a_dim1 + 1], &c__1);
  1186. q__1.r = q__2.r / aaqq, q__1.i =
  1187. q__2.i / aaqq;
  1188. aapq.r = q__1.r, aapq.i = q__1.i;
  1189. }
  1190. } else {
  1191. if (aapp >= aaqq) {
  1192. rotok = aapp <= aaqq / small;
  1193. } else {
  1194. rotok = aaqq <= aapp / small;
  1195. }
  1196. if (aapp > small / aaqq) {
  1197. cdotc_(&q__3, m, &a[p * a_dim1 + 1], &
  1198. c__1, &a[q * a_dim1 + 1], &
  1199. c__1);
  1200. r__1 = f2cmax(aaqq,aapp);
  1201. q__2.r = q__3.r / r__1, q__2.i =
  1202. q__3.i / r__1;
  1203. r__2 = f2cmin(aaqq,aapp);
  1204. q__1.r = q__2.r / r__2, q__1.i =
  1205. q__2.i / r__2;
  1206. aapq.r = q__1.r, aapq.i = q__1.i;
  1207. } else {
  1208. ccopy_(m, &a[q * a_dim1 + 1], &c__1, &
  1209. work[1], &c__1);
  1210. clascl_("G", &c__0, &c__0, &aaqq, &
  1211. c_b27, m, &c__1, &work[1],
  1212. lda, &ierr);
  1213. cdotc_(&q__2, m, &a[p * a_dim1 + 1], &
  1214. c__1, &work[1], &c__1);
  1215. q__1.r = q__2.r / aapp, q__1.i =
  1216. q__2.i / aapp;
  1217. aapq.r = q__1.r, aapq.i = q__1.i;
  1218. }
  1219. }
  1220. /* AAPQ = AAPQ * CONJG(CWORK(p))*CWORK(q) */
  1221. aapq1 = -c_abs(&aapq);
  1222. /* Computing MAX */
  1223. r__1 = mxaapq, r__2 = -aapq1;
  1224. mxaapq = f2cmax(r__1,r__2);
  1225. /* TO rotate or NOT to rotate, THAT is the question ... */
  1226. if (abs(aapq1) > *tol) {
  1227. r__1 = c_abs(&aapq);
  1228. q__1.r = aapq.r / r__1, q__1.i = aapq.i /
  1229. r__1;
  1230. ompq.r = q__1.r, ompq.i = q__1.i;
  1231. notrot = 0;
  1232. /* [RTD] ROTATED = ROTATED + 1 */
  1233. pskipped = 0;
  1234. ++iswrot;
  1235. if (rotok) {
  1236. aqoap = aaqq / aapp;
  1237. apoaq = aapp / aaqq;
  1238. theta = (r__1 = aqoap - apoaq, abs(
  1239. r__1)) * -.5f / aapq1;
  1240. if (aaqq > aapp0) {
  1241. theta = -theta;
  1242. }
  1243. if (abs(theta) > bigtheta) {
  1244. t = .5f / theta;
  1245. cs = 1.f;
  1246. r_cnjg(&q__2, &ompq);
  1247. q__1.r = t * q__2.r, q__1.i = t *
  1248. q__2.i;
  1249. crot_(m, &a[p * a_dim1 + 1], &
  1250. c__1, &a[q * a_dim1 + 1],
  1251. &c__1, &cs, &q__1);
  1252. if (rsvec) {
  1253. r_cnjg(&q__2, &ompq);
  1254. q__1.r = t * q__2.r, q__1.i = t * q__2.i;
  1255. crot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  1256. v_dim1 + 1], &c__1, &cs, &q__1);
  1257. }
  1258. /* Computing MAX */
  1259. r__1 = 0.f, r__2 = t * apoaq *
  1260. aapq1 + 1.f;
  1261. sva[q] = aaqq * sqrt((f2cmax(r__1,
  1262. r__2)));
  1263. /* Computing MAX */
  1264. r__1 = 0.f, r__2 = 1.f - t *
  1265. aqoap * aapq1;
  1266. aapp *= sqrt((f2cmax(r__1,r__2)));
  1267. /* Computing MAX */
  1268. r__1 = mxsinj, r__2 = abs(t);
  1269. mxsinj = f2cmax(r__1,r__2);
  1270. } else {
  1271. thsign = -r_sign(&c_b27, &aapq1);
  1272. if (aaqq > aapp0) {
  1273. thsign = -thsign;
  1274. }
  1275. t = 1.f / (theta + thsign * sqrt(
  1276. theta * theta + 1.f));
  1277. cs = sqrt(1.f / (t * t + 1.f));
  1278. sn = t * cs;
  1279. /* Computing MAX */
  1280. r__1 = mxsinj, r__2 = abs(sn);
  1281. mxsinj = f2cmax(r__1,r__2);
  1282. /* Computing MAX */
  1283. r__1 = 0.f, r__2 = t * apoaq *
  1284. aapq1 + 1.f;
  1285. sva[q] = aaqq * sqrt((f2cmax(r__1,
  1286. r__2)));
  1287. /* Computing MAX */
  1288. r__1 = 0.f, r__2 = 1.f - t *
  1289. aqoap * aapq1;
  1290. aapp *= sqrt((f2cmax(r__1,r__2)));
  1291. r_cnjg(&q__2, &ompq);
  1292. q__1.r = sn * q__2.r, q__1.i = sn
  1293. * q__2.i;
  1294. crot_(m, &a[p * a_dim1 + 1], &
  1295. c__1, &a[q * a_dim1 + 1],
  1296. &c__1, &cs, &q__1);
  1297. if (rsvec) {
  1298. r_cnjg(&q__2, &ompq);
  1299. q__1.r = sn * q__2.r, q__1.i = sn * q__2.i;
  1300. crot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  1301. v_dim1 + 1], &c__1, &cs, &q__1);
  1302. }
  1303. }
  1304. i__6 = p;
  1305. i__7 = q;
  1306. q__2.r = -d__[i__7].r, q__2.i = -d__[
  1307. i__7].i;
  1308. q__1.r = q__2.r * ompq.r - q__2.i *
  1309. ompq.i, q__1.i = q__2.r *
  1310. ompq.i + q__2.i * ompq.r;
  1311. d__[i__6].r = q__1.r, d__[i__6].i =
  1312. q__1.i;
  1313. } else {
  1314. if (aapp > aaqq) {
  1315. ccopy_(m, &a[p * a_dim1 + 1], &
  1316. c__1, &work[1], &c__1);
  1317. clascl_("G", &c__0, &c__0, &aapp,
  1318. &c_b27, m, &c__1, &work[1]
  1319. , lda, &ierr);
  1320. clascl_("G", &c__0, &c__0, &aaqq,
  1321. &c_b27, m, &c__1, &a[q *
  1322. a_dim1 + 1], lda, &ierr);
  1323. q__1.r = -aapq.r, q__1.i =
  1324. -aapq.i;
  1325. caxpy_(m, &q__1, &work[1], &c__1,
  1326. &a[q * a_dim1 + 1], &c__1)
  1327. ;
  1328. clascl_("G", &c__0, &c__0, &c_b27,
  1329. &aaqq, m, &c__1, &a[q *
  1330. a_dim1 + 1], lda, &ierr);
  1331. /* Computing MAX */
  1332. r__1 = 0.f, r__2 = 1.f - aapq1 *
  1333. aapq1;
  1334. sva[q] = aaqq * sqrt((f2cmax(r__1,
  1335. r__2)));
  1336. mxsinj = f2cmax(mxsinj,*sfmin);
  1337. } else {
  1338. ccopy_(m, &a[q * a_dim1 + 1], &
  1339. c__1, &work[1], &c__1);
  1340. clascl_("G", &c__0, &c__0, &aaqq,
  1341. &c_b27, m, &c__1, &work[1]
  1342. , lda, &ierr);
  1343. clascl_("G", &c__0, &c__0, &aapp,
  1344. &c_b27, m, &c__1, &a[p *
  1345. a_dim1 + 1], lda, &ierr);
  1346. r_cnjg(&q__2, &aapq);
  1347. q__1.r = -q__2.r, q__1.i =
  1348. -q__2.i;
  1349. caxpy_(m, &q__1, &work[1], &c__1,
  1350. &a[p * a_dim1 + 1], &c__1)
  1351. ;
  1352. clascl_("G", &c__0, &c__0, &c_b27,
  1353. &aapp, m, &c__1, &a[p *
  1354. a_dim1 + 1], lda, &ierr);
  1355. /* Computing MAX */
  1356. r__1 = 0.f, r__2 = 1.f - aapq1 *
  1357. aapq1;
  1358. sva[p] = aapp * sqrt((f2cmax(r__1,
  1359. r__2)));
  1360. mxsinj = f2cmax(mxsinj,*sfmin);
  1361. }
  1362. }
  1363. /* END IF ROTOK THEN ... ELSE */
  1364. /* In the case of cancellation in updating SVA(q), SVA(p) */
  1365. /* Computing 2nd power */
  1366. r__1 = sva[q] / aaqq;
  1367. if (r__1 * r__1 <= rooteps) {
  1368. if (aaqq < rootbig && aaqq >
  1369. rootsfmin) {
  1370. sva[q] = scnrm2_(m, &a[q * a_dim1
  1371. + 1], &c__1);
  1372. } else {
  1373. t = 0.f;
  1374. aaqq = 1.f;
  1375. classq_(m, &a[q * a_dim1 + 1], &
  1376. c__1, &t, &aaqq);
  1377. sva[q] = t * sqrt(aaqq);
  1378. }
  1379. }
  1380. /* Computing 2nd power */
  1381. r__1 = aapp / aapp0;
  1382. if (r__1 * r__1 <= rooteps) {
  1383. if (aapp < rootbig && aapp >
  1384. rootsfmin) {
  1385. aapp = scnrm2_(m, &a[p * a_dim1 +
  1386. 1], &c__1);
  1387. } else {
  1388. t = 0.f;
  1389. aapp = 1.f;
  1390. classq_(m, &a[p * a_dim1 + 1], &
  1391. c__1, &t, &aapp);
  1392. aapp = t * sqrt(aapp);
  1393. }
  1394. sva[p] = aapp;
  1395. }
  1396. /* end of OK rotation */
  1397. } else {
  1398. ++notrot;
  1399. /* [RTD] SKIPPED = SKIPPED + 1 */
  1400. ++pskipped;
  1401. ++ijblsk;
  1402. }
  1403. } else {
  1404. ++notrot;
  1405. ++pskipped;
  1406. ++ijblsk;
  1407. }
  1408. if (i__ <= swband && ijblsk >= blskip) {
  1409. sva[p] = aapp;
  1410. notrot = 0;
  1411. goto L2011;
  1412. }
  1413. if (i__ <= swband && pskipped > rowskip) {
  1414. aapp = -aapp;
  1415. notrot = 0;
  1416. goto L2203;
  1417. }
  1418. /* L2200: */
  1419. }
  1420. /* end of the q-loop */
  1421. L2203:
  1422. sva[p] = aapp;
  1423. } else {
  1424. if (aapp == 0.f) {
  1425. /* Computing MIN */
  1426. i__5 = jgl + kbl - 1;
  1427. notrot = notrot + f2cmin(i__5,*n) - jgl + 1;
  1428. }
  1429. if (aapp < 0.f) {
  1430. notrot = 0;
  1431. }
  1432. }
  1433. /* L2100: */
  1434. }
  1435. /* end of the p-loop */
  1436. /* L2010: */
  1437. }
  1438. /* end of the jbc-loop */
  1439. L2011:
  1440. /* 2011 bailed out of the jbc-loop */
  1441. /* Computing MIN */
  1442. i__4 = igl + kbl - 1;
  1443. i__3 = f2cmin(i__4,*n);
  1444. for (p = igl; p <= i__3; ++p) {
  1445. sva[p] = (r__1 = sva[p], abs(r__1));
  1446. /* L2012: */
  1447. }
  1448. /* ** */
  1449. /* L2000: */
  1450. }
  1451. /* 2000 :: end of the ibr-loop */
  1452. if (sva[*n] < rootbig && sva[*n] > rootsfmin) {
  1453. sva[*n] = scnrm2_(m, &a[*n * a_dim1 + 1], &c__1);
  1454. } else {
  1455. t = 0.f;
  1456. aapp = 1.f;
  1457. classq_(m, &a[*n * a_dim1 + 1], &c__1, &t, &aapp);
  1458. sva[*n] = t * sqrt(aapp);
  1459. }
  1460. /* Additional steering devices */
  1461. if (i__ < swband && (mxaapq <= roottol || iswrot <= *n)) {
  1462. swband = i__;
  1463. }
  1464. if (i__ > swband + 1 && mxaapq < sqrt((real) (*n)) * *tol && (real) (*
  1465. n) * mxaapq * mxsinj < *tol) {
  1466. goto L1994;
  1467. }
  1468. if (notrot >= emptsw) {
  1469. goto L1994;
  1470. }
  1471. /* L1993: */
  1472. }
  1473. /* end i=1:NSWEEP loop */
  1474. /* #:( Reaching this point means that the procedure has not converged. */
  1475. *info = *nsweep - 1;
  1476. goto L1995;
  1477. L1994:
  1478. /* #:) Reaching this point means numerical convergence after the i-th */
  1479. /* sweep. */
  1480. *info = 0;
  1481. /* #:) INFO = 0 confirms successful iterations. */
  1482. L1995:
  1483. /* Sort the vector SVA() of column norms. */
  1484. i__1 = *n - 1;
  1485. for (p = 1; p <= i__1; ++p) {
  1486. i__2 = *n - p + 1;
  1487. q = isamax_(&i__2, &sva[p], &c__1) + p - 1;
  1488. if (p != q) {
  1489. temp1 = sva[p];
  1490. sva[p] = sva[q];
  1491. sva[q] = temp1;
  1492. i__2 = p;
  1493. aapq.r = d__[i__2].r, aapq.i = d__[i__2].i;
  1494. i__2 = p;
  1495. i__3 = q;
  1496. d__[i__2].r = d__[i__3].r, d__[i__2].i = d__[i__3].i;
  1497. i__2 = q;
  1498. d__[i__2].r = aapq.r, d__[i__2].i = aapq.i;
  1499. cswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 + 1], &c__1);
  1500. if (rsvec) {
  1501. cswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * v_dim1 + 1], &
  1502. c__1);
  1503. }
  1504. }
  1505. /* L5991: */
  1506. }
  1507. return;
  1508. } /* cgsvj0_ */