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.

zgsvj0.c 46 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668
  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 doublereal c_b27 = 1.;
  487. /* > \brief <b> ZGSVJ0 pre-processor for the routine zgesvj. </b> */
  488. /* =========== DOCUMENTATION =========== */
  489. /* Online html documentation available at */
  490. /* http://www.netlib.org/lapack/explore-html/ */
  491. /* > \htmlonly */
  492. /* > Download ZGSVJ0 + dependencies */
  493. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgsvj0.
  494. f"> */
  495. /* > [TGZ]</a> */
  496. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgsvj0.
  497. f"> */
  498. /* > [ZIP]</a> */
  499. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgsvj0.
  500. f"> */
  501. /* > [TXT]</a> */
  502. /* > \endhtmlonly */
  503. /* Definition: */
  504. /* =========== */
  505. /* SUBROUTINE ZGSVJ0( 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. /* DOUBLE PRECISION EPS, SFMIN, TOL */
  509. /* CHARACTER*1 JOBV */
  510. /* COMPLEX*16 A( LDA, * ), D( N ), V( LDV, * ), WORK( LWORK ) */
  511. /* DOUBLE PRECISION SVA( N ) */
  512. /* > \par Purpose: */
  513. /* ============= */
  514. /* > */
  515. /* > \verbatim */
  516. /* > */
  517. /* > ZGSVJ0 is called from ZGESVJ as a pre-processor and that is its main */
  518. /* > purpose. It applies Jacobi rotations in the same way as ZGESVJ 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*16 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*16 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 DOUBLE PRECISION 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*16 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 DOUBLE PRECISION */
  621. /* > EPS = DLAMCH('Epsilon') */
  622. /* > \endverbatim */
  623. /* > */
  624. /* > \param[in] SFMIN */
  625. /* > \verbatim */
  626. /* > SFMIN is DOUBLE PRECISION */
  627. /* > SFMIN = DLAMCH('Safe Minimum') */
  628. /* > \endverbatim */
  629. /* > */
  630. /* > \param[in] TOL */
  631. /* > \verbatim */
  632. /* > TOL is DOUBLE PRECISION */
  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*16 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 complex16OTHERcomputational */
  670. /* > */
  671. /* > \par Further Details: */
  672. /* ===================== */
  673. /* > */
  674. /* > ZGSVJ0 is used just to enable ZGESVJ to call a simplified version of */
  675. /* > itself to work on a submatrix of the original matrix. */
  676. /* > */
  677. /* > Contributor: */
  678. /* ============= */
  679. /* > */
  680. /* > Zlatko Drmac (Zagreb, Croatia) */
  681. /* > */
  682. /* > \par Bugs, Examples and Comments: */
  683. /* ============================ */
  684. /* > */
  685. /* > Please report all bugs and send interesting test examples and comments to */
  686. /* > drmac@math.hr. Thank you. */
  687. /* ===================================================================== */
  688. /* Subroutine */ void zgsvj0_(char *jobv, integer *m, integer *n,
  689. doublecomplex *a, integer *lda, doublecomplex *d__, doublereal *sva,
  690. integer *mv, doublecomplex *v, integer *ldv, doublereal *eps,
  691. doublereal *sfmin, doublereal *tol, integer *nsweep, doublecomplex *
  692. work, integer *lwork, integer *info)
  693. {
  694. /* System generated locals */
  695. integer a_dim1, a_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4, i__5,
  696. i__6, i__7;
  697. doublereal d__1, d__2;
  698. doublecomplex z__1, z__2, z__3;
  699. /* Local variables */
  700. doublereal aapp;
  701. doublecomplex aapq;
  702. doublereal aaqq;
  703. integer ierr;
  704. doublereal bigtheta;
  705. doublecomplex ompq;
  706. integer pskipped;
  707. extern /* Subroutine */ void zrot_(integer *, doublecomplex *, integer *,
  708. doublecomplex *, integer *, doublereal *, doublecomplex *);
  709. doublereal aapp0, aapq1, temp1;
  710. integer i__, p, q;
  711. doublereal t, apoaq, aqoap;
  712. extern logical lsame_(char *, char *);
  713. doublereal theta, small;
  714. logical applv, rsvec;
  715. extern /* Double Complex */ VOID zdotc_(doublecomplex *, integer *,
  716. doublecomplex *, integer *, doublecomplex *, integer *);
  717. logical rotok;
  718. extern /* Subroutine */ void zcopy_(integer *, doublecomplex *, integer *,
  719. doublecomplex *, integer *), zswap_(integer *, doublecomplex *,
  720. integer *, doublecomplex *, integer *), zaxpy_(integer *,
  721. doublecomplex *, doublecomplex *, integer *, doublecomplex *,
  722. integer *);
  723. doublereal rootsfmin;
  724. extern doublereal dznrm2_(integer *, doublecomplex *, integer *);
  725. doublereal cs, sn;
  726. extern integer idamax_(integer *, doublereal *, integer *);
  727. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  728. integer ijblsk, swband, blskip;
  729. doublereal mxaapq;
  730. extern /* Subroutine */ void zlascl_(char *, integer *, integer *,
  731. doublereal *, doublereal *, integer *, integer *, doublecomplex *,
  732. integer *, integer *);
  733. doublereal thsign, mxsinj;
  734. integer ir1;
  735. extern /* Subroutine */ void zlassq_(integer *, doublecomplex *, integer *,
  736. doublereal *, doublereal *);
  737. integer emptsw, notrot, iswrot, jbc;
  738. doublereal big;
  739. integer kbl, lkahead, igl, ibr, jgl, nbl, mvl;
  740. doublereal rootbig, rooteps;
  741. integer rowskip;
  742. doublereal roottol;
  743. /* -- LAPACK computational routine (version 3.8.0) -- */
  744. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  745. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  746. /* June 2016 */
  747. /* ===================================================================== */
  748. /* from BLAS */
  749. /* from LAPACK */
  750. /* Test the input parameters. */
  751. /* Parameter adjustments */
  752. --sva;
  753. --d__;
  754. a_dim1 = *lda;
  755. a_offset = 1 + a_dim1 * 1;
  756. a -= a_offset;
  757. v_dim1 = *ldv;
  758. v_offset = 1 + v_dim1 * 1;
  759. v -= v_offset;
  760. --work;
  761. /* Function Body */
  762. applv = lsame_(jobv, "A");
  763. rsvec = lsame_(jobv, "V");
  764. if (! (rsvec || applv || lsame_(jobv, "N"))) {
  765. *info = -1;
  766. } else if (*m < 0) {
  767. *info = -2;
  768. } else if (*n < 0 || *n > *m) {
  769. *info = -3;
  770. } else if (*lda < *m) {
  771. *info = -5;
  772. } else if ((rsvec || applv) && *mv < 0) {
  773. *info = -8;
  774. } else if (rsvec && *ldv < *n || applv && *ldv < *mv) {
  775. *info = -10;
  776. } else if (*tol <= *eps) {
  777. *info = -13;
  778. } else if (*nsweep < 0) {
  779. *info = -14;
  780. } else if (*lwork < *m) {
  781. *info = -16;
  782. } else {
  783. *info = 0;
  784. }
  785. /* #:( */
  786. if (*info != 0) {
  787. i__1 = -(*info);
  788. xerbla_("ZGSVJ0", &i__1, (ftnlen)6);
  789. return;
  790. }
  791. if (rsvec) {
  792. mvl = *n;
  793. } else if (applv) {
  794. mvl = *mv;
  795. }
  796. rsvec = rsvec || applv;
  797. rooteps = sqrt(*eps);
  798. rootsfmin = sqrt(*sfmin);
  799. small = *sfmin / *eps;
  800. big = 1. / *sfmin;
  801. rootbig = 1. / rootsfmin;
  802. bigtheta = 1. / rooteps;
  803. roottol = sqrt(*tol);
  804. emptsw = *n * (*n - 1) / 2;
  805. notrot = 0;
  806. swband = 0;
  807. /* [TP] SWBAND is a tuning parameter [TP]. It is meaningful and effective */
  808. /* if ZGESVJ is used as a computational routine in the preconditioned */
  809. /* Jacobi SVD algorithm ZGEJSV. For sweeps i=1:SWBAND the procedure */
  810. /* works on pivots inside a band-like region around the diagonal. */
  811. /* The boundaries are determined dynamically, based on the number of */
  812. /* pivots above a threshold. */
  813. kbl = f2cmin(8,*n);
  814. /* [TP] KBL is a tuning parameter that defines the tile size in the */
  815. /* tiling of the p-q loops of pivot pairs. In general, an optimal */
  816. /* value of KBL depends on the matrix dimensions and on the */
  817. /* parameters of the computer's memory. */
  818. nbl = *n / kbl;
  819. if (nbl * kbl != *n) {
  820. ++nbl;
  821. }
  822. /* Computing 2nd power */
  823. i__1 = kbl;
  824. blskip = i__1 * i__1;
  825. /* [TP] BLKSKIP is a tuning parameter that depends on SWBAND and KBL. */
  826. rowskip = f2cmin(5,kbl);
  827. /* [TP] ROWSKIP is a tuning parameter. */
  828. lkahead = 1;
  829. /* [TP] LKAHEAD is a tuning parameter. */
  830. /* Quasi block transformations, using the lower (upper) triangular */
  831. /* structure of the input matrix. The quasi-block-cycling usually */
  832. /* invokes cubic convergence. Big part of this cycle is done inside */
  833. /* canonical subspaces of dimensions less than M. */
  834. i__1 = *nsweep;
  835. for (i__ = 1; i__ <= i__1; ++i__) {
  836. mxaapq = 0.;
  837. mxsinj = 0.;
  838. iswrot = 0;
  839. notrot = 0;
  840. pskipped = 0;
  841. /* Each sweep is unrolled using KBL-by-KBL tiles over the pivot pairs */
  842. /* 1 <= p < q <= N. This is the first step toward a blocked implementation */
  843. /* of the rotations. New implementation, based on block transformations, */
  844. /* is under development. */
  845. i__2 = nbl;
  846. for (ibr = 1; ibr <= i__2; ++ibr) {
  847. igl = (ibr - 1) * kbl + 1;
  848. /* Computing MIN */
  849. i__4 = lkahead, i__5 = nbl - ibr;
  850. i__3 = f2cmin(i__4,i__5);
  851. for (ir1 = 0; ir1 <= i__3; ++ir1) {
  852. igl += ir1 * kbl;
  853. /* Computing MIN */
  854. i__5 = igl + kbl - 1, i__6 = *n - 1;
  855. i__4 = f2cmin(i__5,i__6);
  856. for (p = igl; p <= i__4; ++p) {
  857. i__5 = *n - p + 1;
  858. q = idamax_(&i__5, &sva[p], &c__1) + p - 1;
  859. if (p != q) {
  860. zswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 +
  861. 1], &c__1);
  862. if (rsvec) {
  863. zswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  864. v_dim1 + 1], &c__1);
  865. }
  866. temp1 = sva[p];
  867. sva[p] = sva[q];
  868. sva[q] = temp1;
  869. i__5 = p;
  870. aapq.r = d__[i__5].r, aapq.i = d__[i__5].i;
  871. i__5 = p;
  872. i__6 = q;
  873. d__[i__5].r = d__[i__6].r, d__[i__5].i = d__[i__6].i;
  874. i__5 = q;
  875. d__[i__5].r = aapq.r, d__[i__5].i = aapq.i;
  876. }
  877. if (ir1 == 0) {
  878. /* Column norms are periodically updated by explicit */
  879. /* norm computation. */
  880. /* Caveat: */
  881. /* Unfortunately, some BLAS implementations compute SNCRM2(M,A(1,p),1) */
  882. /* as SQRT(S=ZDOTC(M,A(1,p),1,A(1,p),1)), which may cause the result to */
  883. /* overflow for ||A(:,p)||_2 > SQRT(overflow_threshold), and to */
  884. /* underflow for ||A(:,p)||_2 < SQRT(underflow_threshold). */
  885. /* Hence, DZNRM2 cannot be trusted, not even in the case when */
  886. /* the true norm is far from the under(over)flow boundaries. */
  887. /* If properly implemented DZNRM2 is available, the IF-THEN-ELSE-END IF */
  888. /* below should be replaced with "AAPP = DZNRM2( M, A(1,p), 1 )". */
  889. if (sva[p] < rootbig && sva[p] > rootsfmin) {
  890. sva[p] = dznrm2_(m, &a[p * a_dim1 + 1], &c__1);
  891. } else {
  892. temp1 = 0.;
  893. aapp = 1.;
  894. zlassq_(m, &a[p * a_dim1 + 1], &c__1, &temp1, &
  895. aapp);
  896. sva[p] = temp1 * sqrt(aapp);
  897. }
  898. aapp = sva[p];
  899. } else {
  900. aapp = sva[p];
  901. }
  902. if (aapp > 0.) {
  903. pskipped = 0;
  904. /* Computing MIN */
  905. i__6 = igl + kbl - 1;
  906. i__5 = f2cmin(i__6,*n);
  907. for (q = p + 1; q <= i__5; ++q) {
  908. aaqq = sva[q];
  909. if (aaqq > 0.) {
  910. aapp0 = aapp;
  911. if (aaqq >= 1.) {
  912. rotok = small * aapp <= aaqq;
  913. if (aapp < big / aaqq) {
  914. zdotc_(&z__3, m, &a[p * a_dim1 + 1], &
  915. c__1, &a[q * a_dim1 + 1], &
  916. c__1);
  917. z__2.r = z__3.r / aaqq, z__2.i =
  918. z__3.i / aaqq;
  919. z__1.r = z__2.r / aapp, z__1.i =
  920. z__2.i / aapp;
  921. aapq.r = z__1.r, aapq.i = z__1.i;
  922. } else {
  923. zcopy_(m, &a[p * a_dim1 + 1], &c__1, &
  924. work[1], &c__1);
  925. zlascl_("G", &c__0, &c__0, &aapp, &
  926. c_b27, m, &c__1, &work[1],
  927. lda, &ierr);
  928. zdotc_(&z__2, m, &work[1], &c__1, &a[
  929. q * a_dim1 + 1], &c__1);
  930. z__1.r = z__2.r / aaqq, z__1.i =
  931. z__2.i / aaqq;
  932. aapq.r = z__1.r, aapq.i = z__1.i;
  933. }
  934. } else {
  935. rotok = aapp <= aaqq / small;
  936. if (aapp > small / aaqq) {
  937. zdotc_(&z__3, m, &a[p * a_dim1 + 1], &
  938. c__1, &a[q * a_dim1 + 1], &
  939. c__1);
  940. z__2.r = z__3.r / aapp, z__2.i =
  941. z__3.i / aapp;
  942. z__1.r = z__2.r / aaqq, z__1.i =
  943. z__2.i / aaqq;
  944. aapq.r = z__1.r, aapq.i = z__1.i;
  945. } else {
  946. zcopy_(m, &a[q * a_dim1 + 1], &c__1, &
  947. work[1], &c__1);
  948. zlascl_("G", &c__0, &c__0, &aaqq, &
  949. c_b27, m, &c__1, &work[1],
  950. lda, &ierr);
  951. zdotc_(&z__2, m, &a[p * a_dim1 + 1], &
  952. c__1, &work[1], &c__1);
  953. z__1.r = z__2.r / aapp, z__1.i =
  954. z__2.i / aapp;
  955. aapq.r = z__1.r, aapq.i = z__1.i;
  956. }
  957. }
  958. /* AAPQ = AAPQ * CONJG( CWORK(p) ) * CWORK(q) */
  959. aapq1 = -z_abs(&aapq);
  960. /* Computing MAX */
  961. d__1 = mxaapq, d__2 = -aapq1;
  962. mxaapq = f2cmax(d__1,d__2);
  963. /* TO rotate or NOT to rotate, THAT is the question ... */
  964. if (abs(aapq1) > *tol) {
  965. d__1 = z_abs(&aapq);
  966. z__1.r = aapq.r / d__1, z__1.i = aapq.i /
  967. d__1;
  968. ompq.r = z__1.r, ompq.i = z__1.i;
  969. /* [RTD] ROTATED = ROTATED + ONE */
  970. if (ir1 == 0) {
  971. notrot = 0;
  972. pskipped = 0;
  973. ++iswrot;
  974. }
  975. if (rotok) {
  976. aqoap = aaqq / aapp;
  977. apoaq = aapp / aaqq;
  978. theta = (d__1 = aqoap - apoaq, abs(
  979. d__1)) * -.5 / aapq1;
  980. if (abs(theta) > bigtheta) {
  981. t = .5 / theta;
  982. cs = 1.;
  983. d_cnjg(&z__2, &ompq);
  984. z__1.r = t * z__2.r, z__1.i = t *
  985. z__2.i;
  986. zrot_(m, &a[p * a_dim1 + 1], &
  987. c__1, &a[q * a_dim1 + 1],
  988. &c__1, &cs, &z__1);
  989. if (rsvec) {
  990. d_cnjg(&z__2, &ompq);
  991. z__1.r = t * z__2.r, z__1.i = t * z__2.i;
  992. zrot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  993. v_dim1 + 1], &c__1, &cs, &z__1);
  994. }
  995. /* Computing MAX */
  996. d__1 = 0., d__2 = t * apoaq *
  997. aapq1 + 1.;
  998. sva[q] = aaqq * sqrt((f2cmax(d__1,
  999. d__2)));
  1000. /* Computing MAX */
  1001. d__1 = 0., d__2 = 1. - t * aqoap *
  1002. aapq1;
  1003. aapp *= sqrt((f2cmax(d__1,d__2)));
  1004. /* Computing MAX */
  1005. d__1 = mxsinj, d__2 = abs(t);
  1006. mxsinj = f2cmax(d__1,d__2);
  1007. } else {
  1008. thsign = -d_sign(&c_b27, &aapq1);
  1009. t = 1. / (theta + thsign * sqrt(
  1010. theta * theta + 1.));
  1011. cs = sqrt(1. / (t * t + 1.));
  1012. sn = t * cs;
  1013. /* Computing MAX */
  1014. d__1 = mxsinj, d__2 = abs(sn);
  1015. mxsinj = f2cmax(d__1,d__2);
  1016. /* Computing MAX */
  1017. d__1 = 0., d__2 = t * apoaq *
  1018. aapq1 + 1.;
  1019. sva[q] = aaqq * sqrt((f2cmax(d__1,
  1020. d__2)));
  1021. /* Computing MAX */
  1022. d__1 = 0., d__2 = 1. - t * aqoap *
  1023. aapq1;
  1024. aapp *= sqrt((f2cmax(d__1,d__2)));
  1025. d_cnjg(&z__2, &ompq);
  1026. z__1.r = sn * z__2.r, z__1.i = sn
  1027. * z__2.i;
  1028. zrot_(m, &a[p * a_dim1 + 1], &
  1029. c__1, &a[q * a_dim1 + 1],
  1030. &c__1, &cs, &z__1);
  1031. if (rsvec) {
  1032. d_cnjg(&z__2, &ompq);
  1033. z__1.r = sn * z__2.r, z__1.i = sn * z__2.i;
  1034. zrot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  1035. v_dim1 + 1], &c__1, &cs, &z__1);
  1036. }
  1037. }
  1038. i__6 = p;
  1039. i__7 = q;
  1040. z__2.r = -d__[i__7].r, z__2.i = -d__[
  1041. i__7].i;
  1042. z__1.r = z__2.r * ompq.r - z__2.i *
  1043. ompq.i, z__1.i = z__2.r *
  1044. ompq.i + z__2.i * ompq.r;
  1045. d__[i__6].r = z__1.r, d__[i__6].i =
  1046. z__1.i;
  1047. } else {
  1048. zcopy_(m, &a[p * a_dim1 + 1], &c__1, &
  1049. work[1], &c__1);
  1050. zlascl_("G", &c__0, &c__0, &aapp, &
  1051. c_b27, m, &c__1, &work[1],
  1052. lda, &ierr);
  1053. zlascl_("G", &c__0, &c__0, &aaqq, &
  1054. c_b27, m, &c__1, &a[q *
  1055. a_dim1 + 1], lda, &ierr);
  1056. z__1.r = -aapq.r, z__1.i = -aapq.i;
  1057. zaxpy_(m, &z__1, &work[1], &c__1, &a[
  1058. q * a_dim1 + 1], &c__1);
  1059. zlascl_("G", &c__0, &c__0, &c_b27, &
  1060. aaqq, m, &c__1, &a[q * a_dim1
  1061. + 1], lda, &ierr);
  1062. /* Computing MAX */
  1063. d__1 = 0., d__2 = 1. - aapq1 * aapq1;
  1064. sva[q] = aaqq * sqrt((f2cmax(d__1,d__2)))
  1065. ;
  1066. mxsinj = f2cmax(mxsinj,*sfmin);
  1067. }
  1068. /* END IF ROTOK THEN ... ELSE */
  1069. /* In the case of cancellation in updating SVA(q), SVA(p) */
  1070. /* recompute SVA(q), SVA(p). */
  1071. /* Computing 2nd power */
  1072. d__1 = sva[q] / aaqq;
  1073. if (d__1 * d__1 <= rooteps) {
  1074. if (aaqq < rootbig && aaqq >
  1075. rootsfmin) {
  1076. sva[q] = dznrm2_(m, &a[q * a_dim1
  1077. + 1], &c__1);
  1078. } else {
  1079. t = 0.;
  1080. aaqq = 1.;
  1081. zlassq_(m, &a[q * a_dim1 + 1], &
  1082. c__1, &t, &aaqq);
  1083. sva[q] = t * sqrt(aaqq);
  1084. }
  1085. }
  1086. if (aapp / aapp0 <= rooteps) {
  1087. if (aapp < rootbig && aapp >
  1088. rootsfmin) {
  1089. aapp = dznrm2_(m, &a[p * a_dim1 +
  1090. 1], &c__1);
  1091. } else {
  1092. t = 0.;
  1093. aapp = 1.;
  1094. zlassq_(m, &a[p * a_dim1 + 1], &
  1095. c__1, &t, &aapp);
  1096. aapp = t * sqrt(aapp);
  1097. }
  1098. sva[p] = aapp;
  1099. }
  1100. } else {
  1101. /* A(:,p) and A(:,q) already numerically orthogonal */
  1102. if (ir1 == 0) {
  1103. ++notrot;
  1104. }
  1105. /* [RTD] SKIPPED = SKIPPED + 1 */
  1106. ++pskipped;
  1107. }
  1108. } else {
  1109. /* A(:,q) is zero column */
  1110. if (ir1 == 0) {
  1111. ++notrot;
  1112. }
  1113. ++pskipped;
  1114. }
  1115. if (i__ <= swband && pskipped > rowskip) {
  1116. if (ir1 == 0) {
  1117. aapp = -aapp;
  1118. }
  1119. notrot = 0;
  1120. goto L2103;
  1121. }
  1122. /* L2002: */
  1123. }
  1124. /* END q-LOOP */
  1125. L2103:
  1126. /* bailed out of q-loop */
  1127. sva[p] = aapp;
  1128. } else {
  1129. sva[p] = aapp;
  1130. if (ir1 == 0 && aapp == 0.) {
  1131. /* Computing MIN */
  1132. i__5 = igl + kbl - 1;
  1133. notrot = notrot + f2cmin(i__5,*n) - p;
  1134. }
  1135. }
  1136. /* L2001: */
  1137. }
  1138. /* end of the p-loop */
  1139. /* end of doing the block ( ibr, ibr ) */
  1140. /* L1002: */
  1141. }
  1142. /* end of ir1-loop */
  1143. /* ... go to the off diagonal blocks */
  1144. igl = (ibr - 1) * kbl + 1;
  1145. i__3 = nbl;
  1146. for (jbc = ibr + 1; jbc <= i__3; ++jbc) {
  1147. jgl = (jbc - 1) * kbl + 1;
  1148. /* doing the block at ( ibr, jbc ) */
  1149. ijblsk = 0;
  1150. /* Computing MIN */
  1151. i__5 = igl + kbl - 1;
  1152. i__4 = f2cmin(i__5,*n);
  1153. for (p = igl; p <= i__4; ++p) {
  1154. aapp = sva[p];
  1155. if (aapp > 0.) {
  1156. pskipped = 0;
  1157. /* Computing MIN */
  1158. i__6 = jgl + kbl - 1;
  1159. i__5 = f2cmin(i__6,*n);
  1160. for (q = jgl; q <= i__5; ++q) {
  1161. aaqq = sva[q];
  1162. if (aaqq > 0.) {
  1163. aapp0 = aapp;
  1164. /* Safe Gram matrix computation */
  1165. if (aaqq >= 1.) {
  1166. if (aapp >= aaqq) {
  1167. rotok = small * aapp <= aaqq;
  1168. } else {
  1169. rotok = small * aaqq <= aapp;
  1170. }
  1171. if (aapp < big / aaqq) {
  1172. zdotc_(&z__3, m, &a[p * a_dim1 + 1], &
  1173. c__1, &a[q * a_dim1 + 1], &
  1174. c__1);
  1175. z__2.r = z__3.r / aaqq, z__2.i =
  1176. z__3.i / aaqq;
  1177. z__1.r = z__2.r / aapp, z__1.i =
  1178. z__2.i / aapp;
  1179. aapq.r = z__1.r, aapq.i = z__1.i;
  1180. } else {
  1181. zcopy_(m, &a[p * a_dim1 + 1], &c__1, &
  1182. work[1], &c__1);
  1183. zlascl_("G", &c__0, &c__0, &aapp, &
  1184. c_b27, m, &c__1, &work[1],
  1185. lda, &ierr);
  1186. zdotc_(&z__2, m, &work[1], &c__1, &a[
  1187. q * a_dim1 + 1], &c__1);
  1188. z__1.r = z__2.r / aaqq, z__1.i =
  1189. z__2.i / aaqq;
  1190. aapq.r = z__1.r, aapq.i = z__1.i;
  1191. }
  1192. } else {
  1193. if (aapp >= aaqq) {
  1194. rotok = aapp <= aaqq / small;
  1195. } else {
  1196. rotok = aaqq <= aapp / small;
  1197. }
  1198. if (aapp > small / aaqq) {
  1199. zdotc_(&z__3, m, &a[p * a_dim1 + 1], &
  1200. c__1, &a[q * a_dim1 + 1], &
  1201. c__1);
  1202. d__1 = f2cmax(aaqq,aapp);
  1203. z__2.r = z__3.r / d__1, z__2.i =
  1204. z__3.i / d__1;
  1205. d__2 = f2cmin(aaqq,aapp);
  1206. z__1.r = z__2.r / d__2, z__1.i =
  1207. z__2.i / d__2;
  1208. aapq.r = z__1.r, aapq.i = z__1.i;
  1209. } else {
  1210. zcopy_(m, &a[q * a_dim1 + 1], &c__1, &
  1211. work[1], &c__1);
  1212. zlascl_("G", &c__0, &c__0, &aaqq, &
  1213. c_b27, m, &c__1, &work[1],
  1214. lda, &ierr);
  1215. zdotc_(&z__2, m, &a[p * a_dim1 + 1], &
  1216. c__1, &work[1], &c__1);
  1217. z__1.r = z__2.r / aapp, z__1.i =
  1218. z__2.i / aapp;
  1219. aapq.r = z__1.r, aapq.i = z__1.i;
  1220. }
  1221. }
  1222. /* AAPQ = AAPQ * CONJG(CWORK(p))*CWORK(q) */
  1223. aapq1 = -z_abs(&aapq);
  1224. /* Computing MAX */
  1225. d__1 = mxaapq, d__2 = -aapq1;
  1226. mxaapq = f2cmax(d__1,d__2);
  1227. /* TO rotate or NOT to rotate, THAT is the question ... */
  1228. if (abs(aapq1) > *tol) {
  1229. d__1 = z_abs(&aapq);
  1230. z__1.r = aapq.r / d__1, z__1.i = aapq.i /
  1231. d__1;
  1232. ompq.r = z__1.r, ompq.i = z__1.i;
  1233. notrot = 0;
  1234. /* [RTD] ROTATED = ROTATED + 1 */
  1235. pskipped = 0;
  1236. ++iswrot;
  1237. if (rotok) {
  1238. aqoap = aaqq / aapp;
  1239. apoaq = aapp / aaqq;
  1240. theta = (d__1 = aqoap - apoaq, abs(
  1241. d__1)) * -.5 / aapq1;
  1242. if (aaqq > aapp0) {
  1243. theta = -theta;
  1244. }
  1245. if (abs(theta) > bigtheta) {
  1246. t = .5 / theta;
  1247. cs = 1.;
  1248. d_cnjg(&z__2, &ompq);
  1249. z__1.r = t * z__2.r, z__1.i = t *
  1250. z__2.i;
  1251. zrot_(m, &a[p * a_dim1 + 1], &
  1252. c__1, &a[q * a_dim1 + 1],
  1253. &c__1, &cs, &z__1);
  1254. if (rsvec) {
  1255. d_cnjg(&z__2, &ompq);
  1256. z__1.r = t * z__2.r, z__1.i = t * z__2.i;
  1257. zrot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  1258. v_dim1 + 1], &c__1, &cs, &z__1);
  1259. }
  1260. /* Computing MAX */
  1261. d__1 = 0., d__2 = t * apoaq *
  1262. aapq1 + 1.;
  1263. sva[q] = aaqq * sqrt((f2cmax(d__1,
  1264. d__2)));
  1265. /* Computing MAX */
  1266. d__1 = 0., d__2 = 1. - t * aqoap *
  1267. aapq1;
  1268. aapp *= sqrt((f2cmax(d__1,d__2)));
  1269. /* Computing MAX */
  1270. d__1 = mxsinj, d__2 = abs(t);
  1271. mxsinj = f2cmax(d__1,d__2);
  1272. } else {
  1273. thsign = -d_sign(&c_b27, &aapq1);
  1274. if (aaqq > aapp0) {
  1275. thsign = -thsign;
  1276. }
  1277. t = 1. / (theta + thsign * sqrt(
  1278. theta * theta + 1.));
  1279. cs = sqrt(1. / (t * t + 1.));
  1280. sn = t * cs;
  1281. /* Computing MAX */
  1282. d__1 = mxsinj, d__2 = abs(sn);
  1283. mxsinj = f2cmax(d__1,d__2);
  1284. /* Computing MAX */
  1285. d__1 = 0., d__2 = t * apoaq *
  1286. aapq1 + 1.;
  1287. sva[q] = aaqq * sqrt((f2cmax(d__1,
  1288. d__2)));
  1289. /* Computing MAX */
  1290. d__1 = 0., d__2 = 1. - t * aqoap *
  1291. aapq1;
  1292. aapp *= sqrt((f2cmax(d__1,d__2)));
  1293. d_cnjg(&z__2, &ompq);
  1294. z__1.r = sn * z__2.r, z__1.i = sn
  1295. * z__2.i;
  1296. zrot_(m, &a[p * a_dim1 + 1], &
  1297. c__1, &a[q * a_dim1 + 1],
  1298. &c__1, &cs, &z__1);
  1299. if (rsvec) {
  1300. d_cnjg(&z__2, &ompq);
  1301. z__1.r = sn * z__2.r, z__1.i = sn * z__2.i;
  1302. zrot_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
  1303. v_dim1 + 1], &c__1, &cs, &z__1);
  1304. }
  1305. }
  1306. i__6 = p;
  1307. i__7 = q;
  1308. z__2.r = -d__[i__7].r, z__2.i = -d__[
  1309. i__7].i;
  1310. z__1.r = z__2.r * ompq.r - z__2.i *
  1311. ompq.i, z__1.i = z__2.r *
  1312. ompq.i + z__2.i * ompq.r;
  1313. d__[i__6].r = z__1.r, d__[i__6].i =
  1314. z__1.i;
  1315. } else {
  1316. if (aapp > aaqq) {
  1317. zcopy_(m, &a[p * a_dim1 + 1], &
  1318. c__1, &work[1], &c__1);
  1319. zlascl_("G", &c__0, &c__0, &aapp,
  1320. &c_b27, m, &c__1, &work[1]
  1321. , lda, &ierr);
  1322. zlascl_("G", &c__0, &c__0, &aaqq,
  1323. &c_b27, m, &c__1, &a[q *
  1324. a_dim1 + 1], lda, &ierr);
  1325. z__1.r = -aapq.r, z__1.i =
  1326. -aapq.i;
  1327. zaxpy_(m, &z__1, &work[1], &c__1,
  1328. &a[q * a_dim1 + 1], &c__1)
  1329. ;
  1330. zlascl_("G", &c__0, &c__0, &c_b27,
  1331. &aaqq, m, &c__1, &a[q *
  1332. a_dim1 + 1], lda, &ierr);
  1333. /* Computing MAX */
  1334. d__1 = 0., d__2 = 1. - aapq1 *
  1335. aapq1;
  1336. sva[q] = aaqq * sqrt((f2cmax(d__1,
  1337. d__2)));
  1338. mxsinj = f2cmax(mxsinj,*sfmin);
  1339. } else {
  1340. zcopy_(m, &a[q * a_dim1 + 1], &
  1341. c__1, &work[1], &c__1);
  1342. zlascl_("G", &c__0, &c__0, &aaqq,
  1343. &c_b27, m, &c__1, &work[1]
  1344. , lda, &ierr);
  1345. zlascl_("G", &c__0, &c__0, &aapp,
  1346. &c_b27, m, &c__1, &a[p *
  1347. a_dim1 + 1], lda, &ierr);
  1348. d_cnjg(&z__2, &aapq);
  1349. z__1.r = -z__2.r, z__1.i =
  1350. -z__2.i;
  1351. zaxpy_(m, &z__1, &work[1], &c__1,
  1352. &a[p * a_dim1 + 1], &c__1)
  1353. ;
  1354. zlascl_("G", &c__0, &c__0, &c_b27,
  1355. &aapp, m, &c__1, &a[p *
  1356. a_dim1 + 1], lda, &ierr);
  1357. /* Computing MAX */
  1358. d__1 = 0., d__2 = 1. - aapq1 *
  1359. aapq1;
  1360. sva[p] = aapp * sqrt((f2cmax(d__1,
  1361. d__2)));
  1362. mxsinj = f2cmax(mxsinj,*sfmin);
  1363. }
  1364. }
  1365. /* END IF ROTOK THEN ... ELSE */
  1366. /* In the case of cancellation in updating SVA(q), SVA(p) */
  1367. /* Computing 2nd power */
  1368. d__1 = sva[q] / aaqq;
  1369. if (d__1 * d__1 <= rooteps) {
  1370. if (aaqq < rootbig && aaqq >
  1371. rootsfmin) {
  1372. sva[q] = dznrm2_(m, &a[q * a_dim1
  1373. + 1], &c__1);
  1374. } else {
  1375. t = 0.;
  1376. aaqq = 1.;
  1377. zlassq_(m, &a[q * a_dim1 + 1], &
  1378. c__1, &t, &aaqq);
  1379. sva[q] = t * sqrt(aaqq);
  1380. }
  1381. }
  1382. /* Computing 2nd power */
  1383. d__1 = aapp / aapp0;
  1384. if (d__1 * d__1 <= rooteps) {
  1385. if (aapp < rootbig && aapp >
  1386. rootsfmin) {
  1387. aapp = dznrm2_(m, &a[p * a_dim1 +
  1388. 1], &c__1);
  1389. } else {
  1390. t = 0.;
  1391. aapp = 1.;
  1392. zlassq_(m, &a[p * a_dim1 + 1], &
  1393. c__1, &t, &aapp);
  1394. aapp = t * sqrt(aapp);
  1395. }
  1396. sva[p] = aapp;
  1397. }
  1398. /* end of OK rotation */
  1399. } else {
  1400. ++notrot;
  1401. /* [RTD] SKIPPED = SKIPPED + 1 */
  1402. ++pskipped;
  1403. ++ijblsk;
  1404. }
  1405. } else {
  1406. ++notrot;
  1407. ++pskipped;
  1408. ++ijblsk;
  1409. }
  1410. if (i__ <= swband && ijblsk >= blskip) {
  1411. sva[p] = aapp;
  1412. notrot = 0;
  1413. goto L2011;
  1414. }
  1415. if (i__ <= swband && pskipped > rowskip) {
  1416. aapp = -aapp;
  1417. notrot = 0;
  1418. goto L2203;
  1419. }
  1420. /* L2200: */
  1421. }
  1422. /* end of the q-loop */
  1423. L2203:
  1424. sva[p] = aapp;
  1425. } else {
  1426. if (aapp == 0.) {
  1427. /* Computing MIN */
  1428. i__5 = jgl + kbl - 1;
  1429. notrot = notrot + f2cmin(i__5,*n) - jgl + 1;
  1430. }
  1431. if (aapp < 0.) {
  1432. notrot = 0;
  1433. }
  1434. }
  1435. /* L2100: */
  1436. }
  1437. /* end of the p-loop */
  1438. /* L2010: */
  1439. }
  1440. /* end of the jbc-loop */
  1441. L2011:
  1442. /* 2011 bailed out of the jbc-loop */
  1443. /* Computing MIN */
  1444. i__4 = igl + kbl - 1;
  1445. i__3 = f2cmin(i__4,*n);
  1446. for (p = igl; p <= i__3; ++p) {
  1447. sva[p] = (d__1 = sva[p], abs(d__1));
  1448. /* L2012: */
  1449. }
  1450. /* ** */
  1451. /* L2000: */
  1452. }
  1453. /* 2000 :: end of the ibr-loop */
  1454. if (sva[*n] < rootbig && sva[*n] > rootsfmin) {
  1455. sva[*n] = dznrm2_(m, &a[*n * a_dim1 + 1], &c__1);
  1456. } else {
  1457. t = 0.;
  1458. aapp = 1.;
  1459. zlassq_(m, &a[*n * a_dim1 + 1], &c__1, &t, &aapp);
  1460. sva[*n] = t * sqrt(aapp);
  1461. }
  1462. /* Additional steering devices */
  1463. if (i__ < swband && (mxaapq <= roottol || iswrot <= *n)) {
  1464. swband = i__;
  1465. }
  1466. if (i__ > swband + 1 && mxaapq < sqrt((doublereal) (*n)) * *tol && (
  1467. doublereal) (*n) * mxaapq * mxsinj < *tol) {
  1468. goto L1994;
  1469. }
  1470. if (notrot >= emptsw) {
  1471. goto L1994;
  1472. }
  1473. /* L1993: */
  1474. }
  1475. /* end i=1:NSWEEP loop */
  1476. /* #:( Reaching this point means that the procedure has not converged. */
  1477. *info = *nsweep - 1;
  1478. goto L1995;
  1479. L1994:
  1480. /* #:) Reaching this point means numerical convergence after the i-th */
  1481. /* sweep. */
  1482. *info = 0;
  1483. /* #:) INFO = 0 confirms successful iterations. */
  1484. L1995:
  1485. /* Sort the vector SVA() of column norms. */
  1486. i__1 = *n - 1;
  1487. for (p = 1; p <= i__1; ++p) {
  1488. i__2 = *n - p + 1;
  1489. q = idamax_(&i__2, &sva[p], &c__1) + p - 1;
  1490. if (p != q) {
  1491. temp1 = sva[p];
  1492. sva[p] = sva[q];
  1493. sva[q] = temp1;
  1494. i__2 = p;
  1495. aapq.r = d__[i__2].r, aapq.i = d__[i__2].i;
  1496. i__2 = p;
  1497. i__3 = q;
  1498. d__[i__2].r = d__[i__3].r, d__[i__2].i = d__[i__3].i;
  1499. i__2 = q;
  1500. d__[i__2].r = aapq.r, d__[i__2].i = aapq.i;
  1501. zswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 + 1], &c__1);
  1502. if (rsvec) {
  1503. zswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * v_dim1 + 1], &
  1504. c__1);
  1505. }
  1506. }
  1507. /* L5991: */
  1508. }
  1509. return;
  1510. } /* zgsvj0_ */