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.

zlatmt.c 66 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229
  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 int logical;
  52. typedef short int shortlogical;
  53. typedef char logical1;
  54. typedef char integer1;
  55. #define TRUE_ (1)
  56. #define FALSE_ (0)
  57. /* Extern is for use with -E */
  58. #ifndef Extern
  59. #define Extern extern
  60. #endif
  61. /* I/O stuff */
  62. typedef int flag;
  63. typedef int ftnlen;
  64. typedef int ftnint;
  65. /*external read, write*/
  66. typedef struct
  67. { flag cierr;
  68. ftnint ciunit;
  69. flag ciend;
  70. char *cifmt;
  71. ftnint cirec;
  72. } cilist;
  73. /*internal read, write*/
  74. typedef struct
  75. { flag icierr;
  76. char *iciunit;
  77. flag iciend;
  78. char *icifmt;
  79. ftnint icirlen;
  80. ftnint icirnum;
  81. } icilist;
  82. /*open*/
  83. typedef struct
  84. { flag oerr;
  85. ftnint ounit;
  86. char *ofnm;
  87. ftnlen ofnmlen;
  88. char *osta;
  89. char *oacc;
  90. char *ofm;
  91. ftnint orl;
  92. char *oblnk;
  93. } olist;
  94. /*close*/
  95. typedef struct
  96. { flag cerr;
  97. ftnint cunit;
  98. char *csta;
  99. } cllist;
  100. /*rewind, backspace, endfile*/
  101. typedef struct
  102. { flag aerr;
  103. ftnint aunit;
  104. } alist;
  105. /* inquire */
  106. typedef struct
  107. { flag inerr;
  108. ftnint inunit;
  109. char *infile;
  110. ftnlen infilen;
  111. ftnint *inex; /*parameters in standard's order*/
  112. ftnint *inopen;
  113. ftnint *innum;
  114. ftnint *innamed;
  115. char *inname;
  116. ftnlen innamlen;
  117. char *inacc;
  118. ftnlen inacclen;
  119. char *inseq;
  120. ftnlen inseqlen;
  121. char *indir;
  122. ftnlen indirlen;
  123. char *infmt;
  124. ftnlen infmtlen;
  125. char *inform;
  126. ftnint informlen;
  127. char *inunf;
  128. ftnlen inunflen;
  129. ftnint *inrecl;
  130. ftnint *innrec;
  131. char *inblank;
  132. ftnlen inblanklen;
  133. } inlist;
  134. #define VOID void
  135. union Multitype { /* for multiple entry points */
  136. integer1 g;
  137. shortint h;
  138. integer i;
  139. /* longint j; */
  140. real r;
  141. doublereal d;
  142. complex c;
  143. doublecomplex z;
  144. };
  145. typedef union Multitype Multitype;
  146. struct Vardesc { /* for Namelist */
  147. char *name;
  148. char *addr;
  149. ftnlen *dims;
  150. int type;
  151. };
  152. typedef struct Vardesc Vardesc;
  153. struct Namelist {
  154. char *name;
  155. Vardesc **vars;
  156. int nvars;
  157. };
  158. typedef struct Namelist Namelist;
  159. #define abs(x) ((x) >= 0 ? (x) : -(x))
  160. #define dabs(x) (fabs(x))
  161. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  162. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  163. #define dmin(a,b) (f2cmin(a,b))
  164. #define dmax(a,b) (f2cmax(a,b))
  165. #define bit_test(a,b) ((a) >> (b) & 1)
  166. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  167. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  168. #define abort_() { sig_die("Fortran abort routine called", 1); }
  169. #define c_abs(z) (cabsf(Cf(z)))
  170. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  171. #ifdef _MSC_VER
  172. #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]);}
  173. #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]/Cd(b)._Val[1]);}
  174. #else
  175. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  176. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  177. #endif
  178. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  179. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  180. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  181. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  182. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  183. #define d_abs(x) (fabs(*(x)))
  184. #define d_acos(x) (acos(*(x)))
  185. #define d_asin(x) (asin(*(x)))
  186. #define d_atan(x) (atan(*(x)))
  187. #define d_atn2(x, y) (atan2(*(x),*(y)))
  188. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  189. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  190. #define d_cos(x) (cos(*(x)))
  191. #define d_cosh(x) (cosh(*(x)))
  192. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  193. #define d_exp(x) (exp(*(x)))
  194. #define d_imag(z) (cimag(Cd(z)))
  195. #define r_imag(z) (cimagf(Cf(z)))
  196. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  198. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  200. #define d_log(x) (log(*(x)))
  201. #define d_mod(x, y) (fmod(*(x), *(y)))
  202. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  203. #define d_nint(x) u_nint(*(x))
  204. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  205. #define d_sign(a,b) u_sign(*(a),*(b))
  206. #define r_sign(a,b) u_sign(*(a),*(b))
  207. #define d_sin(x) (sin(*(x)))
  208. #define d_sinh(x) (sinh(*(x)))
  209. #define d_sqrt(x) (sqrt(*(x)))
  210. #define d_tan(x) (tan(*(x)))
  211. #define d_tanh(x) (tanh(*(x)))
  212. #define i_abs(x) abs(*(x))
  213. #define i_dnnt(x) ((integer)u_nint(*(x)))
  214. #define i_len(s, n) (n)
  215. #define i_nint(x) ((integer)u_nint(*(x)))
  216. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  217. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  218. #define pow_si(B,E) spow_ui(*(B),*(E))
  219. #define pow_ri(B,E) spow_ui(*(B),*(E))
  220. #define pow_di(B,E) dpow_ui(*(B),*(E))
  221. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  222. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  223. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  224. #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++ = ' '; }
  225. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  226. #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]; }
  227. #define sig_die(s, kill) { exit(1); }
  228. #define s_stop(s, n) {exit(0);}
  229. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  230. #define z_abs(z) (cabs(Cd(z)))
  231. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  232. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  233. #define myexit_() break;
  234. #define mycycle_() continue;
  235. #define myceiling_(w) {ceil(w)}
  236. #define myhuge_(w) {HUGE_VAL}
  237. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  238. #define mymaxloc_(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  239. /* procedure parameter types for -A and -C++ */
  240. #define F2C_proc_par_types 1
  241. #ifdef __cplusplus
  242. typedef logical (*L_fp)(...);
  243. #else
  244. typedef logical (*L_fp)();
  245. #endif
  246. static float spow_ui(float x, integer n) {
  247. float pow=1.0; unsigned long int u;
  248. if(n != 0) {
  249. if(n < 0) n = -n, x = 1/x;
  250. for(u = n; ; ) {
  251. if(u & 01) pow *= x;
  252. if(u >>= 1) x *= x;
  253. else break;
  254. }
  255. }
  256. return pow;
  257. }
  258. static double dpow_ui(double x, integer n) {
  259. double pow=1.0; unsigned long int u;
  260. if(n != 0) {
  261. if(n < 0) n = -n, x = 1/x;
  262. for(u = n; ; ) {
  263. if(u & 01) pow *= x;
  264. if(u >>= 1) x *= x;
  265. else break;
  266. }
  267. }
  268. return pow;
  269. }
  270. #ifdef _MSC_VER
  271. static _Fcomplex cpow_ui(complex x, integer n) {
  272. complex pow={1.0,0.0}; unsigned long int u;
  273. if(n != 0) {
  274. if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
  275. for(u = n; ; ) {
  276. if(u & 01) pow.r *= x.r, pow.i *= x.i;
  277. if(u >>= 1) x.r *= x.r, x.i *= x.i;
  278. else break;
  279. }
  280. }
  281. _Fcomplex p={pow.r, pow.i};
  282. return p;
  283. }
  284. #else
  285. static _Complex float cpow_ui(_Complex float x, integer n) {
  286. _Complex float pow=1.0; unsigned long int u;
  287. if(n != 0) {
  288. if(n < 0) n = -n, x = 1/x;
  289. for(u = n; ; ) {
  290. if(u & 01) pow *= x;
  291. if(u >>= 1) x *= x;
  292. else break;
  293. }
  294. }
  295. return pow;
  296. }
  297. #endif
  298. #ifdef _MSC_VER
  299. static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
  300. _Dcomplex pow={1.0,0.0}; unsigned long int u;
  301. if(n != 0) {
  302. if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
  303. for(u = n; ; ) {
  304. if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
  305. if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
  306. else break;
  307. }
  308. }
  309. _Dcomplex p = {pow._Val[0], pow._Val[1]};
  310. return p;
  311. }
  312. #else
  313. static _Complex double zpow_ui(_Complex double x, integer n) {
  314. _Complex double pow=1.0; unsigned long int u;
  315. if(n != 0) {
  316. if(n < 0) n = -n, x = 1/x;
  317. for(u = n; ; ) {
  318. if(u & 01) pow *= x;
  319. if(u >>= 1) x *= x;
  320. else break;
  321. }
  322. }
  323. return pow;
  324. }
  325. #endif
  326. static integer pow_ii(integer x, integer n) {
  327. integer pow; unsigned long int u;
  328. if (n <= 0) {
  329. if (n == 0 || x == 1) pow = 1;
  330. else if (x != -1) pow = x == 0 ? 1/x : 0;
  331. else n = -n;
  332. }
  333. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  334. u = n;
  335. for(pow = 1; ; ) {
  336. if(u & 01) pow *= x;
  337. if(u >>= 1) x *= x;
  338. else break;
  339. }
  340. }
  341. return pow;
  342. }
  343. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  344. {
  345. double m; integer i, mi;
  346. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  347. if (w[i-1]>m) mi=i ,m=w[i-1];
  348. return mi-s+1;
  349. }
  350. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  351. {
  352. float m; integer i, mi;
  353. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  354. if (w[i-1]>m) mi=i ,m=w[i-1];
  355. return mi-s+1;
  356. }
  357. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  358. integer n = *n_, incx = *incx_, incy = *incy_, i;
  359. #ifdef _MSC_VER
  360. _Fcomplex zdotc = {0.0, 0.0};
  361. if (incx == 1 && incy == 1) {
  362. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  363. zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
  364. zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
  365. }
  366. } else {
  367. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  368. zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
  369. zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
  370. }
  371. }
  372. pCf(z) = zdotc;
  373. }
  374. #else
  375. _Complex float zdotc = 0.0;
  376. if (incx == 1 && incy == 1) {
  377. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  378. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  379. }
  380. } else {
  381. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  382. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  383. }
  384. }
  385. pCf(z) = zdotc;
  386. }
  387. #endif
  388. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  389. integer n = *n_, incx = *incx_, incy = *incy_, i;
  390. #ifdef _MSC_VER
  391. _Dcomplex zdotc = {0.0, 0.0};
  392. if (incx == 1 && incy == 1) {
  393. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  394. zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
  395. zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
  396. }
  397. } else {
  398. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  399. zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
  400. zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
  401. }
  402. }
  403. pCd(z) = zdotc;
  404. }
  405. #else
  406. _Complex double zdotc = 0.0;
  407. if (incx == 1 && incy == 1) {
  408. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  409. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  410. }
  411. } else {
  412. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  413. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  414. }
  415. }
  416. pCd(z) = zdotc;
  417. }
  418. #endif
  419. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  420. integer n = *n_, incx = *incx_, incy = *incy_, i;
  421. #ifdef _MSC_VER
  422. _Fcomplex zdotc = {0.0, 0.0};
  423. if (incx == 1 && incy == 1) {
  424. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  425. zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
  426. zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
  427. }
  428. } else {
  429. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  430. zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
  431. zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
  432. }
  433. }
  434. pCf(z) = zdotc;
  435. }
  436. #else
  437. _Complex float zdotc = 0.0;
  438. if (incx == 1 && incy == 1) {
  439. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  440. zdotc += Cf(&x[i]) * Cf(&y[i]);
  441. }
  442. } else {
  443. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  444. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  445. }
  446. }
  447. pCf(z) = zdotc;
  448. }
  449. #endif
  450. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  451. integer n = *n_, incx = *incx_, incy = *incy_, i;
  452. #ifdef _MSC_VER
  453. _Dcomplex zdotc = {0.0, 0.0};
  454. if (incx == 1 && incy == 1) {
  455. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  456. zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
  457. zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
  458. }
  459. } else {
  460. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  461. zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
  462. zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
  463. }
  464. }
  465. pCd(z) = zdotc;
  466. }
  467. #else
  468. _Complex double zdotc = 0.0;
  469. if (incx == 1 && incy == 1) {
  470. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  471. zdotc += Cd(&x[i]) * Cd(&y[i]);
  472. }
  473. } else {
  474. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  475. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  476. }
  477. }
  478. pCd(z) = zdotc;
  479. }
  480. #endif
  481. /* -- translated by f2c (version 20000121).
  482. You must link the resulting object file with the libraries:
  483. -lf2c -lm (in that order)
  484. */
  485. /* Table of constant values */
  486. static doublecomplex c_b1 = {0.,0.};
  487. static integer c__1 = 1;
  488. static integer c__5 = 5;
  489. static logical c_true = TRUE_;
  490. static logical c_false = FALSE_;
  491. /* > \brief \b ZLATMT */
  492. /* =========== DOCUMENTATION =========== */
  493. /* Online html documentation available at */
  494. /* http://www.netlib.org/lapack/explore-html/ */
  495. /* Definition: */
  496. /* =========== */
  497. /* SUBROUTINE ZLATMT( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
  498. /* RANK, KL, KU, PACK, A, LDA, WORK, INFO ) */
  499. /* DOUBLE PRECISION COND, DMAX */
  500. /* INTEGER INFO, KL, KU, LDA, M, MODE, N, RANK */
  501. /* CHARACTER DIST, PACK, SYM */
  502. /* COMPLEX*16 A( LDA, * ), WORK( * ) */
  503. /* DOUBLE PRECISION D( * ) */
  504. /* INTEGER ISEED( 4 ) */
  505. /* > \par Purpose: */
  506. /* ============= */
  507. /* > */
  508. /* > \verbatim */
  509. /* > */
  510. /* > ZLATMT generates random matrices with specified singular values */
  511. /* > (or hermitian with specified eigenvalues) */
  512. /* > for testing LAPACK programs. */
  513. /* > */
  514. /* > ZLATMT operates by applying the following sequence of */
  515. /* > operations: */
  516. /* > */
  517. /* > Set the diagonal to D, where D may be input or */
  518. /* > computed according to MODE, COND, DMAX, and SYM */
  519. /* > as described below. */
  520. /* > */
  521. /* > Generate a matrix with the appropriate band structure, by one */
  522. /* > of two methods: */
  523. /* > */
  524. /* > Method A: */
  525. /* > Generate a dense M x N matrix by multiplying D on the left */
  526. /* > and the right by random unitary matrices, then: */
  527. /* > */
  528. /* > Reduce the bandwidth according to KL and KU, using */
  529. /* > Householder transformations. */
  530. /* > */
  531. /* > Method B: */
  532. /* > Convert the bandwidth-0 (i.e., diagonal) matrix to a */
  533. /* > bandwidth-1 matrix using Givens rotations, "chasing" */
  534. /* > out-of-band elements back, much as in QR; then convert */
  535. /* > the bandwidth-1 to a bandwidth-2 matrix, etc. Note */
  536. /* > that for reasonably small bandwidths (relative to M and */
  537. /* > N) this requires less storage, as a dense matrix is not */
  538. /* > generated. Also, for hermitian or symmetric matrices, */
  539. /* > only one triangle is generated. */
  540. /* > */
  541. /* > Method A is chosen if the bandwidth is a large fraction of the */
  542. /* > order of the matrix, and LDA is at least M (so a dense */
  543. /* > matrix can be stored.) Method B is chosen if the bandwidth */
  544. /* > is small (< 1/2 N for hermitian or symmetric, < .3 N+M for */
  545. /* > non-symmetric), or LDA is less than M and not less than the */
  546. /* > bandwidth. */
  547. /* > */
  548. /* > Pack the matrix if desired. Options specified by PACK are: */
  549. /* > no packing */
  550. /* > zero out upper half (if hermitian) */
  551. /* > zero out lower half (if hermitian) */
  552. /* > store the upper half columnwise (if hermitian or upper */
  553. /* > triangular) */
  554. /* > store the lower half columnwise (if hermitian or lower */
  555. /* > triangular) */
  556. /* > store the lower triangle in banded format (if hermitian or */
  557. /* > lower triangular) */
  558. /* > store the upper triangle in banded format (if hermitian or */
  559. /* > upper triangular) */
  560. /* > store the entire matrix in banded format */
  561. /* > If Method B is chosen, and band format is specified, then the */
  562. /* > matrix will be generated in the band format, so no repacking */
  563. /* > will be necessary. */
  564. /* > \endverbatim */
  565. /* Arguments: */
  566. /* ========== */
  567. /* > \param[in] M */
  568. /* > \verbatim */
  569. /* > M is INTEGER */
  570. /* > The number of rows of A. Not modified. */
  571. /* > \endverbatim */
  572. /* > */
  573. /* > \param[in] N */
  574. /* > \verbatim */
  575. /* > N is INTEGER */
  576. /* > The number of columns of A. N must equal M if the matrix */
  577. /* > is symmetric or hermitian (i.e., if SYM is not 'N') */
  578. /* > Not modified. */
  579. /* > \endverbatim */
  580. /* > */
  581. /* > \param[in] DIST */
  582. /* > \verbatim */
  583. /* > DIST is CHARACTER*1 */
  584. /* > On entry, DIST specifies the type of distribution to be used */
  585. /* > to generate the random eigen-/singular values. */
  586. /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
  587. /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
  588. /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
  589. /* > Not modified. */
  590. /* > \endverbatim */
  591. /* > */
  592. /* > \param[in,out] ISEED */
  593. /* > \verbatim */
  594. /* > ISEED is INTEGER array, dimension ( 4 ) */
  595. /* > On entry ISEED specifies the seed of the random number */
  596. /* > generator. They should lie between 0 and 4095 inclusive, */
  597. /* > and ISEED(4) should be odd. The random number generator */
  598. /* > uses a linear congruential sequence limited to small */
  599. /* > integers, and so should produce machine independent */
  600. /* > random numbers. The values of ISEED are changed on */
  601. /* > exit, and can be used in the next call to ZLATMT */
  602. /* > to continue the same random number sequence. */
  603. /* > Changed on exit. */
  604. /* > \endverbatim */
  605. /* > */
  606. /* > \param[in] SYM */
  607. /* > \verbatim */
  608. /* > SYM is CHARACTER*1 */
  609. /* > If SYM='H', the generated matrix is hermitian, with */
  610. /* > eigenvalues specified by D, COND, MODE, and DMAX; they */
  611. /* > may be positive, negative, or zero. */
  612. /* > If SYM='P', the generated matrix is hermitian, with */
  613. /* > eigenvalues (= singular values) specified by D, COND, */
  614. /* > MODE, and DMAX; they will not be negative. */
  615. /* > If SYM='N', the generated matrix is nonsymmetric, with */
  616. /* > singular values specified by D, COND, MODE, and DMAX; */
  617. /* > they will not be negative. */
  618. /* > If SYM='S', the generated matrix is (complex) symmetric, */
  619. /* > with singular values specified by D, COND, MODE, and */
  620. /* > DMAX; they will not be negative. */
  621. /* > Not modified. */
  622. /* > \endverbatim */
  623. /* > */
  624. /* > \param[in,out] D */
  625. /* > \verbatim */
  626. /* > D is DOUBLE PRECISION array, dimension ( MIN( M, N ) ) */
  627. /* > This array is used to specify the singular values or */
  628. /* > eigenvalues of A (see SYM, above.) If MODE=0, then D is */
  629. /* > assumed to contain the singular/eigenvalues, otherwise */
  630. /* > they will be computed according to MODE, COND, and DMAX, */
  631. /* > and placed in D. */
  632. /* > Modified if MODE is nonzero. */
  633. /* > \endverbatim */
  634. /* > */
  635. /* > \param[in] MODE */
  636. /* > \verbatim */
  637. /* > MODE is INTEGER */
  638. /* > On entry this describes how the singular/eigenvalues are to */
  639. /* > be specified: */
  640. /* > MODE = 0 means use D as input */
  641. /* > MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND */
  642. /* > MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND */
  643. /* > MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1)) */
  644. /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
  645. /* > MODE = 5 sets D to random numbers in the range */
  646. /* > ( 1/COND , 1 ) such that their logarithms */
  647. /* > are uniformly distributed. */
  648. /* > MODE = 6 set D to random numbers from same distribution */
  649. /* > as the rest of the matrix. */
  650. /* > MODE < 0 has the same meaning as ABS(MODE), except that */
  651. /* > the order of the elements of D is reversed. */
  652. /* > Thus if MODE is positive, D has entries ranging from */
  653. /* > 1 to 1/COND, if negative, from 1/COND to 1, */
  654. /* > If SYM='H', and MODE is neither 0, 6, nor -6, then */
  655. /* > the elements of D will also be multiplied by a random */
  656. /* > sign (i.e., +1 or -1.) */
  657. /* > Not modified. */
  658. /* > \endverbatim */
  659. /* > */
  660. /* > \param[in] COND */
  661. /* > \verbatim */
  662. /* > COND is DOUBLE PRECISION */
  663. /* > On entry, this is used as described under MODE above. */
  664. /* > If used, it must be >= 1. Not modified. */
  665. /* > \endverbatim */
  666. /* > */
  667. /* > \param[in] DMAX */
  668. /* > \verbatim */
  669. /* > DMAX is DOUBLE PRECISION */
  670. /* > If MODE is neither -6, 0 nor 6, the contents of D, as */
  671. /* > computed according to MODE and COND, will be scaled by */
  672. /* > DMAX / f2cmax(abs(D(i))); thus, the maximum absolute eigen- or */
  673. /* > singular value (which is to say the norm) will be abs(DMAX). */
  674. /* > Note that DMAX need not be positive: if DMAX is negative */
  675. /* > (or zero), D will be scaled by a negative number (or zero). */
  676. /* > Not modified. */
  677. /* > \endverbatim */
  678. /* > */
  679. /* > \param[in] RANK */
  680. /* > \verbatim */
  681. /* > RANK is INTEGER */
  682. /* > The rank of matrix to be generated for modes 1,2,3 only. */
  683. /* > D( RANK+1:N ) = 0. */
  684. /* > Not modified. */
  685. /* > \endverbatim */
  686. /* > */
  687. /* > \param[in] KL */
  688. /* > \verbatim */
  689. /* > KL is INTEGER */
  690. /* > This specifies the lower bandwidth of the matrix. For */
  691. /* > example, KL=0 implies upper triangular, KL=1 implies upper */
  692. /* > Hessenberg, and KL being at least M-1 means that the matrix */
  693. /* > has full lower bandwidth. KL must equal KU if the matrix */
  694. /* > is symmetric or hermitian. */
  695. /* > Not modified. */
  696. /* > \endverbatim */
  697. /* > */
  698. /* > \param[in] KU */
  699. /* > \verbatim */
  700. /* > KU is INTEGER */
  701. /* > This specifies the upper bandwidth of the matrix. For */
  702. /* > example, KU=0 implies lower triangular, KU=1 implies lower */
  703. /* > Hessenberg, and KU being at least N-1 means that the matrix */
  704. /* > has full upper bandwidth. KL must equal KU if the matrix */
  705. /* > is symmetric or hermitian. */
  706. /* > Not modified. */
  707. /* > \endverbatim */
  708. /* > */
  709. /* > \param[in] PACK */
  710. /* > \verbatim */
  711. /* > PACK is CHARACTER*1 */
  712. /* > This specifies packing of matrix as follows: */
  713. /* > 'N' => no packing */
  714. /* > 'U' => zero out all subdiagonal entries (if symmetric */
  715. /* > or hermitian) */
  716. /* > 'L' => zero out all superdiagonal entries (if symmetric */
  717. /* > or hermitian) */
  718. /* > 'C' => store the upper triangle columnwise (only if the */
  719. /* > matrix is symmetric, hermitian, or upper triangular) */
  720. /* > 'R' => store the lower triangle columnwise (only if the */
  721. /* > matrix is symmetric, hermitian, or lower triangular) */
  722. /* > 'B' => store the lower triangle in band storage scheme */
  723. /* > (only if the matrix is symmetric, hermitian, or */
  724. /* > lower triangular) */
  725. /* > 'Q' => store the upper triangle in band storage scheme */
  726. /* > (only if the matrix is symmetric, hermitian, or */
  727. /* > upper triangular) */
  728. /* > 'Z' => store the entire matrix in band storage scheme */
  729. /* > (pivoting can be provided for by using this */
  730. /* > option to store A in the trailing rows of */
  731. /* > the allocated storage) */
  732. /* > */
  733. /* > Using these options, the various LAPACK packed and banded */
  734. /* > storage schemes can be obtained: */
  735. /* > GB - use 'Z' */
  736. /* > PB, SB, HB, or TB - use 'B' or 'Q' */
  737. /* > PP, SP, HB, or TP - use 'C' or 'R' */
  738. /* > */
  739. /* > If two calls to ZLATMT differ only in the PACK parameter, */
  740. /* > they will generate mathematically equivalent matrices. */
  741. /* > Not modified. */
  742. /* > \endverbatim */
  743. /* > */
  744. /* > \param[in,out] A */
  745. /* > \verbatim */
  746. /* > A is COMPLEX*16 array, dimension ( LDA, N ) */
  747. /* > On exit A is the desired test matrix. A is first generated */
  748. /* > in full (unpacked) form, and then packed, if so specified */
  749. /* > by PACK. Thus, the first M elements of the first N */
  750. /* > columns will always be modified. If PACK specifies a */
  751. /* > packed or banded storage scheme, all LDA elements of the */
  752. /* > first N columns will be modified; the elements of the */
  753. /* > array which do not correspond to elements of the generated */
  754. /* > matrix are set to zero. */
  755. /* > Modified. */
  756. /* > \endverbatim */
  757. /* > */
  758. /* > \param[in] LDA */
  759. /* > \verbatim */
  760. /* > LDA is INTEGER */
  761. /* > LDA specifies the first dimension of A as declared in the */
  762. /* > calling program. If PACK='N', 'U', 'L', 'C', or 'R', then */
  763. /* > LDA must be at least M. If PACK='B' or 'Q', then LDA must */
  764. /* > be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)). */
  765. /* > If PACK='Z', LDA must be large enough to hold the packed */
  766. /* > array: MIN( KU, N-1) + MIN( KL, M-1) + 1. */
  767. /* > Not modified. */
  768. /* > \endverbatim */
  769. /* > */
  770. /* > \param[out] WORK */
  771. /* > \verbatim */
  772. /* > WORK is COMPLEX*16 array, dimension ( 3*MAX( N, M ) ) */
  773. /* > Workspace. */
  774. /* > Modified. */
  775. /* > \endverbatim */
  776. /* > */
  777. /* > \param[out] INFO */
  778. /* > \verbatim */
  779. /* > INFO is INTEGER */
  780. /* > Error code. On exit, INFO will be set to one of the */
  781. /* > following values: */
  782. /* > 0 => normal return */
  783. /* > -1 => M negative or unequal to N and SYM='S', 'H', or 'P' */
  784. /* > -2 => N negative */
  785. /* > -3 => DIST illegal string */
  786. /* > -5 => SYM illegal string */
  787. /* > -7 => MODE not in range -6 to 6 */
  788. /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
  789. /* > -10 => KL negative */
  790. /* > -11 => KU negative, or SYM is not 'N' and KU is not equal to */
  791. /* > KL */
  792. /* > -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N'; */
  793. /* > or PACK='C' or 'Q' and SYM='N' and KL is not zero; */
  794. /* > or PACK='R' or 'B' and SYM='N' and KU is not zero; */
  795. /* > or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not */
  796. /* > N. */
  797. /* > -14 => LDA is less than M, or PACK='Z' and LDA is less than */
  798. /* > MIN(KU,N-1) + MIN(KL,M-1) + 1. */
  799. /* > 1 => Error return from DLATM7 */
  800. /* > 2 => Cannot scale to DMAX (f2cmax. sing. value is 0) */
  801. /* > 3 => Error return from ZLAGGE, ZLAGHE or ZLAGSY */
  802. /* > \endverbatim */
  803. /* Authors: */
  804. /* ======== */
  805. /* > \author Univ. of Tennessee */
  806. /* > \author Univ. of California Berkeley */
  807. /* > \author Univ. of Colorado Denver */
  808. /* > \author NAG Ltd. */
  809. /* > \date December 2016 */
  810. /* > \ingroup complex16_matgen */
  811. /* ===================================================================== */
  812. /* Subroutine */ int zlatmt_(integer *m, integer *n, char *dist, integer *
  813. iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
  814. doublereal *dmax__, integer *rank, integer *kl, integer *ku, char *
  815. pack, doublecomplex *a, integer *lda, doublecomplex *work, integer *
  816. info)
  817. {
  818. /* System generated locals */
  819. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  820. doublereal d__1, d__2, d__3;
  821. doublecomplex z__1, z__2, z__3;
  822. logical L__1;
  823. /* Local variables */
  824. integer ilda, icol;
  825. doublereal temp;
  826. logical csym;
  827. integer irow, isym;
  828. doublecomplex c__;
  829. integer i__, j, k;
  830. doublecomplex s;
  831. doublereal alpha, angle, realc;
  832. integer ipack, ioffg;
  833. extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
  834. integer *);
  835. extern logical lsame_(char *, char *);
  836. integer iinfo, idist, mnmin;
  837. doublecomplex extra;
  838. integer iskew;
  839. doublecomplex dummy, ztemp;
  840. extern /* Subroutine */ int dlatm7_(integer *, doublereal *, integer *,
  841. integer *, integer *, doublereal *, integer *, integer *, integer
  842. *);
  843. integer ic, jc, nc, il;
  844. doublecomplex ct;
  845. integer iendch, ir, jr, ipackg, mr, minlda;
  846. extern doublereal dlarnd_(integer *, integer *);
  847. doublecomplex st;
  848. extern /* Subroutine */ int zlagge_(integer *, integer *, integer *,
  849. integer *, doublereal *, doublecomplex *, integer *, integer *,
  850. doublecomplex *, integer *), zlaghe_(integer *, integer *,
  851. doublereal *, doublecomplex *, integer *, integer *,
  852. doublecomplex *, integer *), xerbla_(char *, integer *);
  853. integer ioffst, irsign;
  854. logical givens, iltemp;
  855. //extern /* Double Complex */ VOID zlarnd_(doublecomplex *, integer *,
  856. extern doublecomplex zlarnd_(integer *,
  857. integer *);
  858. extern /* Subroutine */ int zlaset_(char *, integer *, integer *,
  859. doublecomplex *, doublecomplex *, doublecomplex *, integer *), zlartg_(doublecomplex *, doublecomplex *, doublereal *,
  860. doublecomplex *, doublecomplex *);
  861. logical ilextr;
  862. extern /* Subroutine */ int zlagsy_(integer *, integer *, doublereal *,
  863. doublecomplex *, integer *, integer *, doublecomplex *, integer *)
  864. ;
  865. integer ir1, ir2, isympk;
  866. logical topdwn;
  867. extern /* Subroutine */ int zlarot_(logical *, logical *, logical *,
  868. integer *, doublecomplex *, doublecomplex *, doublecomplex *,
  869. integer *, doublecomplex *, doublecomplex *);
  870. integer jch, llb, jkl, jku, uub;
  871. /* -- LAPACK computational routine (version 3.7.0) -- */
  872. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  873. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  874. /* December 2016 */
  875. /* ===================================================================== */
  876. /* 1) Decode and Test the input parameters. */
  877. /* Initialize flags & seed. */
  878. /* Parameter adjustments */
  879. --iseed;
  880. --d__;
  881. a_dim1 = *lda;
  882. a_offset = 1 + a_dim1 * 1;
  883. a -= a_offset;
  884. --work;
  885. /* Function Body */
  886. *info = 0;
  887. /* Quick return if possible */
  888. if (*m == 0 || *n == 0) {
  889. return 0;
  890. }
  891. /* Decode DIST */
  892. if (lsame_(dist, "U")) {
  893. idist = 1;
  894. } else if (lsame_(dist, "S")) {
  895. idist = 2;
  896. } else if (lsame_(dist, "N")) {
  897. idist = 3;
  898. } else {
  899. idist = -1;
  900. }
  901. /* Decode SYM */
  902. if (lsame_(sym, "N")) {
  903. isym = 1;
  904. irsign = 0;
  905. csym = FALSE_;
  906. } else if (lsame_(sym, "P")) {
  907. isym = 2;
  908. irsign = 0;
  909. csym = FALSE_;
  910. } else if (lsame_(sym, "S")) {
  911. isym = 2;
  912. irsign = 0;
  913. csym = TRUE_;
  914. } else if (lsame_(sym, "H")) {
  915. isym = 2;
  916. irsign = 1;
  917. csym = FALSE_;
  918. } else {
  919. isym = -1;
  920. }
  921. /* Decode PACK */
  922. isympk = 0;
  923. if (lsame_(pack, "N")) {
  924. ipack = 0;
  925. } else if (lsame_(pack, "U")) {
  926. ipack = 1;
  927. isympk = 1;
  928. } else if (lsame_(pack, "L")) {
  929. ipack = 2;
  930. isympk = 1;
  931. } else if (lsame_(pack, "C")) {
  932. ipack = 3;
  933. isympk = 2;
  934. } else if (lsame_(pack, "R")) {
  935. ipack = 4;
  936. isympk = 3;
  937. } else if (lsame_(pack, "B")) {
  938. ipack = 5;
  939. isympk = 3;
  940. } else if (lsame_(pack, "Q")) {
  941. ipack = 6;
  942. isympk = 2;
  943. } else if (lsame_(pack, "Z")) {
  944. ipack = 7;
  945. } else {
  946. ipack = -1;
  947. }
  948. /* Set certain internal parameters */
  949. mnmin = f2cmin(*m,*n);
  950. /* Computing MIN */
  951. i__1 = *kl, i__2 = *m - 1;
  952. llb = f2cmin(i__1,i__2);
  953. /* Computing MIN */
  954. i__1 = *ku, i__2 = *n - 1;
  955. uub = f2cmin(i__1,i__2);
  956. /* Computing MIN */
  957. i__1 = *m, i__2 = *n + llb;
  958. mr = f2cmin(i__1,i__2);
  959. /* Computing MIN */
  960. i__1 = *n, i__2 = *m + uub;
  961. nc = f2cmin(i__1,i__2);
  962. if (ipack == 5 || ipack == 6) {
  963. minlda = uub + 1;
  964. } else if (ipack == 7) {
  965. minlda = llb + uub + 1;
  966. } else {
  967. minlda = *m;
  968. }
  969. /* Use Givens rotation method if bandwidth small enough, */
  970. /* or if LDA is too small to store the matrix unpacked. */
  971. givens = FALSE_;
  972. if (isym == 1) {
  973. /* Computing MAX */
  974. i__1 = 1, i__2 = mr + nc;
  975. if ((doublereal) (llb + uub) < (doublereal) f2cmax(i__1,i__2) * .3) {
  976. givens = TRUE_;
  977. }
  978. } else {
  979. if (llb << 1 < *m) {
  980. givens = TRUE_;
  981. }
  982. }
  983. if (*lda < *m && *lda >= minlda) {
  984. givens = TRUE_;
  985. }
  986. /* Set INFO if an error */
  987. if (*m < 0) {
  988. *info = -1;
  989. } else if (*m != *n && isym != 1) {
  990. *info = -1;
  991. } else if (*n < 0) {
  992. *info = -2;
  993. } else if (idist == -1) {
  994. *info = -3;
  995. } else if (isym == -1) {
  996. *info = -5;
  997. } else if (abs(*mode) > 6) {
  998. *info = -7;
  999. } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
  1000. *info = -8;
  1001. } else if (*kl < 0) {
  1002. *info = -10;
  1003. } else if (*ku < 0 || isym != 1 && *kl != *ku) {
  1004. *info = -11;
  1005. } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
  1006. == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
  1007. != 0 && *m != *n) {
  1008. *info = -12;
  1009. } else if (*lda < f2cmax(1,minlda)) {
  1010. *info = -14;
  1011. }
  1012. if (*info != 0) {
  1013. i__1 = -(*info);
  1014. xerbla_("ZLATMT", &i__1);
  1015. return 0;
  1016. }
  1017. /* Initialize random number generator */
  1018. for (i__ = 1; i__ <= 4; ++i__) {
  1019. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  1020. /* L100: */
  1021. }
  1022. if (iseed[4] % 2 != 1) {
  1023. ++iseed[4];
  1024. }
  1025. /* 2) Set up D if indicated. */
  1026. /* Compute D according to COND and MODE */
  1027. dlatm7_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, rank, &
  1028. iinfo);
  1029. if (iinfo != 0) {
  1030. *info = 1;
  1031. return 0;
  1032. }
  1033. /* Choose Top-Down if D is (apparently) increasing, */
  1034. /* Bottom-Up if D is (apparently) decreasing. */
  1035. if (abs(d__[1]) <= (d__1 = d__[*rank], abs(d__1))) {
  1036. topdwn = TRUE_;
  1037. } else {
  1038. topdwn = FALSE_;
  1039. }
  1040. if (*mode != 0 && abs(*mode) != 6) {
  1041. /* Scale by DMAX */
  1042. temp = abs(d__[1]);
  1043. i__1 = *rank;
  1044. for (i__ = 2; i__ <= i__1; ++i__) {
  1045. /* Computing MAX */
  1046. d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
  1047. temp = f2cmax(d__2,d__3);
  1048. /* L110: */
  1049. }
  1050. if (temp > 0.) {
  1051. alpha = *dmax__ / temp;
  1052. } else {
  1053. *info = 2;
  1054. return 0;
  1055. }
  1056. dscal_(rank, &alpha, &d__[1], &c__1);
  1057. }
  1058. zlaset_("Full", lda, n, &c_b1, &c_b1, &a[a_offset], lda);
  1059. /* 3) Generate Banded Matrix using Givens rotations. */
  1060. /* Also the special case of UUB=LLB=0 */
  1061. /* Compute Addressing constants to cover all */
  1062. /* storage formats. Whether GE, HE, SY, GB, HB, or SB, */
  1063. /* upper or lower triangle or both, */
  1064. /* the (i,j)-th element is in */
  1065. /* A( i - ISKEW*j + IOFFST, j ) */
  1066. if (ipack > 4) {
  1067. ilda = *lda - 1;
  1068. iskew = 1;
  1069. if (ipack > 5) {
  1070. ioffst = uub + 1;
  1071. } else {
  1072. ioffst = 1;
  1073. }
  1074. } else {
  1075. ilda = *lda;
  1076. iskew = 0;
  1077. ioffst = 0;
  1078. }
  1079. /* IPACKG is the format that the matrix is generated in. If this is */
  1080. /* different from IPACK, then the matrix must be repacked at the */
  1081. /* end. It also signals how to compute the norm, for scaling. */
  1082. ipackg = 0;
  1083. /* Diagonal Matrix -- We are done, unless it */
  1084. /* is to be stored HP/SP/PP/TP (PACK='R' or 'C') */
  1085. if (llb == 0 && uub == 0) {
  1086. i__1 = mnmin;
  1087. for (j = 1; j <= i__1; ++j) {
  1088. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  1089. i__3 = j;
  1090. z__1.r = d__[i__3], z__1.i = 0.;
  1091. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1092. /* L120: */
  1093. }
  1094. if (ipack <= 2 || ipack >= 5) {
  1095. ipackg = ipack;
  1096. }
  1097. } else if (givens) {
  1098. /* Check whether to use Givens rotations, */
  1099. /* Householder transformations, or nothing. */
  1100. if (isym == 1) {
  1101. /* Non-symmetric -- A = U D V */
  1102. if (ipack > 4) {
  1103. ipackg = ipack;
  1104. } else {
  1105. ipackg = 0;
  1106. }
  1107. i__1 = mnmin;
  1108. for (j = 1; j <= i__1; ++j) {
  1109. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  1110. i__3 = j;
  1111. z__1.r = d__[i__3], z__1.i = 0.;
  1112. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1113. /* L130: */
  1114. }
  1115. if (topdwn) {
  1116. jkl = 0;
  1117. i__1 = uub;
  1118. for (jku = 1; jku <= i__1; ++jku) {
  1119. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1120. /* Last row actually rotated is M */
  1121. /* Last column actually rotated is MIN( M+JKU, N ) */
  1122. /* Computing MIN */
  1123. i__3 = *m + jku;
  1124. i__2 = f2cmin(i__3,*n) + jkl - 1;
  1125. for (jr = 1; jr <= i__2; ++jr) {
  1126. extra.r = 0., extra.i = 0.;
  1127. angle = dlarnd_(&c__1, &iseed[1]) *
  1128. 6.2831853071795864769252867663;
  1129. d__1 = cos(angle);
  1130. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1131. z__2=zlarnd_(&c__5, &iseed[1]);
  1132. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1133. c__.r = z__1.r, c__.i = z__1.i;
  1134. d__1 = sin(angle);
  1135. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1136. z__2=zlarnd_( &c__5, &iseed[1]);
  1137. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1138. s.r = z__1.r, s.i = z__1.i;
  1139. /* Computing MAX */
  1140. i__3 = 1, i__4 = jr - jkl;
  1141. icol = f2cmax(i__3,i__4);
  1142. if (jr < *m) {
  1143. /* Computing MIN */
  1144. i__3 = *n, i__4 = jr + jku;
  1145. il = f2cmin(i__3,i__4) + 1 - icol;
  1146. L__1 = jr > jkl;
  1147. zlarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
  1148. a[jr - iskew * icol + ioffst + icol *
  1149. a_dim1], &ilda, &extra, &dummy);
  1150. }
  1151. /* Chase "EXTRA" back up */
  1152. ir = jr;
  1153. ic = icol;
  1154. i__3 = -jkl - jku;
  1155. for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
  1156. jch += i__3) {
  1157. if (ir < *m) {
  1158. zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1159. + (ic + 1) * a_dim1], &extra, &realc,
  1160. &s, &dummy);
  1161. d__1 = dlarnd_(&c__5, &iseed[1]);
  1162. dummy.r = d__1, dummy.i = 0.;
  1163. z__2.r = realc * dummy.r, z__2.i = realc *
  1164. dummy.i;
  1165. d_cnjg(&z__1, &z__2);
  1166. c__.r = z__1.r, c__.i = z__1.i;
  1167. z__3.r = -s.r, z__3.i = -s.i;
  1168. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1169. z__2.i = z__3.r * dummy.i + z__3.i *
  1170. dummy.r;
  1171. d_cnjg(&z__1, &z__2);
  1172. s.r = z__1.r, s.i = z__1.i;
  1173. }
  1174. /* Computing MAX */
  1175. i__4 = 1, i__5 = jch - jku;
  1176. irow = f2cmax(i__4,i__5);
  1177. il = ir + 2 - irow;
  1178. ztemp.r = 0., ztemp.i = 0.;
  1179. iltemp = jch > jku;
  1180. zlarot_(&c_false, &iltemp, &c_true, &il, &c__, &s,
  1181. &a[irow - iskew * ic + ioffst + ic *
  1182. a_dim1], &ilda, &ztemp, &extra);
  1183. if (iltemp) {
  1184. zlartg_(&a[irow + 1 - iskew * (ic + 1) +
  1185. ioffst + (ic + 1) * a_dim1], &ztemp, &
  1186. realc, &s, &dummy);
  1187. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1188. z__1=zlarnd_( &c__5, &iseed[1]);
  1189. dummy.r = z__1.r, dummy.i = z__1.i;
  1190. z__2.r = realc * dummy.r, z__2.i = realc *
  1191. dummy.i;
  1192. d_cnjg(&z__1, &z__2);
  1193. c__.r = z__1.r, c__.i = z__1.i;
  1194. z__3.r = -s.r, z__3.i = -s.i;
  1195. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1196. z__2.i = z__3.r * dummy.i + z__3.i *
  1197. dummy.r;
  1198. d_cnjg(&z__1, &z__2);
  1199. s.r = z__1.r, s.i = z__1.i;
  1200. /* Computing MAX */
  1201. i__4 = 1, i__5 = jch - jku - jkl;
  1202. icol = f2cmax(i__4,i__5);
  1203. il = ic + 2 - icol;
  1204. extra.r = 0., extra.i = 0.;
  1205. L__1 = jch > jku + jkl;
  1206. zlarot_(&c_true, &L__1, &c_true, &il, &c__, &
  1207. s, &a[irow - iskew * icol + ioffst +
  1208. icol * a_dim1], &ilda, &extra, &ztemp)
  1209. ;
  1210. ic = icol;
  1211. ir = irow;
  1212. }
  1213. /* L140: */
  1214. }
  1215. /* L150: */
  1216. }
  1217. /* L160: */
  1218. }
  1219. jku = uub;
  1220. i__1 = llb;
  1221. for (jkl = 1; jkl <= i__1; ++jkl) {
  1222. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1223. /* Computing MIN */
  1224. i__3 = *n + jkl;
  1225. i__2 = f2cmin(i__3,*m) + jku - 1;
  1226. for (jc = 1; jc <= i__2; ++jc) {
  1227. extra.r = 0., extra.i = 0.;
  1228. angle = dlarnd_(&c__1, &iseed[1]) *
  1229. 6.2831853071795864769252867663;
  1230. d__1 = cos(angle);
  1231. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1232. z__2=zlarnd_(&c__5, &iseed[1]);
  1233. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1234. c__.r = z__1.r, c__.i = z__1.i;
  1235. d__1 = sin(angle);
  1236. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1237. z__2=zlarnd_(&c__5, &iseed[1]);
  1238. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1239. s.r = z__1.r, s.i = z__1.i;
  1240. /* Computing MAX */
  1241. i__3 = 1, i__4 = jc - jku;
  1242. irow = f2cmax(i__3,i__4);
  1243. if (jc < *n) {
  1244. /* Computing MIN */
  1245. i__3 = *m, i__4 = jc + jkl;
  1246. il = f2cmin(i__3,i__4) + 1 - irow;
  1247. L__1 = jc > jku;
  1248. zlarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
  1249. &a[irow - iskew * jc + ioffst + jc *
  1250. a_dim1], &ilda, &extra, &dummy);
  1251. }
  1252. /* Chase "EXTRA" back up */
  1253. ic = jc;
  1254. ir = irow;
  1255. i__3 = -jkl - jku;
  1256. for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
  1257. jch += i__3) {
  1258. if (ic < *n) {
  1259. zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1260. + (ic + 1) * a_dim1], &extra, &realc,
  1261. &s, &dummy);
  1262. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1263. z__1=zlarnd_(&c__5, &iseed[1]);
  1264. dummy.r = z__1.r, dummy.i = z__1.i;
  1265. z__2.r = realc * dummy.r, z__2.i = realc *
  1266. dummy.i;
  1267. d_cnjg(&z__1, &z__2);
  1268. c__.r = z__1.r, c__.i = z__1.i;
  1269. z__3.r = -s.r, z__3.i = -s.i;
  1270. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1271. z__2.i = z__3.r * dummy.i + z__3.i *
  1272. dummy.r;
  1273. d_cnjg(&z__1, &z__2);
  1274. s.r = z__1.r, s.i = z__1.i;
  1275. }
  1276. /* Computing MAX */
  1277. i__4 = 1, i__5 = jch - jkl;
  1278. icol = f2cmax(i__4,i__5);
  1279. il = ic + 2 - icol;
  1280. ztemp.r = 0., ztemp.i = 0.;
  1281. iltemp = jch > jkl;
  1282. zlarot_(&c_true, &iltemp, &c_true, &il, &c__, &s,
  1283. &a[ir - iskew * icol + ioffst + icol *
  1284. a_dim1], &ilda, &ztemp, &extra);
  1285. if (iltemp) {
  1286. zlartg_(&a[ir + 1 - iskew * (icol + 1) +
  1287. ioffst + (icol + 1) * a_dim1], &ztemp,
  1288. &realc, &s, &dummy);
  1289. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1290. z__1=zlarnd_(&c__5, &iseed[1]);
  1291. dummy.r = z__1.r, dummy.i = z__1.i;
  1292. z__2.r = realc * dummy.r, z__2.i = realc *
  1293. dummy.i;
  1294. d_cnjg(&z__1, &z__2);
  1295. c__.r = z__1.r, c__.i = z__1.i;
  1296. z__3.r = -s.r, z__3.i = -s.i;
  1297. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1298. z__2.i = z__3.r * dummy.i + z__3.i *
  1299. dummy.r;
  1300. d_cnjg(&z__1, &z__2);
  1301. s.r = z__1.r, s.i = z__1.i;
  1302. /* Computing MAX */
  1303. i__4 = 1, i__5 = jch - jkl - jku;
  1304. irow = f2cmax(i__4,i__5);
  1305. il = ir + 2 - irow;
  1306. extra.r = 0., extra.i = 0.;
  1307. L__1 = jch > jkl + jku;
  1308. zlarot_(&c_false, &L__1, &c_true, &il, &c__, &
  1309. s, &a[irow - iskew * icol + ioffst +
  1310. icol * a_dim1], &ilda, &extra, &ztemp)
  1311. ;
  1312. ic = icol;
  1313. ir = irow;
  1314. }
  1315. /* L170: */
  1316. }
  1317. /* L180: */
  1318. }
  1319. /* L190: */
  1320. }
  1321. } else {
  1322. /* Bottom-Up -- Start at the bottom right. */
  1323. jkl = 0;
  1324. i__1 = uub;
  1325. for (jku = 1; jku <= i__1; ++jku) {
  1326. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1327. /* First row actually rotated is M */
  1328. /* First column actually rotated is MIN( M+JKU, N ) */
  1329. /* Computing MIN */
  1330. i__2 = *m, i__3 = *n + jkl;
  1331. iendch = f2cmin(i__2,i__3) - 1;
  1332. /* Computing MIN */
  1333. i__2 = *m + jku;
  1334. i__3 = 1 - jkl;
  1335. for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
  1336. extra.r = 0., extra.i = 0.;
  1337. angle = dlarnd_(&c__1, &iseed[1]) *
  1338. 6.2831853071795864769252867663;
  1339. d__1 = cos(angle);
  1340. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1341. z__2=zlarnd_( &c__5, &iseed[1]);
  1342. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1343. c__.r = z__1.r, c__.i = z__1.i;
  1344. d__1 = sin(angle);
  1345. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1346. z__2=zlarnd_( &c__5, &iseed[1]);
  1347. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1348. s.r = z__1.r, s.i = z__1.i;
  1349. /* Computing MAX */
  1350. i__2 = 1, i__4 = jc - jku + 1;
  1351. irow = f2cmax(i__2,i__4);
  1352. if (jc > 0) {
  1353. /* Computing MIN */
  1354. i__2 = *m, i__4 = jc + jkl + 1;
  1355. il = f2cmin(i__2,i__4) + 1 - irow;
  1356. L__1 = jc + jkl < *m;
  1357. zlarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
  1358. &a[irow - iskew * jc + ioffst + jc *
  1359. a_dim1], &ilda, &dummy, &extra);
  1360. }
  1361. /* Chase "EXTRA" back down */
  1362. ic = jc;
  1363. i__2 = iendch;
  1364. i__4 = jkl + jku;
  1365. for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
  1366. i__2; jch += i__4) {
  1367. ilextr = ic > 0;
  1368. if (ilextr) {
  1369. zlartg_(&a[jch - iskew * ic + ioffst + ic *
  1370. a_dim1], &extra, &realc, &s, &dummy);
  1371. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1372. z__1=zlarnd_(&c__5, &iseed[1]);
  1373. dummy.r = z__1.r, dummy.i = z__1.i;
  1374. z__1.r = realc * dummy.r, z__1.i = realc *
  1375. dummy.i;
  1376. c__.r = z__1.r, c__.i = z__1.i;
  1377. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1378. z__1.i = s.r * dummy.i + s.i *
  1379. dummy.r;
  1380. s.r = z__1.r, s.i = z__1.i;
  1381. }
  1382. ic = f2cmax(1,ic);
  1383. /* Computing MIN */
  1384. i__5 = *n - 1, i__6 = jch + jku;
  1385. icol = f2cmin(i__5,i__6);
  1386. iltemp = jch + jku < *n;
  1387. ztemp.r = 0., ztemp.i = 0.;
  1388. i__5 = icol + 2 - ic;
  1389. zlarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
  1390. s, &a[jch - iskew * ic + ioffst + ic *
  1391. a_dim1], &ilda, &extra, &ztemp);
  1392. if (iltemp) {
  1393. zlartg_(&a[jch - iskew * icol + ioffst + icol
  1394. * a_dim1], &ztemp, &realc, &s, &dummy)
  1395. ;
  1396. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1397. z__1=zlarnd_(&c__5, &iseed[1]);
  1398. dummy.r = z__1.r, dummy.i = z__1.i;
  1399. z__1.r = realc * dummy.r, z__1.i = realc *
  1400. dummy.i;
  1401. c__.r = z__1.r, c__.i = z__1.i;
  1402. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1403. z__1.i = s.r * dummy.i + s.i *
  1404. dummy.r;
  1405. s.r = z__1.r, s.i = z__1.i;
  1406. /* Computing MIN */
  1407. i__5 = iendch, i__6 = jch + jkl + jku;
  1408. il = f2cmin(i__5,i__6) + 2 - jch;
  1409. extra.r = 0., extra.i = 0.;
  1410. L__1 = jch + jkl + jku <= iendch;
  1411. zlarot_(&c_false, &c_true, &L__1, &il, &c__, &
  1412. s, &a[jch - iskew * icol + ioffst +
  1413. icol * a_dim1], &ilda, &ztemp, &extra)
  1414. ;
  1415. ic = icol;
  1416. }
  1417. /* L200: */
  1418. }
  1419. /* L210: */
  1420. }
  1421. /* L220: */
  1422. }
  1423. jku = uub;
  1424. i__1 = llb;
  1425. for (jkl = 1; jkl <= i__1; ++jkl) {
  1426. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1427. /* First row actually rotated is MIN( N+JKL, M ) */
  1428. /* First column actually rotated is N */
  1429. /* Computing MIN */
  1430. i__3 = *n, i__4 = *m + jku;
  1431. iendch = f2cmin(i__3,i__4) - 1;
  1432. /* Computing MIN */
  1433. i__3 = *n + jkl;
  1434. i__4 = 1 - jku;
  1435. for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
  1436. extra.r = 0., extra.i = 0.;
  1437. angle = dlarnd_(&c__1, &iseed[1]) *
  1438. 6.2831853071795864769252867663;
  1439. d__1 = cos(angle);
  1440. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1441. z__2=zlarnd_(&c__5, &iseed[1]);
  1442. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1443. c__.r = z__1.r, c__.i = z__1.i;
  1444. d__1 = sin(angle);
  1445. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1446. z__2=zlarnd_(&c__5, &iseed[1]);
  1447. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1448. s.r = z__1.r, s.i = z__1.i;
  1449. /* Computing MAX */
  1450. i__3 = 1, i__2 = jr - jkl + 1;
  1451. icol = f2cmax(i__3,i__2);
  1452. if (jr > 0) {
  1453. /* Computing MIN */
  1454. i__3 = *n, i__2 = jr + jku + 1;
  1455. il = f2cmin(i__3,i__2) + 1 - icol;
  1456. L__1 = jr + jku < *n;
  1457. zlarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
  1458. a[jr - iskew * icol + ioffst + icol *
  1459. a_dim1], &ilda, &dummy, &extra);
  1460. }
  1461. /* Chase "EXTRA" back down */
  1462. ir = jr;
  1463. i__3 = iendch;
  1464. i__2 = jkl + jku;
  1465. for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
  1466. i__3; jch += i__2) {
  1467. ilextr = ir > 0;
  1468. if (ilextr) {
  1469. zlartg_(&a[ir - iskew * jch + ioffst + jch *
  1470. a_dim1], &extra, &realc, &s, &dummy);
  1471. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1472. z__1=zlarnd_( &c__5, &iseed[1]);
  1473. dummy.r = z__1.r, dummy.i = z__1.i;
  1474. z__1.r = realc * dummy.r, z__1.i = realc *
  1475. dummy.i;
  1476. c__.r = z__1.r, c__.i = z__1.i;
  1477. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1478. z__1.i = s.r * dummy.i + s.i *
  1479. dummy.r;
  1480. s.r = z__1.r, s.i = z__1.i;
  1481. }
  1482. ir = f2cmax(1,ir);
  1483. /* Computing MIN */
  1484. i__5 = *m - 1, i__6 = jch + jkl;
  1485. irow = f2cmin(i__5,i__6);
  1486. iltemp = jch + jkl < *m;
  1487. ztemp.r = 0., ztemp.i = 0.;
  1488. i__5 = irow + 2 - ir;
  1489. zlarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
  1490. s, &a[ir - iskew * jch + ioffst + jch *
  1491. a_dim1], &ilda, &extra, &ztemp);
  1492. if (iltemp) {
  1493. zlartg_(&a[irow - iskew * jch + ioffst + jch *
  1494. a_dim1], &ztemp, &realc, &s, &dummy);
  1495. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1496. z__1=zlarnd_(&c__5, &iseed[1]);
  1497. dummy.r = z__1.r, dummy.i = z__1.i;
  1498. z__1.r = realc * dummy.r, z__1.i = realc *
  1499. dummy.i;
  1500. c__.r = z__1.r, c__.i = z__1.i;
  1501. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1502. z__1.i = s.r * dummy.i + s.i *
  1503. dummy.r;
  1504. s.r = z__1.r, s.i = z__1.i;
  1505. /* Computing MIN */
  1506. i__5 = iendch, i__6 = jch + jkl + jku;
  1507. il = f2cmin(i__5,i__6) + 2 - jch;
  1508. extra.r = 0., extra.i = 0.;
  1509. L__1 = jch + jkl + jku <= iendch;
  1510. zlarot_(&c_true, &c_true, &L__1, &il, &c__, &
  1511. s, &a[irow - iskew * jch + ioffst +
  1512. jch * a_dim1], &ilda, &ztemp, &extra);
  1513. ir = irow;
  1514. }
  1515. /* L230: */
  1516. }
  1517. /* L240: */
  1518. }
  1519. /* L250: */
  1520. }
  1521. }
  1522. } else {
  1523. /* Symmetric -- A = U D U' */
  1524. /* Hermitian -- A = U D U* */
  1525. ipackg = ipack;
  1526. ioffg = ioffst;
  1527. if (topdwn) {
  1528. /* Top-Down -- Generate Upper triangle only */
  1529. if (ipack >= 5) {
  1530. ipackg = 6;
  1531. ioffg = uub + 1;
  1532. } else {
  1533. ipackg = 1;
  1534. }
  1535. i__1 = mnmin;
  1536. for (j = 1; j <= i__1; ++j) {
  1537. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1538. i__2 = j;
  1539. z__1.r = d__[i__2], z__1.i = 0.;
  1540. a[i__4].r = z__1.r, a[i__4].i = z__1.i;
  1541. /* L260: */
  1542. }
  1543. i__1 = uub;
  1544. for (k = 1; k <= i__1; ++k) {
  1545. i__4 = *n - 1;
  1546. for (jc = 1; jc <= i__4; ++jc) {
  1547. /* Computing MAX */
  1548. i__2 = 1, i__3 = jc - k;
  1549. irow = f2cmax(i__2,i__3);
  1550. /* Computing MIN */
  1551. i__2 = jc + 1, i__3 = k + 2;
  1552. il = f2cmin(i__2,i__3);
  1553. extra.r = 0., extra.i = 0.;
  1554. i__2 = jc - iskew * (jc + 1) + ioffg + (jc + 1) *
  1555. a_dim1;
  1556. ztemp.r = a[i__2].r, ztemp.i = a[i__2].i;
  1557. angle = dlarnd_(&c__1, &iseed[1]) *
  1558. 6.2831853071795864769252867663;
  1559. d__1 = cos(angle);
  1560. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1561. z__2=zlarnd_(&c__5, &iseed[1]);
  1562. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1563. c__.r = z__1.r, c__.i = z__1.i;
  1564. d__1 = sin(angle);
  1565. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1566. z__2=zlarnd_( &c__5, &iseed[1]);
  1567. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1568. s.r = z__1.r, s.i = z__1.i;
  1569. if (csym) {
  1570. ct.r = c__.r, ct.i = c__.i;
  1571. st.r = s.r, st.i = s.i;
  1572. } else {
  1573. d_cnjg(&z__1, &ztemp);
  1574. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1575. d_cnjg(&z__1, &c__);
  1576. ct.r = z__1.r, ct.i = z__1.i;
  1577. d_cnjg(&z__1, &s);
  1578. st.r = z__1.r, st.i = z__1.i;
  1579. }
  1580. L__1 = jc > k;
  1581. zlarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
  1582. irow - iskew * jc + ioffg + jc * a_dim1], &
  1583. ilda, &extra, &ztemp);
  1584. /* Computing MIN */
  1585. i__3 = k, i__5 = *n - jc;
  1586. i__2 = f2cmin(i__3,i__5) + 1;
  1587. zlarot_(&c_true, &c_true, &c_false, &i__2, &ct, &st, &
  1588. a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
  1589. ilda, &ztemp, &dummy);
  1590. /* Chase EXTRA back up the matrix */
  1591. icol = jc;
  1592. i__2 = -k;
  1593. for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
  1594. jch += i__2) {
  1595. zlartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
  1596. (icol + 1) * a_dim1], &extra, &realc, &s,
  1597. &dummy);
  1598. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1599. z__1=zlarnd_(&c__5, &iseed[1]);
  1600. dummy.r = z__1.r, dummy.i = z__1.i;
  1601. z__2.r = realc * dummy.r, z__2.i = realc *
  1602. dummy.i;
  1603. d_cnjg(&z__1, &z__2);
  1604. c__.r = z__1.r, c__.i = z__1.i;
  1605. z__3.r = -s.r, z__3.i = -s.i;
  1606. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1607. z__2.i = z__3.r * dummy.i + z__3.i *
  1608. dummy.r;
  1609. d_cnjg(&z__1, &z__2);
  1610. s.r = z__1.r, s.i = z__1.i;
  1611. i__3 = jch - iskew * (jch + 1) + ioffg + (jch + 1)
  1612. * a_dim1;
  1613. ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
  1614. if (csym) {
  1615. ct.r = c__.r, ct.i = c__.i;
  1616. st.r = s.r, st.i = s.i;
  1617. } else {
  1618. d_cnjg(&z__1, &ztemp);
  1619. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1620. d_cnjg(&z__1, &c__);
  1621. ct.r = z__1.r, ct.i = z__1.i;
  1622. d_cnjg(&z__1, &s);
  1623. st.r = z__1.r, st.i = z__1.i;
  1624. }
  1625. i__3 = k + 2;
  1626. zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1627. s, &a[(1 - iskew) * jch + ioffg + jch *
  1628. a_dim1], &ilda, &ztemp, &extra);
  1629. /* Computing MAX */
  1630. i__3 = 1, i__5 = jch - k;
  1631. irow = f2cmax(i__3,i__5);
  1632. /* Computing MIN */
  1633. i__3 = jch + 1, i__5 = k + 2;
  1634. il = f2cmin(i__3,i__5);
  1635. extra.r = 0., extra.i = 0.;
  1636. L__1 = jch > k;
  1637. zlarot_(&c_false, &L__1, &c_true, &il, &ct, &st, &
  1638. a[irow - iskew * jch + ioffg + jch *
  1639. a_dim1], &ilda, &extra, &ztemp);
  1640. icol = jch;
  1641. /* L270: */
  1642. }
  1643. /* L280: */
  1644. }
  1645. /* L290: */
  1646. }
  1647. /* If we need lower triangle, copy from upper. Note that */
  1648. /* the order of copying is chosen to work for 'q' -> 'b' */
  1649. if (ipack != ipackg && ipack != 3) {
  1650. i__1 = *n;
  1651. for (jc = 1; jc <= i__1; ++jc) {
  1652. irow = ioffst - iskew * jc;
  1653. if (csym) {
  1654. /* Computing MIN */
  1655. i__2 = *n, i__3 = jc + uub;
  1656. i__4 = f2cmin(i__2,i__3);
  1657. for (jr = jc; jr <= i__4; ++jr) {
  1658. i__2 = jr + irow + jc * a_dim1;
  1659. i__3 = jc - iskew * jr + ioffg + jr * a_dim1;
  1660. a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
  1661. /* L300: */
  1662. }
  1663. } else {
  1664. /* Computing MIN */
  1665. i__2 = *n, i__3 = jc + uub;
  1666. i__4 = f2cmin(i__2,i__3);
  1667. for (jr = jc; jr <= i__4; ++jr) {
  1668. i__2 = jr + irow + jc * a_dim1;
  1669. d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
  1670. * a_dim1]);
  1671. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1672. /* L310: */
  1673. }
  1674. }
  1675. /* L320: */
  1676. }
  1677. if (ipack == 5) {
  1678. i__1 = *n;
  1679. for (jc = *n - uub + 1; jc <= i__1; ++jc) {
  1680. i__4 = uub + 1;
  1681. for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
  1682. i__2 = jr + jc * a_dim1;
  1683. a[i__2].r = 0., a[i__2].i = 0.;
  1684. /* L330: */
  1685. }
  1686. /* L340: */
  1687. }
  1688. }
  1689. if (ipackg == 6) {
  1690. ipackg = ipack;
  1691. } else {
  1692. ipackg = 0;
  1693. }
  1694. }
  1695. } else {
  1696. /* Bottom-Up -- Generate Lower triangle only */
  1697. if (ipack >= 5) {
  1698. ipackg = 5;
  1699. if (ipack == 6) {
  1700. ioffg = 1;
  1701. }
  1702. } else {
  1703. ipackg = 2;
  1704. }
  1705. i__1 = mnmin;
  1706. for (j = 1; j <= i__1; ++j) {
  1707. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1708. i__2 = j;
  1709. z__1.r = d__[i__2], z__1.i = 0.;
  1710. a[i__4].r = z__1.r, a[i__4].i = z__1.i;
  1711. /* L350: */
  1712. }
  1713. i__1 = uub;
  1714. for (k = 1; k <= i__1; ++k) {
  1715. for (jc = *n - 1; jc >= 1; --jc) {
  1716. /* Computing MIN */
  1717. i__4 = *n + 1 - jc, i__2 = k + 2;
  1718. il = f2cmin(i__4,i__2);
  1719. extra.r = 0., extra.i = 0.;
  1720. i__4 = (1 - iskew) * jc + 1 + ioffg + jc * a_dim1;
  1721. ztemp.r = a[i__4].r, ztemp.i = a[i__4].i;
  1722. angle = dlarnd_(&c__1, &iseed[1]) *
  1723. 6.2831853071795864769252867663;
  1724. d__1 = cos(angle);
  1725. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1726. z__2=zlarnd_(&c__5, &iseed[1]);
  1727. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1728. c__.r = z__1.r, c__.i = z__1.i;
  1729. d__1 = sin(angle);
  1730. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1731. z__2=zlarnd_(&c__5, &iseed[1]);
  1732. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1733. s.r = z__1.r, s.i = z__1.i;
  1734. if (csym) {
  1735. ct.r = c__.r, ct.i = c__.i;
  1736. st.r = s.r, st.i = s.i;
  1737. } else {
  1738. d_cnjg(&z__1, &ztemp);
  1739. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1740. d_cnjg(&z__1, &c__);
  1741. ct.r = z__1.r, ct.i = z__1.i;
  1742. d_cnjg(&z__1, &s);
  1743. st.r = z__1.r, st.i = z__1.i;
  1744. }
  1745. L__1 = *n - jc > k;
  1746. zlarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
  1747. 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
  1748. &ztemp, &extra);
  1749. /* Computing MAX */
  1750. i__4 = 1, i__2 = jc - k + 1;
  1751. icol = f2cmax(i__4,i__2);
  1752. i__4 = jc + 2 - icol;
  1753. zlarot_(&c_true, &c_false, &c_true, &i__4, &ct, &st, &
  1754. a[jc - iskew * icol + ioffg + icol * a_dim1],
  1755. &ilda, &dummy, &ztemp);
  1756. /* Chase EXTRA back down the matrix */
  1757. icol = jc;
  1758. i__4 = *n - 1;
  1759. i__2 = k;
  1760. for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
  1761. i__4; jch += i__2) {
  1762. zlartg_(&a[jch - iskew * icol + ioffg + icol *
  1763. a_dim1], &extra, &realc, &s, &dummy);
  1764. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1765. z__1=zlarnd_(&c__5, &iseed[1]);
  1766. dummy.r = z__1.r, dummy.i = z__1.i;
  1767. z__1.r = realc * dummy.r, z__1.i = realc *
  1768. dummy.i;
  1769. c__.r = z__1.r, c__.i = z__1.i;
  1770. z__1.r = s.r * dummy.r - s.i * dummy.i, z__1.i =
  1771. s.r * dummy.i + s.i * dummy.r;
  1772. s.r = z__1.r, s.i = z__1.i;
  1773. i__3 = (1 - iskew) * jch + 1 + ioffg + jch *
  1774. a_dim1;
  1775. ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
  1776. if (csym) {
  1777. ct.r = c__.r, ct.i = c__.i;
  1778. st.r = s.r, st.i = s.i;
  1779. } else {
  1780. d_cnjg(&z__1, &ztemp);
  1781. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1782. d_cnjg(&z__1, &c__);
  1783. ct.r = z__1.r, ct.i = z__1.i;
  1784. d_cnjg(&z__1, &s);
  1785. st.r = z__1.r, st.i = z__1.i;
  1786. }
  1787. i__3 = k + 2;
  1788. zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1789. s, &a[jch - iskew * icol + ioffg + icol *
  1790. a_dim1], &ilda, &extra, &ztemp);
  1791. /* Computing MIN */
  1792. i__3 = *n + 1 - jch, i__5 = k + 2;
  1793. il = f2cmin(i__3,i__5);
  1794. extra.r = 0., extra.i = 0.;
  1795. L__1 = *n - jch > k;
  1796. zlarot_(&c_false, &c_true, &L__1, &il, &ct, &st, &
  1797. a[(1 - iskew) * jch + ioffg + jch *
  1798. a_dim1], &ilda, &ztemp, &extra);
  1799. icol = jch;
  1800. /* L360: */
  1801. }
  1802. /* L370: */
  1803. }
  1804. /* L380: */
  1805. }
  1806. /* If we need upper triangle, copy from lower. Note that */
  1807. /* the order of copying is chosen to work for 'b' -> 'q' */
  1808. if (ipack != ipackg && ipack != 4) {
  1809. for (jc = *n; jc >= 1; --jc) {
  1810. irow = ioffst - iskew * jc;
  1811. if (csym) {
  1812. /* Computing MAX */
  1813. i__2 = 1, i__4 = jc - uub;
  1814. i__1 = f2cmax(i__2,i__4);
  1815. for (jr = jc; jr >= i__1; --jr) {
  1816. i__2 = jr + irow + jc * a_dim1;
  1817. i__4 = jc - iskew * jr + ioffg + jr * a_dim1;
  1818. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1819. /* L390: */
  1820. }
  1821. } else {
  1822. /* Computing MAX */
  1823. i__2 = 1, i__4 = jc - uub;
  1824. i__1 = f2cmax(i__2,i__4);
  1825. for (jr = jc; jr >= i__1; --jr) {
  1826. i__2 = jr + irow + jc * a_dim1;
  1827. d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
  1828. * a_dim1]);
  1829. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1830. /* L400: */
  1831. }
  1832. }
  1833. /* L410: */
  1834. }
  1835. if (ipack == 6) {
  1836. i__1 = uub;
  1837. for (jc = 1; jc <= i__1; ++jc) {
  1838. i__2 = uub + 1 - jc;
  1839. for (jr = 1; jr <= i__2; ++jr) {
  1840. i__4 = jr + jc * a_dim1;
  1841. a[i__4].r = 0., a[i__4].i = 0.;
  1842. /* L420: */
  1843. }
  1844. /* L430: */
  1845. }
  1846. }
  1847. if (ipackg == 5) {
  1848. ipackg = ipack;
  1849. } else {
  1850. ipackg = 0;
  1851. }
  1852. }
  1853. }
  1854. /* Ensure that the diagonal is real if Hermitian */
  1855. if (! csym) {
  1856. i__1 = *n;
  1857. for (jc = 1; jc <= i__1; ++jc) {
  1858. irow = ioffst + (1 - iskew) * jc;
  1859. i__2 = irow + jc * a_dim1;
  1860. i__4 = irow + jc * a_dim1;
  1861. d__1 = a[i__4].r;
  1862. z__1.r = d__1, z__1.i = 0.;
  1863. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1864. /* L440: */
  1865. }
  1866. }
  1867. }
  1868. } else {
  1869. /* 4) Generate Banded Matrix by first */
  1870. /* Rotating by random Unitary matrices, */
  1871. /* then reducing the bandwidth using Householder */
  1872. /* transformations. */
  1873. /* Note: we should get here only if LDA .ge. N */
  1874. if (isym == 1) {
  1875. /* Non-symmetric -- A = U D V */
  1876. zlagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
  1877. 1], &work[1], &iinfo);
  1878. } else {
  1879. /* Symmetric -- A = U D U' or */
  1880. /* Hermitian -- A = U D U* */
  1881. if (csym) {
  1882. zlagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1883. 1], &iinfo);
  1884. } else {
  1885. zlaghe_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1886. 1], &iinfo);
  1887. }
  1888. }
  1889. if (iinfo != 0) {
  1890. *info = 3;
  1891. return 0;
  1892. }
  1893. }
  1894. /* 5) Pack the matrix */
  1895. if (ipack != ipackg) {
  1896. if (ipack == 1) {
  1897. /* 'U' -- Upper triangular, not packed */
  1898. i__1 = *m;
  1899. for (j = 1; j <= i__1; ++j) {
  1900. i__2 = *m;
  1901. for (i__ = j + 1; i__ <= i__2; ++i__) {
  1902. i__4 = i__ + j * a_dim1;
  1903. a[i__4].r = 0., a[i__4].i = 0.;
  1904. /* L450: */
  1905. }
  1906. /* L460: */
  1907. }
  1908. } else if (ipack == 2) {
  1909. /* 'L' -- Lower triangular, not packed */
  1910. i__1 = *m;
  1911. for (j = 2; j <= i__1; ++j) {
  1912. i__2 = j - 1;
  1913. for (i__ = 1; i__ <= i__2; ++i__) {
  1914. i__4 = i__ + j * a_dim1;
  1915. a[i__4].r = 0., a[i__4].i = 0.;
  1916. /* L470: */
  1917. }
  1918. /* L480: */
  1919. }
  1920. } else if (ipack == 3) {
  1921. /* 'C' -- Upper triangle packed Columnwise. */
  1922. icol = 1;
  1923. irow = 0;
  1924. i__1 = *m;
  1925. for (j = 1; j <= i__1; ++j) {
  1926. i__2 = j;
  1927. for (i__ = 1; i__ <= i__2; ++i__) {
  1928. ++irow;
  1929. if (irow > *lda) {
  1930. irow = 1;
  1931. ++icol;
  1932. }
  1933. i__4 = irow + icol * a_dim1;
  1934. i__3 = i__ + j * a_dim1;
  1935. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1936. /* L490: */
  1937. }
  1938. /* L500: */
  1939. }
  1940. } else if (ipack == 4) {
  1941. /* 'R' -- Lower triangle packed Columnwise. */
  1942. icol = 1;
  1943. irow = 0;
  1944. i__1 = *m;
  1945. for (j = 1; j <= i__1; ++j) {
  1946. i__2 = *m;
  1947. for (i__ = j; i__ <= i__2; ++i__) {
  1948. ++irow;
  1949. if (irow > *lda) {
  1950. irow = 1;
  1951. ++icol;
  1952. }
  1953. i__4 = irow + icol * a_dim1;
  1954. i__3 = i__ + j * a_dim1;
  1955. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1956. /* L510: */
  1957. }
  1958. /* L520: */
  1959. }
  1960. } else if (ipack >= 5) {
  1961. /* 'B' -- The lower triangle is packed as a band matrix. */
  1962. /* 'Q' -- The upper triangle is packed as a band matrix. */
  1963. /* 'Z' -- The whole matrix is packed as a band matrix. */
  1964. if (ipack == 5) {
  1965. uub = 0;
  1966. }
  1967. if (ipack == 6) {
  1968. llb = 0;
  1969. }
  1970. i__1 = uub;
  1971. for (j = 1; j <= i__1; ++j) {
  1972. /* Computing MIN */
  1973. i__2 = j + llb;
  1974. for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
  1975. i__2 = i__ - j + uub + 1 + j * a_dim1;
  1976. i__4 = i__ + j * a_dim1;
  1977. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1978. /* L530: */
  1979. }
  1980. /* L540: */
  1981. }
  1982. i__1 = *n;
  1983. for (j = uub + 2; j <= i__1; ++j) {
  1984. /* Computing MIN */
  1985. i__4 = j + llb;
  1986. i__2 = f2cmin(i__4,*m);
  1987. for (i__ = j - uub; i__ <= i__2; ++i__) {
  1988. i__4 = i__ - j + uub + 1 + j * a_dim1;
  1989. i__3 = i__ + j * a_dim1;
  1990. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1991. /* L550: */
  1992. }
  1993. /* L560: */
  1994. }
  1995. }
  1996. /* If packed, zero out extraneous elements. */
  1997. /* Symmetric/Triangular Packed -- */
  1998. /* zero out everything after A(IROW,ICOL) */
  1999. if (ipack == 3 || ipack == 4) {
  2000. i__1 = *m;
  2001. for (jc = icol; jc <= i__1; ++jc) {
  2002. i__2 = *lda;
  2003. for (jr = irow + 1; jr <= i__2; ++jr) {
  2004. i__4 = jr + jc * a_dim1;
  2005. a[i__4].r = 0., a[i__4].i = 0.;
  2006. /* L570: */
  2007. }
  2008. irow = 0;
  2009. /* L580: */
  2010. }
  2011. } else if (ipack >= 5) {
  2012. /* Packed Band -- */
  2013. /* 1st row is now in A( UUB+2-j, j), zero above it */
  2014. /* m-th row is now in A( M+UUB-j,j), zero below it */
  2015. /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
  2016. /* zero below it, too. */
  2017. ir1 = uub + llb + 2;
  2018. ir2 = uub + *m + 2;
  2019. i__1 = *n;
  2020. for (jc = 1; jc <= i__1; ++jc) {
  2021. i__2 = uub + 1 - jc;
  2022. for (jr = 1; jr <= i__2; ++jr) {
  2023. i__4 = jr + jc * a_dim1;
  2024. a[i__4].r = 0., a[i__4].i = 0.;
  2025. /* L590: */
  2026. }
  2027. /* Computing MAX */
  2028. /* Computing MIN */
  2029. i__3 = ir1, i__5 = ir2 - jc;
  2030. i__2 = 1, i__4 = f2cmin(i__3,i__5);
  2031. i__6 = *lda;
  2032. for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
  2033. i__2 = jr + jc * a_dim1;
  2034. a[i__2].r = 0., a[i__2].i = 0.;
  2035. /* L600: */
  2036. }
  2037. /* L610: */
  2038. }
  2039. }
  2040. }
  2041. return 0;
  2042. /* End of ZLATMT */
  2043. } /* zlatmt_ */