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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230
  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 */ void 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 */ void 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 */ void 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 */ void zlagge_(integer *, integer *, integer *,
  849. integer *, doublereal *, doublecomplex *, integer *, integer *,
  850. doublecomplex *, integer *), zlaghe_(integer *, integer *,
  851. doublereal *, doublecomplex *, integer *, integer *,
  852. doublecomplex *, integer *);
  853. extern int xerbla_(char *, integer *, ftnlen);
  854. integer ioffst, irsign;
  855. logical givens, iltemp;
  856. //extern /* Double Complex */ VOID zlarnd_(doublecomplex *, integer *,
  857. extern doublecomplex zlarnd_(integer *,
  858. integer *);
  859. extern /* Subroutine */ void zlaset_(char *, integer *, integer *,
  860. doublecomplex *, doublecomplex *, doublecomplex *, integer *), zlartg_(doublecomplex *, doublecomplex *, doublereal *,
  861. doublecomplex *, doublecomplex *);
  862. logical ilextr;
  863. extern /* Subroutine */ void zlagsy_(integer *, integer *, doublereal *,
  864. doublecomplex *, integer *, integer *, doublecomplex *, integer *)
  865. ;
  866. integer ir1, ir2, isympk;
  867. logical topdwn;
  868. extern /* Subroutine */ void zlarot_(logical *, logical *, logical *,
  869. integer *, doublecomplex *, doublecomplex *, doublecomplex *,
  870. integer *, doublecomplex *, doublecomplex *);
  871. integer jch, llb, jkl, jku, uub;
  872. /* -- LAPACK computational routine (version 3.7.0) -- */
  873. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  874. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  875. /* December 2016 */
  876. /* ===================================================================== */
  877. /* 1) Decode and Test the input parameters. */
  878. /* Initialize flags & seed. */
  879. /* Parameter adjustments */
  880. --iseed;
  881. --d__;
  882. a_dim1 = *lda;
  883. a_offset = 1 + a_dim1 * 1;
  884. a -= a_offset;
  885. --work;
  886. /* Function Body */
  887. *info = 0;
  888. /* Quick return if possible */
  889. if (*m == 0 || *n == 0) {
  890. return;
  891. }
  892. /* Decode DIST */
  893. if (lsame_(dist, "U")) {
  894. idist = 1;
  895. } else if (lsame_(dist, "S")) {
  896. idist = 2;
  897. } else if (lsame_(dist, "N")) {
  898. idist = 3;
  899. } else {
  900. idist = -1;
  901. }
  902. /* Decode SYM */
  903. if (lsame_(sym, "N")) {
  904. isym = 1;
  905. irsign = 0;
  906. csym = FALSE_;
  907. } else if (lsame_(sym, "P")) {
  908. isym = 2;
  909. irsign = 0;
  910. csym = FALSE_;
  911. } else if (lsame_(sym, "S")) {
  912. isym = 2;
  913. irsign = 0;
  914. csym = TRUE_;
  915. } else if (lsame_(sym, "H")) {
  916. isym = 2;
  917. irsign = 1;
  918. csym = FALSE_;
  919. } else {
  920. isym = -1;
  921. }
  922. /* Decode PACK */
  923. isympk = 0;
  924. if (lsame_(pack, "N")) {
  925. ipack = 0;
  926. } else if (lsame_(pack, "U")) {
  927. ipack = 1;
  928. isympk = 1;
  929. } else if (lsame_(pack, "L")) {
  930. ipack = 2;
  931. isympk = 1;
  932. } else if (lsame_(pack, "C")) {
  933. ipack = 3;
  934. isympk = 2;
  935. } else if (lsame_(pack, "R")) {
  936. ipack = 4;
  937. isympk = 3;
  938. } else if (lsame_(pack, "B")) {
  939. ipack = 5;
  940. isympk = 3;
  941. } else if (lsame_(pack, "Q")) {
  942. ipack = 6;
  943. isympk = 2;
  944. } else if (lsame_(pack, "Z")) {
  945. ipack = 7;
  946. } else {
  947. ipack = -1;
  948. }
  949. /* Set certain internal parameters */
  950. mnmin = f2cmin(*m,*n);
  951. /* Computing MIN */
  952. i__1 = *kl, i__2 = *m - 1;
  953. llb = f2cmin(i__1,i__2);
  954. /* Computing MIN */
  955. i__1 = *ku, i__2 = *n - 1;
  956. uub = f2cmin(i__1,i__2);
  957. /* Computing MIN */
  958. i__1 = *m, i__2 = *n + llb;
  959. mr = f2cmin(i__1,i__2);
  960. /* Computing MIN */
  961. i__1 = *n, i__2 = *m + uub;
  962. nc = f2cmin(i__1,i__2);
  963. if (ipack == 5 || ipack == 6) {
  964. minlda = uub + 1;
  965. } else if (ipack == 7) {
  966. minlda = llb + uub + 1;
  967. } else {
  968. minlda = *m;
  969. }
  970. /* Use Givens rotation method if bandwidth small enough, */
  971. /* or if LDA is too small to store the matrix unpacked. */
  972. givens = FALSE_;
  973. if (isym == 1) {
  974. /* Computing MAX */
  975. i__1 = 1, i__2 = mr + nc;
  976. if ((doublereal) (llb + uub) < (doublereal) f2cmax(i__1,i__2) * .3) {
  977. givens = TRUE_;
  978. }
  979. } else {
  980. if (llb << 1 < *m) {
  981. givens = TRUE_;
  982. }
  983. }
  984. if (*lda < *m && *lda >= minlda) {
  985. givens = TRUE_;
  986. }
  987. /* Set INFO if an error */
  988. if (*m < 0) {
  989. *info = -1;
  990. } else if (*m != *n && isym != 1) {
  991. *info = -1;
  992. } else if (*n < 0) {
  993. *info = -2;
  994. } else if (idist == -1) {
  995. *info = -3;
  996. } else if (isym == -1) {
  997. *info = -5;
  998. } else if (abs(*mode) > 6) {
  999. *info = -7;
  1000. } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
  1001. *info = -8;
  1002. } else if (*kl < 0) {
  1003. *info = -10;
  1004. } else if (*ku < 0 || isym != 1 && *kl != *ku) {
  1005. *info = -11;
  1006. } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
  1007. == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
  1008. != 0 && *m != *n) {
  1009. *info = -12;
  1010. } else if (*lda < f2cmax(1,minlda)) {
  1011. *info = -14;
  1012. }
  1013. if (*info != 0) {
  1014. i__1 = -(*info);
  1015. xerbla_("ZLATMT", &i__1, 6);
  1016. return;
  1017. }
  1018. /* Initialize random number generator */
  1019. for (i__ = 1; i__ <= 4; ++i__) {
  1020. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  1021. /* L100: */
  1022. }
  1023. if (iseed[4] % 2 != 1) {
  1024. ++iseed[4];
  1025. }
  1026. /* 2) Set up D if indicated. */
  1027. /* Compute D according to COND and MODE */
  1028. dlatm7_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, rank, &
  1029. iinfo);
  1030. if (iinfo != 0) {
  1031. *info = 1;
  1032. return;
  1033. }
  1034. /* Choose Top-Down if D is (apparently) increasing, */
  1035. /* Bottom-Up if D is (apparently) decreasing. */
  1036. if (abs(d__[1]) <= (d__1 = d__[*rank], abs(d__1))) {
  1037. topdwn = TRUE_;
  1038. } else {
  1039. topdwn = FALSE_;
  1040. }
  1041. if (*mode != 0 && abs(*mode) != 6) {
  1042. /* Scale by DMAX */
  1043. temp = abs(d__[1]);
  1044. i__1 = *rank;
  1045. for (i__ = 2; i__ <= i__1; ++i__) {
  1046. /* Computing MAX */
  1047. d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
  1048. temp = f2cmax(d__2,d__3);
  1049. /* L110: */
  1050. }
  1051. if (temp > 0.) {
  1052. alpha = *dmax__ / temp;
  1053. } else {
  1054. *info = 2;
  1055. return;
  1056. }
  1057. dscal_(rank, &alpha, &d__[1], &c__1);
  1058. }
  1059. zlaset_("Full", lda, n, &c_b1, &c_b1, &a[a_offset], lda);
  1060. /* 3) Generate Banded Matrix using Givens rotations. */
  1061. /* Also the special case of UUB=LLB=0 */
  1062. /* Compute Addressing constants to cover all */
  1063. /* storage formats. Whether GE, HE, SY, GB, HB, or SB, */
  1064. /* upper or lower triangle or both, */
  1065. /* the (i,j)-th element is in */
  1066. /* A( i - ISKEW*j + IOFFST, j ) */
  1067. if (ipack > 4) {
  1068. ilda = *lda - 1;
  1069. iskew = 1;
  1070. if (ipack > 5) {
  1071. ioffst = uub + 1;
  1072. } else {
  1073. ioffst = 1;
  1074. }
  1075. } else {
  1076. ilda = *lda;
  1077. iskew = 0;
  1078. ioffst = 0;
  1079. }
  1080. /* IPACKG is the format that the matrix is generated in. If this is */
  1081. /* different from IPACK, then the matrix must be repacked at the */
  1082. /* end. It also signals how to compute the norm, for scaling. */
  1083. ipackg = 0;
  1084. /* Diagonal Matrix -- We are done, unless it */
  1085. /* is to be stored HP/SP/PP/TP (PACK='R' or 'C') */
  1086. if (llb == 0 && uub == 0) {
  1087. i__1 = mnmin;
  1088. for (j = 1; j <= i__1; ++j) {
  1089. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  1090. i__3 = j;
  1091. z__1.r = d__[i__3], z__1.i = 0.;
  1092. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1093. /* L120: */
  1094. }
  1095. if (ipack <= 2 || ipack >= 5) {
  1096. ipackg = ipack;
  1097. }
  1098. } else if (givens) {
  1099. /* Check whether to use Givens rotations, */
  1100. /* Householder transformations, or nothing. */
  1101. if (isym == 1) {
  1102. /* Non-symmetric -- A = U D V */
  1103. if (ipack > 4) {
  1104. ipackg = ipack;
  1105. } else {
  1106. ipackg = 0;
  1107. }
  1108. i__1 = mnmin;
  1109. for (j = 1; j <= i__1; ++j) {
  1110. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  1111. i__3 = j;
  1112. z__1.r = d__[i__3], z__1.i = 0.;
  1113. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1114. /* L130: */
  1115. }
  1116. if (topdwn) {
  1117. jkl = 0;
  1118. i__1 = uub;
  1119. for (jku = 1; jku <= i__1; ++jku) {
  1120. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1121. /* Last row actually rotated is M */
  1122. /* Last column actually rotated is MIN( M+JKU, N ) */
  1123. /* Computing MIN */
  1124. i__3 = *m + jku;
  1125. i__2 = f2cmin(i__3,*n) + jkl - 1;
  1126. for (jr = 1; jr <= i__2; ++jr) {
  1127. extra.r = 0., extra.i = 0.;
  1128. angle = dlarnd_(&c__1, &iseed[1]) *
  1129. 6.2831853071795864769252867663;
  1130. d__1 = cos(angle);
  1131. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1132. z__2=zlarnd_(&c__5, &iseed[1]);
  1133. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1134. c__.r = z__1.r, c__.i = z__1.i;
  1135. d__1 = sin(angle);
  1136. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1137. z__2=zlarnd_( &c__5, &iseed[1]);
  1138. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1139. s.r = z__1.r, s.i = z__1.i;
  1140. /* Computing MAX */
  1141. i__3 = 1, i__4 = jr - jkl;
  1142. icol = f2cmax(i__3,i__4);
  1143. if (jr < *m) {
  1144. /* Computing MIN */
  1145. i__3 = *n, i__4 = jr + jku;
  1146. il = f2cmin(i__3,i__4) + 1 - icol;
  1147. L__1 = jr > jkl;
  1148. zlarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
  1149. a[jr - iskew * icol + ioffst + icol *
  1150. a_dim1], &ilda, &extra, &dummy);
  1151. }
  1152. /* Chase "EXTRA" back up */
  1153. ir = jr;
  1154. ic = icol;
  1155. i__3 = -jkl - jku;
  1156. for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
  1157. jch += i__3) {
  1158. if (ir < *m) {
  1159. zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1160. + (ic + 1) * a_dim1], &extra, &realc,
  1161. &s, &dummy);
  1162. d__1 = dlarnd_(&c__5, &iseed[1]);
  1163. dummy.r = d__1, dummy.i = 0.;
  1164. z__2.r = realc * dummy.r, z__2.i = realc *
  1165. dummy.i;
  1166. d_cnjg(&z__1, &z__2);
  1167. c__.r = z__1.r, c__.i = z__1.i;
  1168. z__3.r = -s.r, z__3.i = -s.i;
  1169. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1170. z__2.i = z__3.r * dummy.i + z__3.i *
  1171. dummy.r;
  1172. d_cnjg(&z__1, &z__2);
  1173. s.r = z__1.r, s.i = z__1.i;
  1174. }
  1175. /* Computing MAX */
  1176. i__4 = 1, i__5 = jch - jku;
  1177. irow = f2cmax(i__4,i__5);
  1178. il = ir + 2 - irow;
  1179. ztemp.r = 0., ztemp.i = 0.;
  1180. iltemp = jch > jku;
  1181. zlarot_(&c_false, &iltemp, &c_true, &il, &c__, &s,
  1182. &a[irow - iskew * ic + ioffst + ic *
  1183. a_dim1], &ilda, &ztemp, &extra);
  1184. if (iltemp) {
  1185. zlartg_(&a[irow + 1 - iskew * (ic + 1) +
  1186. ioffst + (ic + 1) * a_dim1], &ztemp, &
  1187. realc, &s, &dummy);
  1188. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1189. z__1=zlarnd_( &c__5, &iseed[1]);
  1190. dummy.r = z__1.r, dummy.i = z__1.i;
  1191. z__2.r = realc * dummy.r, z__2.i = realc *
  1192. dummy.i;
  1193. d_cnjg(&z__1, &z__2);
  1194. c__.r = z__1.r, c__.i = z__1.i;
  1195. z__3.r = -s.r, z__3.i = -s.i;
  1196. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1197. z__2.i = z__3.r * dummy.i + z__3.i *
  1198. dummy.r;
  1199. d_cnjg(&z__1, &z__2);
  1200. s.r = z__1.r, s.i = z__1.i;
  1201. /* Computing MAX */
  1202. i__4 = 1, i__5 = jch - jku - jkl;
  1203. icol = f2cmax(i__4,i__5);
  1204. il = ic + 2 - icol;
  1205. extra.r = 0., extra.i = 0.;
  1206. L__1 = jch > jku + jkl;
  1207. zlarot_(&c_true, &L__1, &c_true, &il, &c__, &
  1208. s, &a[irow - iskew * icol + ioffst +
  1209. icol * a_dim1], &ilda, &extra, &ztemp)
  1210. ;
  1211. ic = icol;
  1212. ir = irow;
  1213. }
  1214. /* L140: */
  1215. }
  1216. /* L150: */
  1217. }
  1218. /* L160: */
  1219. }
  1220. jku = uub;
  1221. i__1 = llb;
  1222. for (jkl = 1; jkl <= i__1; ++jkl) {
  1223. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1224. /* Computing MIN */
  1225. i__3 = *n + jkl;
  1226. i__2 = f2cmin(i__3,*m) + jku - 1;
  1227. for (jc = 1; jc <= i__2; ++jc) {
  1228. extra.r = 0., extra.i = 0.;
  1229. angle = dlarnd_(&c__1, &iseed[1]) *
  1230. 6.2831853071795864769252867663;
  1231. d__1 = cos(angle);
  1232. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1233. z__2=zlarnd_(&c__5, &iseed[1]);
  1234. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1235. c__.r = z__1.r, c__.i = z__1.i;
  1236. d__1 = sin(angle);
  1237. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1238. z__2=zlarnd_(&c__5, &iseed[1]);
  1239. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1240. s.r = z__1.r, s.i = z__1.i;
  1241. /* Computing MAX */
  1242. i__3 = 1, i__4 = jc - jku;
  1243. irow = f2cmax(i__3,i__4);
  1244. if (jc < *n) {
  1245. /* Computing MIN */
  1246. i__3 = *m, i__4 = jc + jkl;
  1247. il = f2cmin(i__3,i__4) + 1 - irow;
  1248. L__1 = jc > jku;
  1249. zlarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
  1250. &a[irow - iskew * jc + ioffst + jc *
  1251. a_dim1], &ilda, &extra, &dummy);
  1252. }
  1253. /* Chase "EXTRA" back up */
  1254. ic = jc;
  1255. ir = irow;
  1256. i__3 = -jkl - jku;
  1257. for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
  1258. jch += i__3) {
  1259. if (ic < *n) {
  1260. zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1261. + (ic + 1) * a_dim1], &extra, &realc,
  1262. &s, &dummy);
  1263. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1264. z__1=zlarnd_(&c__5, &iseed[1]);
  1265. dummy.r = z__1.r, dummy.i = z__1.i;
  1266. z__2.r = realc * dummy.r, z__2.i = realc *
  1267. dummy.i;
  1268. d_cnjg(&z__1, &z__2);
  1269. c__.r = z__1.r, c__.i = z__1.i;
  1270. z__3.r = -s.r, z__3.i = -s.i;
  1271. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1272. z__2.i = z__3.r * dummy.i + z__3.i *
  1273. dummy.r;
  1274. d_cnjg(&z__1, &z__2);
  1275. s.r = z__1.r, s.i = z__1.i;
  1276. }
  1277. /* Computing MAX */
  1278. i__4 = 1, i__5 = jch - jkl;
  1279. icol = f2cmax(i__4,i__5);
  1280. il = ic + 2 - icol;
  1281. ztemp.r = 0., ztemp.i = 0.;
  1282. iltemp = jch > jkl;
  1283. zlarot_(&c_true, &iltemp, &c_true, &il, &c__, &s,
  1284. &a[ir - iskew * icol + ioffst + icol *
  1285. a_dim1], &ilda, &ztemp, &extra);
  1286. if (iltemp) {
  1287. zlartg_(&a[ir + 1 - iskew * (icol + 1) +
  1288. ioffst + (icol + 1) * a_dim1], &ztemp,
  1289. &realc, &s, &dummy);
  1290. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1291. z__1=zlarnd_(&c__5, &iseed[1]);
  1292. dummy.r = z__1.r, dummy.i = z__1.i;
  1293. z__2.r = realc * dummy.r, z__2.i = realc *
  1294. dummy.i;
  1295. d_cnjg(&z__1, &z__2);
  1296. c__.r = z__1.r, c__.i = z__1.i;
  1297. z__3.r = -s.r, z__3.i = -s.i;
  1298. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1299. z__2.i = z__3.r * dummy.i + z__3.i *
  1300. dummy.r;
  1301. d_cnjg(&z__1, &z__2);
  1302. s.r = z__1.r, s.i = z__1.i;
  1303. /* Computing MAX */
  1304. i__4 = 1, i__5 = jch - jkl - jku;
  1305. irow = f2cmax(i__4,i__5);
  1306. il = ir + 2 - irow;
  1307. extra.r = 0., extra.i = 0.;
  1308. L__1 = jch > jkl + jku;
  1309. zlarot_(&c_false, &L__1, &c_true, &il, &c__, &
  1310. s, &a[irow - iskew * icol + ioffst +
  1311. icol * a_dim1], &ilda, &extra, &ztemp)
  1312. ;
  1313. ic = icol;
  1314. ir = irow;
  1315. }
  1316. /* L170: */
  1317. }
  1318. /* L180: */
  1319. }
  1320. /* L190: */
  1321. }
  1322. } else {
  1323. /* Bottom-Up -- Start at the bottom right. */
  1324. jkl = 0;
  1325. i__1 = uub;
  1326. for (jku = 1; jku <= i__1; ++jku) {
  1327. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1328. /* First row actually rotated is M */
  1329. /* First column actually rotated is MIN( M+JKU, N ) */
  1330. /* Computing MIN */
  1331. i__2 = *m, i__3 = *n + jkl;
  1332. iendch = f2cmin(i__2,i__3) - 1;
  1333. /* Computing MIN */
  1334. i__2 = *m + jku;
  1335. i__3 = 1 - jkl;
  1336. for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
  1337. extra.r = 0., extra.i = 0.;
  1338. angle = dlarnd_(&c__1, &iseed[1]) *
  1339. 6.2831853071795864769252867663;
  1340. d__1 = cos(angle);
  1341. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1342. z__2=zlarnd_( &c__5, &iseed[1]);
  1343. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1344. c__.r = z__1.r, c__.i = z__1.i;
  1345. d__1 = sin(angle);
  1346. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1347. z__2=zlarnd_( &c__5, &iseed[1]);
  1348. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1349. s.r = z__1.r, s.i = z__1.i;
  1350. /* Computing MAX */
  1351. i__2 = 1, i__4 = jc - jku + 1;
  1352. irow = f2cmax(i__2,i__4);
  1353. if (jc > 0) {
  1354. /* Computing MIN */
  1355. i__2 = *m, i__4 = jc + jkl + 1;
  1356. il = f2cmin(i__2,i__4) + 1 - irow;
  1357. L__1 = jc + jkl < *m;
  1358. zlarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
  1359. &a[irow - iskew * jc + ioffst + jc *
  1360. a_dim1], &ilda, &dummy, &extra);
  1361. }
  1362. /* Chase "EXTRA" back down */
  1363. ic = jc;
  1364. i__2 = iendch;
  1365. i__4 = jkl + jku;
  1366. for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
  1367. i__2; jch += i__4) {
  1368. ilextr = ic > 0;
  1369. if (ilextr) {
  1370. zlartg_(&a[jch - iskew * ic + ioffst + ic *
  1371. a_dim1], &extra, &realc, &s, &dummy);
  1372. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1373. z__1=zlarnd_(&c__5, &iseed[1]);
  1374. dummy.r = z__1.r, dummy.i = z__1.i;
  1375. z__1.r = realc * dummy.r, z__1.i = realc *
  1376. dummy.i;
  1377. c__.r = z__1.r, c__.i = z__1.i;
  1378. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1379. z__1.i = s.r * dummy.i + s.i *
  1380. dummy.r;
  1381. s.r = z__1.r, s.i = z__1.i;
  1382. }
  1383. ic = f2cmax(1,ic);
  1384. /* Computing MIN */
  1385. i__5 = *n - 1, i__6 = jch + jku;
  1386. icol = f2cmin(i__5,i__6);
  1387. iltemp = jch + jku < *n;
  1388. ztemp.r = 0., ztemp.i = 0.;
  1389. i__5 = icol + 2 - ic;
  1390. zlarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
  1391. s, &a[jch - iskew * ic + ioffst + ic *
  1392. a_dim1], &ilda, &extra, &ztemp);
  1393. if (iltemp) {
  1394. zlartg_(&a[jch - iskew * icol + ioffst + icol
  1395. * a_dim1], &ztemp, &realc, &s, &dummy)
  1396. ;
  1397. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1398. z__1=zlarnd_(&c__5, &iseed[1]);
  1399. dummy.r = z__1.r, dummy.i = z__1.i;
  1400. z__1.r = realc * dummy.r, z__1.i = realc *
  1401. dummy.i;
  1402. c__.r = z__1.r, c__.i = z__1.i;
  1403. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1404. z__1.i = s.r * dummy.i + s.i *
  1405. dummy.r;
  1406. s.r = z__1.r, s.i = z__1.i;
  1407. /* Computing MIN */
  1408. i__5 = iendch, i__6 = jch + jkl + jku;
  1409. il = f2cmin(i__5,i__6) + 2 - jch;
  1410. extra.r = 0., extra.i = 0.;
  1411. L__1 = jch + jkl + jku <= iendch;
  1412. zlarot_(&c_false, &c_true, &L__1, &il, &c__, &
  1413. s, &a[jch - iskew * icol + ioffst +
  1414. icol * a_dim1], &ilda, &ztemp, &extra)
  1415. ;
  1416. ic = icol;
  1417. }
  1418. /* L200: */
  1419. }
  1420. /* L210: */
  1421. }
  1422. /* L220: */
  1423. }
  1424. jku = uub;
  1425. i__1 = llb;
  1426. for (jkl = 1; jkl <= i__1; ++jkl) {
  1427. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1428. /* First row actually rotated is MIN( N+JKL, M ) */
  1429. /* First column actually rotated is N */
  1430. /* Computing MIN */
  1431. i__3 = *n, i__4 = *m + jku;
  1432. iendch = f2cmin(i__3,i__4) - 1;
  1433. /* Computing MIN */
  1434. i__3 = *n + jkl;
  1435. i__4 = 1 - jku;
  1436. for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
  1437. extra.r = 0., extra.i = 0.;
  1438. angle = dlarnd_(&c__1, &iseed[1]) *
  1439. 6.2831853071795864769252867663;
  1440. d__1 = cos(angle);
  1441. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1442. z__2=zlarnd_(&c__5, &iseed[1]);
  1443. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1444. c__.r = z__1.r, c__.i = z__1.i;
  1445. d__1 = sin(angle);
  1446. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1447. z__2=zlarnd_(&c__5, &iseed[1]);
  1448. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1449. s.r = z__1.r, s.i = z__1.i;
  1450. /* Computing MAX */
  1451. i__3 = 1, i__2 = jr - jkl + 1;
  1452. icol = f2cmax(i__3,i__2);
  1453. if (jr > 0) {
  1454. /* Computing MIN */
  1455. i__3 = *n, i__2 = jr + jku + 1;
  1456. il = f2cmin(i__3,i__2) + 1 - icol;
  1457. L__1 = jr + jku < *n;
  1458. zlarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
  1459. a[jr - iskew * icol + ioffst + icol *
  1460. a_dim1], &ilda, &dummy, &extra);
  1461. }
  1462. /* Chase "EXTRA" back down */
  1463. ir = jr;
  1464. i__3 = iendch;
  1465. i__2 = jkl + jku;
  1466. for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
  1467. i__3; jch += i__2) {
  1468. ilextr = ir > 0;
  1469. if (ilextr) {
  1470. zlartg_(&a[ir - iskew * jch + ioffst + jch *
  1471. a_dim1], &extra, &realc, &s, &dummy);
  1472. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1473. z__1=zlarnd_( &c__5, &iseed[1]);
  1474. dummy.r = z__1.r, dummy.i = z__1.i;
  1475. z__1.r = realc * dummy.r, z__1.i = realc *
  1476. dummy.i;
  1477. c__.r = z__1.r, c__.i = z__1.i;
  1478. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1479. z__1.i = s.r * dummy.i + s.i *
  1480. dummy.r;
  1481. s.r = z__1.r, s.i = z__1.i;
  1482. }
  1483. ir = f2cmax(1,ir);
  1484. /* Computing MIN */
  1485. i__5 = *m - 1, i__6 = jch + jkl;
  1486. irow = f2cmin(i__5,i__6);
  1487. iltemp = jch + jkl < *m;
  1488. ztemp.r = 0., ztemp.i = 0.;
  1489. i__5 = irow + 2 - ir;
  1490. zlarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
  1491. s, &a[ir - iskew * jch + ioffst + jch *
  1492. a_dim1], &ilda, &extra, &ztemp);
  1493. if (iltemp) {
  1494. zlartg_(&a[irow - iskew * jch + ioffst + jch *
  1495. a_dim1], &ztemp, &realc, &s, &dummy);
  1496. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1497. z__1=zlarnd_(&c__5, &iseed[1]);
  1498. dummy.r = z__1.r, dummy.i = z__1.i;
  1499. z__1.r = realc * dummy.r, z__1.i = realc *
  1500. dummy.i;
  1501. c__.r = z__1.r, c__.i = z__1.i;
  1502. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1503. z__1.i = s.r * dummy.i + s.i *
  1504. dummy.r;
  1505. s.r = z__1.r, s.i = z__1.i;
  1506. /* Computing MIN */
  1507. i__5 = iendch, i__6 = jch + jkl + jku;
  1508. il = f2cmin(i__5,i__6) + 2 - jch;
  1509. extra.r = 0., extra.i = 0.;
  1510. L__1 = jch + jkl + jku <= iendch;
  1511. zlarot_(&c_true, &c_true, &L__1, &il, &c__, &
  1512. s, &a[irow - iskew * jch + ioffst +
  1513. jch * a_dim1], &ilda, &ztemp, &extra);
  1514. ir = irow;
  1515. }
  1516. /* L230: */
  1517. }
  1518. /* L240: */
  1519. }
  1520. /* L250: */
  1521. }
  1522. }
  1523. } else {
  1524. /* Symmetric -- A = U D U' */
  1525. /* Hermitian -- A = U D U* */
  1526. ipackg = ipack;
  1527. ioffg = ioffst;
  1528. if (topdwn) {
  1529. /* Top-Down -- Generate Upper triangle only */
  1530. if (ipack >= 5) {
  1531. ipackg = 6;
  1532. ioffg = uub + 1;
  1533. } else {
  1534. ipackg = 1;
  1535. }
  1536. i__1 = mnmin;
  1537. for (j = 1; j <= i__1; ++j) {
  1538. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1539. i__2 = j;
  1540. z__1.r = d__[i__2], z__1.i = 0.;
  1541. a[i__4].r = z__1.r, a[i__4].i = z__1.i;
  1542. /* L260: */
  1543. }
  1544. i__1 = uub;
  1545. for (k = 1; k <= i__1; ++k) {
  1546. i__4 = *n - 1;
  1547. for (jc = 1; jc <= i__4; ++jc) {
  1548. /* Computing MAX */
  1549. i__2 = 1, i__3 = jc - k;
  1550. irow = f2cmax(i__2,i__3);
  1551. /* Computing MIN */
  1552. i__2 = jc + 1, i__3 = k + 2;
  1553. il = f2cmin(i__2,i__3);
  1554. extra.r = 0., extra.i = 0.;
  1555. i__2 = jc - iskew * (jc + 1) + ioffg + (jc + 1) *
  1556. a_dim1;
  1557. ztemp.r = a[i__2].r, ztemp.i = a[i__2].i;
  1558. angle = dlarnd_(&c__1, &iseed[1]) *
  1559. 6.2831853071795864769252867663;
  1560. d__1 = cos(angle);
  1561. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1562. z__2=zlarnd_(&c__5, &iseed[1]);
  1563. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1564. c__.r = z__1.r, c__.i = z__1.i;
  1565. d__1 = sin(angle);
  1566. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1567. z__2=zlarnd_( &c__5, &iseed[1]);
  1568. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1569. s.r = z__1.r, s.i = z__1.i;
  1570. if (csym) {
  1571. ct.r = c__.r, ct.i = c__.i;
  1572. st.r = s.r, st.i = s.i;
  1573. } else {
  1574. d_cnjg(&z__1, &ztemp);
  1575. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1576. d_cnjg(&z__1, &c__);
  1577. ct.r = z__1.r, ct.i = z__1.i;
  1578. d_cnjg(&z__1, &s);
  1579. st.r = z__1.r, st.i = z__1.i;
  1580. }
  1581. L__1 = jc > k;
  1582. zlarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
  1583. irow - iskew * jc + ioffg + jc * a_dim1], &
  1584. ilda, &extra, &ztemp);
  1585. /* Computing MIN */
  1586. i__3 = k, i__5 = *n - jc;
  1587. i__2 = f2cmin(i__3,i__5) + 1;
  1588. zlarot_(&c_true, &c_true, &c_false, &i__2, &ct, &st, &
  1589. a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
  1590. ilda, &ztemp, &dummy);
  1591. /* Chase EXTRA back up the matrix */
  1592. icol = jc;
  1593. i__2 = -k;
  1594. for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
  1595. jch += i__2) {
  1596. zlartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
  1597. (icol + 1) * a_dim1], &extra, &realc, &s,
  1598. &dummy);
  1599. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1600. z__1=zlarnd_(&c__5, &iseed[1]);
  1601. dummy.r = z__1.r, dummy.i = z__1.i;
  1602. z__2.r = realc * dummy.r, z__2.i = realc *
  1603. dummy.i;
  1604. d_cnjg(&z__1, &z__2);
  1605. c__.r = z__1.r, c__.i = z__1.i;
  1606. z__3.r = -s.r, z__3.i = -s.i;
  1607. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1608. z__2.i = z__3.r * dummy.i + z__3.i *
  1609. dummy.r;
  1610. d_cnjg(&z__1, &z__2);
  1611. s.r = z__1.r, s.i = z__1.i;
  1612. i__3 = jch - iskew * (jch + 1) + ioffg + (jch + 1)
  1613. * a_dim1;
  1614. ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
  1615. if (csym) {
  1616. ct.r = c__.r, ct.i = c__.i;
  1617. st.r = s.r, st.i = s.i;
  1618. } else {
  1619. d_cnjg(&z__1, &ztemp);
  1620. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1621. d_cnjg(&z__1, &c__);
  1622. ct.r = z__1.r, ct.i = z__1.i;
  1623. d_cnjg(&z__1, &s);
  1624. st.r = z__1.r, st.i = z__1.i;
  1625. }
  1626. i__3 = k + 2;
  1627. zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1628. s, &a[(1 - iskew) * jch + ioffg + jch *
  1629. a_dim1], &ilda, &ztemp, &extra);
  1630. /* Computing MAX */
  1631. i__3 = 1, i__5 = jch - k;
  1632. irow = f2cmax(i__3,i__5);
  1633. /* Computing MIN */
  1634. i__3 = jch + 1, i__5 = k + 2;
  1635. il = f2cmin(i__3,i__5);
  1636. extra.r = 0., extra.i = 0.;
  1637. L__1 = jch > k;
  1638. zlarot_(&c_false, &L__1, &c_true, &il, &ct, &st, &
  1639. a[irow - iskew * jch + ioffg + jch *
  1640. a_dim1], &ilda, &extra, &ztemp);
  1641. icol = jch;
  1642. /* L270: */
  1643. }
  1644. /* L280: */
  1645. }
  1646. /* L290: */
  1647. }
  1648. /* If we need lower triangle, copy from upper. Note that */
  1649. /* the order of copying is chosen to work for 'q' -> 'b' */
  1650. if (ipack != ipackg && ipack != 3) {
  1651. i__1 = *n;
  1652. for (jc = 1; jc <= i__1; ++jc) {
  1653. irow = ioffst - iskew * jc;
  1654. if (csym) {
  1655. /* Computing MIN */
  1656. i__2 = *n, i__3 = jc + uub;
  1657. i__4 = f2cmin(i__2,i__3);
  1658. for (jr = jc; jr <= i__4; ++jr) {
  1659. i__2 = jr + irow + jc * a_dim1;
  1660. i__3 = jc - iskew * jr + ioffg + jr * a_dim1;
  1661. a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
  1662. /* L300: */
  1663. }
  1664. } else {
  1665. /* Computing MIN */
  1666. i__2 = *n, i__3 = jc + uub;
  1667. i__4 = f2cmin(i__2,i__3);
  1668. for (jr = jc; jr <= i__4; ++jr) {
  1669. i__2 = jr + irow + jc * a_dim1;
  1670. d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
  1671. * a_dim1]);
  1672. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1673. /* L310: */
  1674. }
  1675. }
  1676. /* L320: */
  1677. }
  1678. if (ipack == 5) {
  1679. i__1 = *n;
  1680. for (jc = *n - uub + 1; jc <= i__1; ++jc) {
  1681. i__4 = uub + 1;
  1682. for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
  1683. i__2 = jr + jc * a_dim1;
  1684. a[i__2].r = 0., a[i__2].i = 0.;
  1685. /* L330: */
  1686. }
  1687. /* L340: */
  1688. }
  1689. }
  1690. if (ipackg == 6) {
  1691. ipackg = ipack;
  1692. } else {
  1693. ipackg = 0;
  1694. }
  1695. }
  1696. } else {
  1697. /* Bottom-Up -- Generate Lower triangle only */
  1698. if (ipack >= 5) {
  1699. ipackg = 5;
  1700. if (ipack == 6) {
  1701. ioffg = 1;
  1702. }
  1703. } else {
  1704. ipackg = 2;
  1705. }
  1706. i__1 = mnmin;
  1707. for (j = 1; j <= i__1; ++j) {
  1708. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1709. i__2 = j;
  1710. z__1.r = d__[i__2], z__1.i = 0.;
  1711. a[i__4].r = z__1.r, a[i__4].i = z__1.i;
  1712. /* L350: */
  1713. }
  1714. i__1 = uub;
  1715. for (k = 1; k <= i__1; ++k) {
  1716. for (jc = *n - 1; jc >= 1; --jc) {
  1717. /* Computing MIN */
  1718. i__4 = *n + 1 - jc, i__2 = k + 2;
  1719. il = f2cmin(i__4,i__2);
  1720. extra.r = 0., extra.i = 0.;
  1721. i__4 = (1 - iskew) * jc + 1 + ioffg + jc * a_dim1;
  1722. ztemp.r = a[i__4].r, ztemp.i = a[i__4].i;
  1723. angle = dlarnd_(&c__1, &iseed[1]) *
  1724. 6.2831853071795864769252867663;
  1725. d__1 = cos(angle);
  1726. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1727. z__2=zlarnd_(&c__5, &iseed[1]);
  1728. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1729. c__.r = z__1.r, c__.i = z__1.i;
  1730. d__1 = sin(angle);
  1731. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1732. z__2=zlarnd_(&c__5, &iseed[1]);
  1733. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1734. s.r = z__1.r, s.i = z__1.i;
  1735. if (csym) {
  1736. ct.r = c__.r, ct.i = c__.i;
  1737. st.r = s.r, st.i = s.i;
  1738. } else {
  1739. d_cnjg(&z__1, &ztemp);
  1740. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1741. d_cnjg(&z__1, &c__);
  1742. ct.r = z__1.r, ct.i = z__1.i;
  1743. d_cnjg(&z__1, &s);
  1744. st.r = z__1.r, st.i = z__1.i;
  1745. }
  1746. L__1 = *n - jc > k;
  1747. zlarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
  1748. 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
  1749. &ztemp, &extra);
  1750. /* Computing MAX */
  1751. i__4 = 1, i__2 = jc - k + 1;
  1752. icol = f2cmax(i__4,i__2);
  1753. i__4 = jc + 2 - icol;
  1754. zlarot_(&c_true, &c_false, &c_true, &i__4, &ct, &st, &
  1755. a[jc - iskew * icol + ioffg + icol * a_dim1],
  1756. &ilda, &dummy, &ztemp);
  1757. /* Chase EXTRA back down the matrix */
  1758. icol = jc;
  1759. i__4 = *n - 1;
  1760. i__2 = k;
  1761. for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
  1762. i__4; jch += i__2) {
  1763. zlartg_(&a[jch - iskew * icol + ioffg + icol *
  1764. a_dim1], &extra, &realc, &s, &dummy);
  1765. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1766. z__1=zlarnd_(&c__5, &iseed[1]);
  1767. dummy.r = z__1.r, dummy.i = z__1.i;
  1768. z__1.r = realc * dummy.r, z__1.i = realc *
  1769. dummy.i;
  1770. c__.r = z__1.r, c__.i = z__1.i;
  1771. z__1.r = s.r * dummy.r - s.i * dummy.i, z__1.i =
  1772. s.r * dummy.i + s.i * dummy.r;
  1773. s.r = z__1.r, s.i = z__1.i;
  1774. i__3 = (1 - iskew) * jch + 1 + ioffg + jch *
  1775. a_dim1;
  1776. ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
  1777. if (csym) {
  1778. ct.r = c__.r, ct.i = c__.i;
  1779. st.r = s.r, st.i = s.i;
  1780. } else {
  1781. d_cnjg(&z__1, &ztemp);
  1782. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1783. d_cnjg(&z__1, &c__);
  1784. ct.r = z__1.r, ct.i = z__1.i;
  1785. d_cnjg(&z__1, &s);
  1786. st.r = z__1.r, st.i = z__1.i;
  1787. }
  1788. i__3 = k + 2;
  1789. zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1790. s, &a[jch - iskew * icol + ioffg + icol *
  1791. a_dim1], &ilda, &extra, &ztemp);
  1792. /* Computing MIN */
  1793. i__3 = *n + 1 - jch, i__5 = k + 2;
  1794. il = f2cmin(i__3,i__5);
  1795. extra.r = 0., extra.i = 0.;
  1796. L__1 = *n - jch > k;
  1797. zlarot_(&c_false, &c_true, &L__1, &il, &ct, &st, &
  1798. a[(1 - iskew) * jch + ioffg + jch *
  1799. a_dim1], &ilda, &ztemp, &extra);
  1800. icol = jch;
  1801. /* L360: */
  1802. }
  1803. /* L370: */
  1804. }
  1805. /* L380: */
  1806. }
  1807. /* If we need upper triangle, copy from lower. Note that */
  1808. /* the order of copying is chosen to work for 'b' -> 'q' */
  1809. if (ipack != ipackg && ipack != 4) {
  1810. for (jc = *n; jc >= 1; --jc) {
  1811. irow = ioffst - iskew * jc;
  1812. if (csym) {
  1813. /* Computing MAX */
  1814. i__2 = 1, i__4 = jc - uub;
  1815. i__1 = f2cmax(i__2,i__4);
  1816. for (jr = jc; jr >= i__1; --jr) {
  1817. i__2 = jr + irow + jc * a_dim1;
  1818. i__4 = jc - iskew * jr + ioffg + jr * a_dim1;
  1819. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1820. /* L390: */
  1821. }
  1822. } else {
  1823. /* Computing MAX */
  1824. i__2 = 1, i__4 = jc - uub;
  1825. i__1 = f2cmax(i__2,i__4);
  1826. for (jr = jc; jr >= i__1; --jr) {
  1827. i__2 = jr + irow + jc * a_dim1;
  1828. d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
  1829. * a_dim1]);
  1830. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1831. /* L400: */
  1832. }
  1833. }
  1834. /* L410: */
  1835. }
  1836. if (ipack == 6) {
  1837. i__1 = uub;
  1838. for (jc = 1; jc <= i__1; ++jc) {
  1839. i__2 = uub + 1 - jc;
  1840. for (jr = 1; jr <= i__2; ++jr) {
  1841. i__4 = jr + jc * a_dim1;
  1842. a[i__4].r = 0., a[i__4].i = 0.;
  1843. /* L420: */
  1844. }
  1845. /* L430: */
  1846. }
  1847. }
  1848. if (ipackg == 5) {
  1849. ipackg = ipack;
  1850. } else {
  1851. ipackg = 0;
  1852. }
  1853. }
  1854. }
  1855. /* Ensure that the diagonal is real if Hermitian */
  1856. if (! csym) {
  1857. i__1 = *n;
  1858. for (jc = 1; jc <= i__1; ++jc) {
  1859. irow = ioffst + (1 - iskew) * jc;
  1860. i__2 = irow + jc * a_dim1;
  1861. i__4 = irow + jc * a_dim1;
  1862. d__1 = a[i__4].r;
  1863. z__1.r = d__1, z__1.i = 0.;
  1864. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1865. /* L440: */
  1866. }
  1867. }
  1868. }
  1869. } else {
  1870. /* 4) Generate Banded Matrix by first */
  1871. /* Rotating by random Unitary matrices, */
  1872. /* then reducing the bandwidth using Householder */
  1873. /* transformations. */
  1874. /* Note: we should get here only if LDA .ge. N */
  1875. if (isym == 1) {
  1876. /* Non-symmetric -- A = U D V */
  1877. zlagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
  1878. 1], &work[1], &iinfo);
  1879. } else {
  1880. /* Symmetric -- A = U D U' or */
  1881. /* Hermitian -- A = U D U* */
  1882. if (csym) {
  1883. zlagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1884. 1], &iinfo);
  1885. } else {
  1886. zlaghe_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1887. 1], &iinfo);
  1888. }
  1889. }
  1890. if (iinfo != 0) {
  1891. *info = 3;
  1892. return;
  1893. }
  1894. }
  1895. /* 5) Pack the matrix */
  1896. if (ipack != ipackg) {
  1897. if (ipack == 1) {
  1898. /* 'U' -- Upper triangular, not packed */
  1899. i__1 = *m;
  1900. for (j = 1; j <= i__1; ++j) {
  1901. i__2 = *m;
  1902. for (i__ = j + 1; i__ <= i__2; ++i__) {
  1903. i__4 = i__ + j * a_dim1;
  1904. a[i__4].r = 0., a[i__4].i = 0.;
  1905. /* L450: */
  1906. }
  1907. /* L460: */
  1908. }
  1909. } else if (ipack == 2) {
  1910. /* 'L' -- Lower triangular, not packed */
  1911. i__1 = *m;
  1912. for (j = 2; j <= i__1; ++j) {
  1913. i__2 = j - 1;
  1914. for (i__ = 1; i__ <= i__2; ++i__) {
  1915. i__4 = i__ + j * a_dim1;
  1916. a[i__4].r = 0., a[i__4].i = 0.;
  1917. /* L470: */
  1918. }
  1919. /* L480: */
  1920. }
  1921. } else if (ipack == 3) {
  1922. /* 'C' -- Upper triangle packed Columnwise. */
  1923. icol = 1;
  1924. irow = 0;
  1925. i__1 = *m;
  1926. for (j = 1; j <= i__1; ++j) {
  1927. i__2 = j;
  1928. for (i__ = 1; i__ <= i__2; ++i__) {
  1929. ++irow;
  1930. if (irow > *lda) {
  1931. irow = 1;
  1932. ++icol;
  1933. }
  1934. i__4 = irow + icol * a_dim1;
  1935. i__3 = i__ + j * a_dim1;
  1936. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1937. /* L490: */
  1938. }
  1939. /* L500: */
  1940. }
  1941. } else if (ipack == 4) {
  1942. /* 'R' -- Lower triangle packed Columnwise. */
  1943. icol = 1;
  1944. irow = 0;
  1945. i__1 = *m;
  1946. for (j = 1; j <= i__1; ++j) {
  1947. i__2 = *m;
  1948. for (i__ = j; i__ <= i__2; ++i__) {
  1949. ++irow;
  1950. if (irow > *lda) {
  1951. irow = 1;
  1952. ++icol;
  1953. }
  1954. i__4 = irow + icol * a_dim1;
  1955. i__3 = i__ + j * a_dim1;
  1956. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1957. /* L510: */
  1958. }
  1959. /* L520: */
  1960. }
  1961. } else if (ipack >= 5) {
  1962. /* 'B' -- The lower triangle is packed as a band matrix. */
  1963. /* 'Q' -- The upper triangle is packed as a band matrix. */
  1964. /* 'Z' -- The whole matrix is packed as a band matrix. */
  1965. if (ipack == 5) {
  1966. uub = 0;
  1967. }
  1968. if (ipack == 6) {
  1969. llb = 0;
  1970. }
  1971. i__1 = uub;
  1972. for (j = 1; j <= i__1; ++j) {
  1973. /* Computing MIN */
  1974. i__2 = j + llb;
  1975. for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
  1976. i__2 = i__ - j + uub + 1 + j * a_dim1;
  1977. i__4 = i__ + j * a_dim1;
  1978. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1979. /* L530: */
  1980. }
  1981. /* L540: */
  1982. }
  1983. i__1 = *n;
  1984. for (j = uub + 2; j <= i__1; ++j) {
  1985. /* Computing MIN */
  1986. i__4 = j + llb;
  1987. i__2 = f2cmin(i__4,*m);
  1988. for (i__ = j - uub; i__ <= i__2; ++i__) {
  1989. i__4 = i__ - j + uub + 1 + j * a_dim1;
  1990. i__3 = i__ + j * a_dim1;
  1991. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1992. /* L550: */
  1993. }
  1994. /* L560: */
  1995. }
  1996. }
  1997. /* If packed, zero out extraneous elements. */
  1998. /* Symmetric/Triangular Packed -- */
  1999. /* zero out everything after A(IROW,ICOL) */
  2000. if (ipack == 3 || ipack == 4) {
  2001. i__1 = *m;
  2002. for (jc = icol; jc <= i__1; ++jc) {
  2003. i__2 = *lda;
  2004. for (jr = irow + 1; jr <= i__2; ++jr) {
  2005. i__4 = jr + jc * a_dim1;
  2006. a[i__4].r = 0., a[i__4].i = 0.;
  2007. /* L570: */
  2008. }
  2009. irow = 0;
  2010. /* L580: */
  2011. }
  2012. } else if (ipack >= 5) {
  2013. /* Packed Band -- */
  2014. /* 1st row is now in A( UUB+2-j, j), zero above it */
  2015. /* m-th row is now in A( M+UUB-j,j), zero below it */
  2016. /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
  2017. /* zero below it, too. */
  2018. ir1 = uub + llb + 2;
  2019. ir2 = uub + *m + 2;
  2020. i__1 = *n;
  2021. for (jc = 1; jc <= i__1; ++jc) {
  2022. i__2 = uub + 1 - jc;
  2023. for (jr = 1; jr <= i__2; ++jr) {
  2024. i__4 = jr + jc * a_dim1;
  2025. a[i__4].r = 0., a[i__4].i = 0.;
  2026. /* L590: */
  2027. }
  2028. /* Computing MAX */
  2029. /* Computing MIN */
  2030. i__3 = ir1, i__5 = ir2 - jc;
  2031. i__2 = 1, i__4 = f2cmin(i__3,i__5);
  2032. i__6 = *lda;
  2033. for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
  2034. i__2 = jr + jc * a_dim1;
  2035. a[i__2].r = 0., a[i__2].i = 0.;
  2036. /* L600: */
  2037. }
  2038. /* L610: */
  2039. }
  2040. }
  2041. }
  2042. return;
  2043. /* End of ZLATMT */
  2044. } /* zlatmt_ */