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.

clatms.c 65 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217
  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]/df(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 complex c_b1 = {0.f,0.f};
  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 CLATMS */
  492. /* =========== DOCUMENTATION =========== */
  493. /* Online html documentation available at */
  494. /* http://www.netlib.org/lapack/explore-html/ */
  495. /* Definition: */
  496. /* =========== */
  497. /* SUBROUTINE CLATMS( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
  498. /* KL, KU, PACK, A, LDA, WORK, INFO ) */
  499. /* CHARACTER DIST, PACK, SYM */
  500. /* INTEGER INFO, KL, KU, LDA, M, MODE, N */
  501. /* REAL COND, DMAX */
  502. /* INTEGER ISEED( 4 ) */
  503. /* REAL D( * ) */
  504. /* COMPLEX A( LDA, * ), WORK( * ) */
  505. /* > \par Purpose: */
  506. /* ============= */
  507. /* > */
  508. /* > \verbatim */
  509. /* > */
  510. /* > CLATMS generates random matrices with specified singular values */
  511. /* > (or hermitian with specified eigenvalues) */
  512. /* > for testing LAPACK programs. */
  513. /* > */
  514. /* > CLATMS 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 CLATMS */
  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 REAL 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:N)=1.0/COND */
  642. /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
  643. /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-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 REAL */
  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 REAL */
  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] KL */
  680. /* > \verbatim */
  681. /* > KL is INTEGER */
  682. /* > This specifies the lower bandwidth of the matrix. For */
  683. /* > example, KL=0 implies upper triangular, KL=1 implies upper */
  684. /* > Hessenberg, and KL being at least M-1 means that the matrix */
  685. /* > has full lower bandwidth. KL must equal KU if the matrix */
  686. /* > is symmetric or hermitian. */
  687. /* > Not modified. */
  688. /* > \endverbatim */
  689. /* > */
  690. /* > \param[in] KU */
  691. /* > \verbatim */
  692. /* > KU is INTEGER */
  693. /* > This specifies the upper bandwidth of the matrix. For */
  694. /* > example, KU=0 implies lower triangular, KU=1 implies lower */
  695. /* > Hessenberg, and KU being at least N-1 means that the matrix */
  696. /* > has full upper bandwidth. KL must equal KU if the matrix */
  697. /* > is symmetric or hermitian. */
  698. /* > Not modified. */
  699. /* > \endverbatim */
  700. /* > */
  701. /* > \param[in] PACK */
  702. /* > \verbatim */
  703. /* > PACK is CHARACTER*1 */
  704. /* > This specifies packing of matrix as follows: */
  705. /* > 'N' => no packing */
  706. /* > 'U' => zero out all subdiagonal entries (if symmetric */
  707. /* > or hermitian) */
  708. /* > 'L' => zero out all superdiagonal entries (if symmetric */
  709. /* > or hermitian) */
  710. /* > 'C' => store the upper triangle columnwise (only if the */
  711. /* > matrix is symmetric, hermitian, or upper triangular) */
  712. /* > 'R' => store the lower triangle columnwise (only if the */
  713. /* > matrix is symmetric, hermitian, or lower triangular) */
  714. /* > 'B' => store the lower triangle in band storage scheme */
  715. /* > (only if the matrix is symmetric, hermitian, or */
  716. /* > lower triangular) */
  717. /* > 'Q' => store the upper triangle in band storage scheme */
  718. /* > (only if the matrix is symmetric, hermitian, or */
  719. /* > upper triangular) */
  720. /* > 'Z' => store the entire matrix in band storage scheme */
  721. /* > (pivoting can be provided for by using this */
  722. /* > option to store A in the trailing rows of */
  723. /* > the allocated storage) */
  724. /* > */
  725. /* > Using these options, the various LAPACK packed and banded */
  726. /* > storage schemes can be obtained: */
  727. /* > GB - use 'Z' */
  728. /* > PB, SB, HB, or TB - use 'B' or 'Q' */
  729. /* > PP, SP, HB, or TP - use 'C' or 'R' */
  730. /* > */
  731. /* > If two calls to CLATMS differ only in the PACK parameter, */
  732. /* > they will generate mathematically equivalent matrices. */
  733. /* > Not modified. */
  734. /* > \endverbatim */
  735. /* > */
  736. /* > \param[in,out] A */
  737. /* > \verbatim */
  738. /* > A is COMPLEX array, dimension ( LDA, N ) */
  739. /* > On exit A is the desired test matrix. A is first generated */
  740. /* > in full (unpacked) form, and then packed, if so specified */
  741. /* > by PACK. Thus, the first M elements of the first N */
  742. /* > columns will always be modified. If PACK specifies a */
  743. /* > packed or banded storage scheme, all LDA elements of the */
  744. /* > first N columns will be modified; the elements of the */
  745. /* > array which do not correspond to elements of the generated */
  746. /* > matrix are set to zero. */
  747. /* > Modified. */
  748. /* > \endverbatim */
  749. /* > */
  750. /* > \param[in] LDA */
  751. /* > \verbatim */
  752. /* > LDA is INTEGER */
  753. /* > LDA specifies the first dimension of A as declared in the */
  754. /* > calling program. If PACK='N', 'U', 'L', 'C', or 'R', then */
  755. /* > LDA must be at least M. If PACK='B' or 'Q', then LDA must */
  756. /* > be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)). */
  757. /* > If PACK='Z', LDA must be large enough to hold the packed */
  758. /* > array: MIN( KU, N-1) + MIN( KL, M-1) + 1. */
  759. /* > Not modified. */
  760. /* > \endverbatim */
  761. /* > */
  762. /* > \param[out] WORK */
  763. /* > \verbatim */
  764. /* > WORK is COMPLEX array, dimension ( 3*MAX( N, M ) ) */
  765. /* > Workspace. */
  766. /* > Modified. */
  767. /* > \endverbatim */
  768. /* > */
  769. /* > \param[out] INFO */
  770. /* > \verbatim */
  771. /* > INFO is INTEGER */
  772. /* > Error code. On exit, INFO will be set to one of the */
  773. /* > following values: */
  774. /* > 0 => normal return */
  775. /* > -1 => M negative or unequal to N and SYM='S', 'H', or 'P' */
  776. /* > -2 => N negative */
  777. /* > -3 => DIST illegal string */
  778. /* > -5 => SYM illegal string */
  779. /* > -7 => MODE not in range -6 to 6 */
  780. /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
  781. /* > -10 => KL negative */
  782. /* > -11 => KU negative, or SYM is not 'N' and KU is not equal to */
  783. /* > KL */
  784. /* > -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N'; */
  785. /* > or PACK='C' or 'Q' and SYM='N' and KL is not zero; */
  786. /* > or PACK='R' or 'B' and SYM='N' and KU is not zero; */
  787. /* > or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not */
  788. /* > N. */
  789. /* > -14 => LDA is less than M, or PACK='Z' and LDA is less than */
  790. /* > MIN(KU,N-1) + MIN(KL,M-1) + 1. */
  791. /* > 1 => Error return from SLATM1 */
  792. /* > 2 => Cannot scale to DMAX (f2cmax. sing. value is 0) */
  793. /* > 3 => Error return from CLAGGE, CLAGHE or CLAGSY */
  794. /* > \endverbatim */
  795. /* Authors: */
  796. /* ======== */
  797. /* > \author Univ. of Tennessee */
  798. /* > \author Univ. of California Berkeley */
  799. /* > \author Univ. of Colorado Denver */
  800. /* > \author NAG Ltd. */
  801. /* > \date December 2016 */
  802. /* > \ingroup complex_matgen */
  803. /* ===================================================================== */
  804. /* Subroutine */ void clatms_(integer *m, integer *n, char *dist, integer *
  805. iseed, char *sym, real *d__, integer *mode, real *cond, real *dmax__,
  806. integer *kl, integer *ku, char *pack, complex *a, integer *lda,
  807. complex *work, integer *info)
  808. {
  809. /* System generated locals */
  810. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  811. real r__1, r__2, r__3;
  812. complex q__1, q__2, q__3;
  813. logical L__1;
  814. /* Local variables */
  815. integer ilda, icol;
  816. real temp;
  817. logical csym;
  818. integer irow, isym;
  819. complex c__;
  820. integer i__, j, k;
  821. complex s;
  822. real alpha, angle;
  823. integer ipack;
  824. real realc;
  825. integer ioffg;
  826. extern logical lsame_(char *, char *);
  827. integer iinfo;
  828. extern /* Subroutine */ void sscal_(integer *, real *, real *, integer *);
  829. complex ctemp;
  830. integer idist, mnmin, iskew;
  831. complex extra, dummy;
  832. extern /* Subroutine */ void slatm1_(integer *, real *, integer *, integer
  833. *, integer *, real *, integer *, integer *);
  834. integer ic, jc, nc;
  835. extern /* Subroutine */ void clagge_(integer *, integer *, integer *,
  836. integer *, real *, complex *, integer *, integer *, complex *,
  837. integer *), claghe_(integer *, integer *, real *, complex *,
  838. integer *, integer *, complex *, integer *);
  839. integer il;
  840. complex ct;
  841. integer iendch, ir, jr, ipackg, mr;
  842. //extern /* Complex */ VOID clarnd_(complex *, integer *, integer *);
  843. extern complex clarnd_(integer *, integer *);
  844. integer minlda;
  845. complex st;
  846. extern /* Subroutine */ void claset_(char *, integer *, integer *, complex
  847. *, complex *, complex *, integer *), clartg_(complex *,
  848. complex *, real *, complex *, complex *);
  849. extern int xerbla_(char *, integer *, ftnlen);
  850. extern void clagsy_(integer *, integer *, real *, complex *,
  851. integer *, integer *, complex *, integer *);
  852. extern real slarnd_(integer *, integer *);
  853. extern /* Subroutine */ void clarot_(logical *, logical *, logical *,
  854. integer *, complex *, complex *, complex *, integer *, complex *,
  855. complex *);
  856. logical iltemp, givens;
  857. integer ioffst, irsign;
  858. logical ilextr, topdwn;
  859. integer ir1, ir2, isympk, jch, llb, jkl, jku, uub;
  860. /* -- LAPACK computational routine (version 3.7.0) -- */
  861. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  862. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  863. /* December 2016 */
  864. /* ===================================================================== */
  865. /* 1) Decode and Test the input parameters. */
  866. /* Initialize flags & seed. */
  867. /* Parameter adjustments */
  868. --iseed;
  869. --d__;
  870. a_dim1 = *lda;
  871. a_offset = 1 + a_dim1 * 1;
  872. a -= a_offset;
  873. --work;
  874. /* Function Body */
  875. *info = 0;
  876. /* Quick return if possible */
  877. if (*m == 0 || *n == 0) {
  878. return;
  879. }
  880. /* Decode DIST */
  881. if (lsame_(dist, "U")) {
  882. idist = 1;
  883. } else if (lsame_(dist, "S")) {
  884. idist = 2;
  885. } else if (lsame_(dist, "N")) {
  886. idist = 3;
  887. } else {
  888. idist = -1;
  889. }
  890. /* Decode SYM */
  891. if (lsame_(sym, "N")) {
  892. isym = 1;
  893. irsign = 0;
  894. csym = FALSE_;
  895. } else if (lsame_(sym, "P")) {
  896. isym = 2;
  897. irsign = 0;
  898. csym = FALSE_;
  899. } else if (lsame_(sym, "S")) {
  900. isym = 2;
  901. irsign = 0;
  902. csym = TRUE_;
  903. } else if (lsame_(sym, "H")) {
  904. isym = 2;
  905. irsign = 1;
  906. csym = FALSE_;
  907. } else {
  908. isym = -1;
  909. }
  910. /* Decode PACK */
  911. isympk = 0;
  912. if (lsame_(pack, "N")) {
  913. ipack = 0;
  914. } else if (lsame_(pack, "U")) {
  915. ipack = 1;
  916. isympk = 1;
  917. } else if (lsame_(pack, "L")) {
  918. ipack = 2;
  919. isympk = 1;
  920. } else if (lsame_(pack, "C")) {
  921. ipack = 3;
  922. isympk = 2;
  923. } else if (lsame_(pack, "R")) {
  924. ipack = 4;
  925. isympk = 3;
  926. } else if (lsame_(pack, "B")) {
  927. ipack = 5;
  928. isympk = 3;
  929. } else if (lsame_(pack, "Q")) {
  930. ipack = 6;
  931. isympk = 2;
  932. } else if (lsame_(pack, "Z")) {
  933. ipack = 7;
  934. } else {
  935. ipack = -1;
  936. }
  937. /* Set certain internal parameters */
  938. mnmin = f2cmin(*m,*n);
  939. /* Computing MIN */
  940. i__1 = *kl, i__2 = *m - 1;
  941. llb = f2cmin(i__1,i__2);
  942. /* Computing MIN */
  943. i__1 = *ku, i__2 = *n - 1;
  944. uub = f2cmin(i__1,i__2);
  945. /* Computing MIN */
  946. i__1 = *m, i__2 = *n + llb;
  947. mr = f2cmin(i__1,i__2);
  948. /* Computing MIN */
  949. i__1 = *n, i__2 = *m + uub;
  950. nc = f2cmin(i__1,i__2);
  951. if (ipack == 5 || ipack == 6) {
  952. minlda = uub + 1;
  953. } else if (ipack == 7) {
  954. minlda = llb + uub + 1;
  955. } else {
  956. minlda = *m;
  957. }
  958. /* Use Givens rotation method if bandwidth small enough, */
  959. /* or if LDA is too small to store the matrix unpacked. */
  960. givens = FALSE_;
  961. if (isym == 1) {
  962. /* Computing MAX */
  963. i__1 = 1, i__2 = mr + nc;
  964. if ((real) (llb + uub) < (real) f2cmax(i__1,i__2) * .3f) {
  965. givens = TRUE_;
  966. }
  967. } else {
  968. if (llb << 1 < *m) {
  969. givens = TRUE_;
  970. }
  971. }
  972. if (*lda < *m && *lda >= minlda) {
  973. givens = TRUE_;
  974. }
  975. /* Set INFO if an error */
  976. if (*m < 0) {
  977. *info = -1;
  978. } else if (*m != *n && isym != 1) {
  979. *info = -1;
  980. } else if (*n < 0) {
  981. *info = -2;
  982. } else if (idist == -1) {
  983. *info = -3;
  984. } else if (isym == -1) {
  985. *info = -5;
  986. } else if (abs(*mode) > 6) {
  987. *info = -7;
  988. } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.f) {
  989. *info = -8;
  990. } else if (*kl < 0) {
  991. *info = -10;
  992. } else if (*ku < 0 || isym != 1 && *kl != *ku) {
  993. *info = -11;
  994. } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
  995. == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
  996. != 0 && *m != *n) {
  997. *info = -12;
  998. } else if (*lda < f2cmax(1,minlda)) {
  999. *info = -14;
  1000. }
  1001. if (*info != 0) {
  1002. i__1 = -(*info);
  1003. xerbla_("CLATMS", &i__1, 6);
  1004. return;
  1005. }
  1006. /* Initialize random number generator */
  1007. for (i__ = 1; i__ <= 4; ++i__) {
  1008. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  1009. /* L10: */
  1010. }
  1011. if (iseed[4] % 2 != 1) {
  1012. ++iseed[4];
  1013. }
  1014. /* 2) Set up D if indicated. */
  1015. /* Compute D according to COND and MODE */
  1016. slatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, &iinfo);
  1017. if (iinfo != 0) {
  1018. *info = 1;
  1019. return;
  1020. }
  1021. /* Choose Top-Down if D is (apparently) increasing, */
  1022. /* Bottom-Up if D is (apparently) decreasing. */
  1023. if (abs(d__[1]) <= (r__1 = d__[mnmin], abs(r__1))) {
  1024. topdwn = TRUE_;
  1025. } else {
  1026. topdwn = FALSE_;
  1027. }
  1028. if (*mode != 0 && abs(*mode) != 6) {
  1029. /* Scale by DMAX */
  1030. temp = abs(d__[1]);
  1031. i__1 = mnmin;
  1032. for (i__ = 2; i__ <= i__1; ++i__) {
  1033. /* Computing MAX */
  1034. r__2 = temp, r__3 = (r__1 = d__[i__], abs(r__1));
  1035. temp = f2cmax(r__2,r__3);
  1036. /* L20: */
  1037. }
  1038. if (temp > 0.f) {
  1039. alpha = *dmax__ / temp;
  1040. } else {
  1041. *info = 2;
  1042. return;
  1043. }
  1044. sscal_(&mnmin, &alpha, &d__[1], &c__1);
  1045. }
  1046. claset_("Full", lda, n, &c_b1, &c_b1, &a[a_offset], lda);
  1047. /* 3) Generate Banded Matrix using Givens rotations. */
  1048. /* Also the special case of UUB=LLB=0 */
  1049. /* Compute Addressing constants to cover all */
  1050. /* storage formats. Whether GE, HE, SY, GB, HB, or SB, */
  1051. /* upper or lower triangle or both, */
  1052. /* the (i,j)-th element is in */
  1053. /* A( i - ISKEW*j + IOFFST, j ) */
  1054. if (ipack > 4) {
  1055. ilda = *lda - 1;
  1056. iskew = 1;
  1057. if (ipack > 5) {
  1058. ioffst = uub + 1;
  1059. } else {
  1060. ioffst = 1;
  1061. }
  1062. } else {
  1063. ilda = *lda;
  1064. iskew = 0;
  1065. ioffst = 0;
  1066. }
  1067. /* IPACKG is the format that the matrix is generated in. If this is */
  1068. /* different from IPACK, then the matrix must be repacked at the */
  1069. /* end. It also signals how to compute the norm, for scaling. */
  1070. ipackg = 0;
  1071. /* Diagonal Matrix -- We are done, unless it */
  1072. /* is to be stored HP/SP/PP/TP (PACK='R' or 'C') */
  1073. if (llb == 0 && uub == 0) {
  1074. i__1 = mnmin;
  1075. for (j = 1; j <= i__1; ++j) {
  1076. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  1077. i__3 = j;
  1078. q__1.r = d__[i__3], q__1.i = 0.f;
  1079. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1080. /* L30: */
  1081. }
  1082. if (ipack <= 2 || ipack >= 5) {
  1083. ipackg = ipack;
  1084. }
  1085. } else if (givens) {
  1086. /* Check whether to use Givens rotations, */
  1087. /* Householder transformations, or nothing. */
  1088. if (isym == 1) {
  1089. /* Non-symmetric -- A = U D V */
  1090. if (ipack > 4) {
  1091. ipackg = ipack;
  1092. } else {
  1093. ipackg = 0;
  1094. }
  1095. i__1 = mnmin;
  1096. for (j = 1; j <= i__1; ++j) {
  1097. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  1098. i__3 = j;
  1099. q__1.r = d__[i__3], q__1.i = 0.f;
  1100. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1101. /* L40: */
  1102. }
  1103. if (topdwn) {
  1104. jkl = 0;
  1105. i__1 = uub;
  1106. for (jku = 1; jku <= i__1; ++jku) {
  1107. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1108. /* Last row actually rotated is M */
  1109. /* Last column actually rotated is MIN( M+JKU, N ) */
  1110. /* Computing MIN */
  1111. i__3 = *m + jku;
  1112. i__2 = f2cmin(i__3,*n) + jkl - 1;
  1113. for (jr = 1; jr <= i__2; ++jr) {
  1114. extra.r = 0.f, extra.i = 0.f;
  1115. angle = slarnd_(&c__1, &iseed[1]) *
  1116. 6.2831853071795864769252867663f;
  1117. r__1 = cos(angle);
  1118. //clarnd_(&q__2, &c__5, &iseed[1]);
  1119. q__2=clarnd_(&c__5, &iseed[1]);
  1120. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1121. c__.r = q__1.r, c__.i = q__1.i;
  1122. r__1 = sin(angle);
  1123. //clarnd_(&q__2, &c__5, &iseed[1]);
  1124. q__2=clarnd_(&c__5, &iseed[1]);
  1125. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1126. s.r = q__1.r, s.i = q__1.i;
  1127. /* Computing MAX */
  1128. i__3 = 1, i__4 = jr - jkl;
  1129. icol = f2cmax(i__3,i__4);
  1130. if (jr < *m) {
  1131. /* Computing MIN */
  1132. i__3 = *n, i__4 = jr + jku;
  1133. il = f2cmin(i__3,i__4) + 1 - icol;
  1134. L__1 = jr > jkl;
  1135. clarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
  1136. a[jr - iskew * icol + ioffst + icol *
  1137. a_dim1], &ilda, &extra, &dummy);
  1138. }
  1139. /* Chase "EXTRA" back up */
  1140. ir = jr;
  1141. ic = icol;
  1142. i__3 = -jkl - jku;
  1143. for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
  1144. jch += i__3) {
  1145. if (ir < *m) {
  1146. clartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1147. + (ic + 1) * a_dim1], &extra, &realc,
  1148. &s, &dummy);
  1149. //clarnd_(&q__1, &c__5, &iseed[1]);
  1150. q__1=clarnd_(&c__5, &iseed[1]);
  1151. dummy.r = q__1.r, dummy.i = q__1.i;
  1152. q__2.r = realc * dummy.r, q__2.i = realc *
  1153. dummy.i;
  1154. r_cnjg(&q__1, &q__2);
  1155. c__.r = q__1.r, c__.i = q__1.i;
  1156. q__3.r = -s.r, q__3.i = -s.i;
  1157. q__2.r = q__3.r * dummy.r - q__3.i * dummy.i,
  1158. q__2.i = q__3.r * dummy.i + q__3.i *
  1159. dummy.r;
  1160. r_cnjg(&q__1, &q__2);
  1161. s.r = q__1.r, s.i = q__1.i;
  1162. }
  1163. /* Computing MAX */
  1164. i__4 = 1, i__5 = jch - jku;
  1165. irow = f2cmax(i__4,i__5);
  1166. il = ir + 2 - irow;
  1167. ctemp.r = 0.f, ctemp.i = 0.f;
  1168. iltemp = jch > jku;
  1169. clarot_(&c_false, &iltemp, &c_true, &il, &c__, &s,
  1170. &a[irow - iskew * ic + ioffst + ic *
  1171. a_dim1], &ilda, &ctemp, &extra);
  1172. if (iltemp) {
  1173. clartg_(&a[irow + 1 - iskew * (ic + 1) +
  1174. ioffst + (ic + 1) * a_dim1], &ctemp, &
  1175. realc, &s, &dummy);
  1176. //clarnd_(&q__1, &c__5, &iseed[1]);
  1177. q__1=clarnd_(&c__5, &iseed[1]);
  1178. dummy.r = q__1.r, dummy.i = q__1.i;
  1179. q__2.r = realc * dummy.r, q__2.i = realc *
  1180. dummy.i;
  1181. r_cnjg(&q__1, &q__2);
  1182. c__.r = q__1.r, c__.i = q__1.i;
  1183. q__3.r = -s.r, q__3.i = -s.i;
  1184. q__2.r = q__3.r * dummy.r - q__3.i * dummy.i,
  1185. q__2.i = q__3.r * dummy.i + q__3.i *
  1186. dummy.r;
  1187. r_cnjg(&q__1, &q__2);
  1188. s.r = q__1.r, s.i = q__1.i;
  1189. /* Computing MAX */
  1190. i__4 = 1, i__5 = jch - jku - jkl;
  1191. icol = f2cmax(i__4,i__5);
  1192. il = ic + 2 - icol;
  1193. extra.r = 0.f, extra.i = 0.f;
  1194. L__1 = jch > jku + jkl;
  1195. clarot_(&c_true, &L__1, &c_true, &il, &c__, &
  1196. s, &a[irow - iskew * icol + ioffst +
  1197. icol * a_dim1], &ilda, &extra, &ctemp)
  1198. ;
  1199. ic = icol;
  1200. ir = irow;
  1201. }
  1202. /* L50: */
  1203. }
  1204. /* L60: */
  1205. }
  1206. /* L70: */
  1207. }
  1208. jku = uub;
  1209. i__1 = llb;
  1210. for (jkl = 1; jkl <= i__1; ++jkl) {
  1211. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1212. /* Computing MIN */
  1213. i__3 = *n + jkl;
  1214. i__2 = f2cmin(i__3,*m) + jku - 1;
  1215. for (jc = 1; jc <= i__2; ++jc) {
  1216. extra.r = 0.f, extra.i = 0.f;
  1217. angle = slarnd_(&c__1, &iseed[1]) *
  1218. 6.2831853071795864769252867663f;
  1219. r__1 = cos(angle);
  1220. //clarnd_(&q__2, &c__5, &iseed[1]);
  1221. q__2=clarnd_(&c__5, &iseed[1]);
  1222. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1223. c__.r = q__1.r, c__.i = q__1.i;
  1224. r__1 = sin(angle);
  1225. //clarnd_(&q__2, &c__5, &iseed[1]);
  1226. q__2=clarnd_(&c__5, &iseed[1]);
  1227. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1228. s.r = q__1.r, s.i = q__1.i;
  1229. /* Computing MAX */
  1230. i__3 = 1, i__4 = jc - jku;
  1231. irow = f2cmax(i__3,i__4);
  1232. if (jc < *n) {
  1233. /* Computing MIN */
  1234. i__3 = *m, i__4 = jc + jkl;
  1235. il = f2cmin(i__3,i__4) + 1 - irow;
  1236. L__1 = jc > jku;
  1237. clarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
  1238. &a[irow - iskew * jc + ioffst + jc *
  1239. a_dim1], &ilda, &extra, &dummy);
  1240. }
  1241. /* Chase "EXTRA" back up */
  1242. ic = jc;
  1243. ir = irow;
  1244. i__3 = -jkl - jku;
  1245. for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
  1246. jch += i__3) {
  1247. if (ic < *n) {
  1248. clartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1249. + (ic + 1) * a_dim1], &extra, &realc,
  1250. &s, &dummy);
  1251. //clarnd_(&q__1, &c__5, &iseed[1]);
  1252. q__1=clarnd_(&c__5, &iseed[1]);
  1253. dummy.r = q__1.r, dummy.i = q__1.i;
  1254. q__2.r = realc * dummy.r, q__2.i = realc *
  1255. dummy.i;
  1256. r_cnjg(&q__1, &q__2);
  1257. c__.r = q__1.r, c__.i = q__1.i;
  1258. q__3.r = -s.r, q__3.i = -s.i;
  1259. q__2.r = q__3.r * dummy.r - q__3.i * dummy.i,
  1260. q__2.i = q__3.r * dummy.i + q__3.i *
  1261. dummy.r;
  1262. r_cnjg(&q__1, &q__2);
  1263. s.r = q__1.r, s.i = q__1.i;
  1264. }
  1265. /* Computing MAX */
  1266. i__4 = 1, i__5 = jch - jkl;
  1267. icol = f2cmax(i__4,i__5);
  1268. il = ic + 2 - icol;
  1269. ctemp.r = 0.f, ctemp.i = 0.f;
  1270. iltemp = jch > jkl;
  1271. clarot_(&c_true, &iltemp, &c_true, &il, &c__, &s,
  1272. &a[ir - iskew * icol + ioffst + icol *
  1273. a_dim1], &ilda, &ctemp, &extra);
  1274. if (iltemp) {
  1275. clartg_(&a[ir + 1 - iskew * (icol + 1) +
  1276. ioffst + (icol + 1) * a_dim1], &ctemp,
  1277. &realc, &s, &dummy);
  1278. //clarnd_(&q__1, &c__5, &iseed[1]);
  1279. q__1=clarnd_(&c__5, &iseed[1]);
  1280. dummy.r = q__1.r, dummy.i = q__1.i;
  1281. q__2.r = realc * dummy.r, q__2.i = realc *
  1282. dummy.i;
  1283. r_cnjg(&q__1, &q__2);
  1284. c__.r = q__1.r, c__.i = q__1.i;
  1285. q__3.r = -s.r, q__3.i = -s.i;
  1286. q__2.r = q__3.r * dummy.r - q__3.i * dummy.i,
  1287. q__2.i = q__3.r * dummy.i + q__3.i *
  1288. dummy.r;
  1289. r_cnjg(&q__1, &q__2);
  1290. s.r = q__1.r, s.i = q__1.i;
  1291. /* Computing MAX */
  1292. i__4 = 1, i__5 = jch - jkl - jku;
  1293. irow = f2cmax(i__4,i__5);
  1294. il = ir + 2 - irow;
  1295. extra.r = 0.f, extra.i = 0.f;
  1296. L__1 = jch > jkl + jku;
  1297. clarot_(&c_false, &L__1, &c_true, &il, &c__, &
  1298. s, &a[irow - iskew * icol + ioffst +
  1299. icol * a_dim1], &ilda, &extra, &ctemp)
  1300. ;
  1301. ic = icol;
  1302. ir = irow;
  1303. }
  1304. /* L80: */
  1305. }
  1306. /* L90: */
  1307. }
  1308. /* L100: */
  1309. }
  1310. } else {
  1311. /* Bottom-Up -- Start at the bottom right. */
  1312. jkl = 0;
  1313. i__1 = uub;
  1314. for (jku = 1; jku <= i__1; ++jku) {
  1315. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1316. /* First row actually rotated is M */
  1317. /* First column actually rotated is MIN( M+JKU, N ) */
  1318. /* Computing MIN */
  1319. i__2 = *m, i__3 = *n + jkl;
  1320. iendch = f2cmin(i__2,i__3) - 1;
  1321. /* Computing MIN */
  1322. i__2 = *m + jku;
  1323. i__3 = 1 - jkl;
  1324. for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
  1325. extra.r = 0.f, extra.i = 0.f;
  1326. angle = slarnd_(&c__1, &iseed[1]) *
  1327. 6.2831853071795864769252867663f;
  1328. r__1 = cos(angle);
  1329. //clarnd_(&q__2, &c__5, &iseed[1]);
  1330. q__2=clarnd_(&c__5, &iseed[1]);
  1331. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1332. c__.r = q__1.r, c__.i = q__1.i;
  1333. r__1 = sin(angle);
  1334. //clarnd_(&q__2, &c__5, &iseed[1]);
  1335. q__2=clarnd_(&c__5, &iseed[1]);
  1336. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1337. s.r = q__1.r, s.i = q__1.i;
  1338. /* Computing MAX */
  1339. i__2 = 1, i__4 = jc - jku + 1;
  1340. irow = f2cmax(i__2,i__4);
  1341. if (jc > 0) {
  1342. /* Computing MIN */
  1343. i__2 = *m, i__4 = jc + jkl + 1;
  1344. il = f2cmin(i__2,i__4) + 1 - irow;
  1345. L__1 = jc + jkl < *m;
  1346. clarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
  1347. &a[irow - iskew * jc + ioffst + jc *
  1348. a_dim1], &ilda, &dummy, &extra);
  1349. }
  1350. /* Chase "EXTRA" back down */
  1351. ic = jc;
  1352. i__2 = iendch;
  1353. i__4 = jkl + jku;
  1354. for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
  1355. i__2; jch += i__4) {
  1356. ilextr = ic > 0;
  1357. if (ilextr) {
  1358. clartg_(&a[jch - iskew * ic + ioffst + ic *
  1359. a_dim1], &extra, &realc, &s, &dummy);
  1360. //clarnd_(&q__1, &c__5, &iseed[1]);
  1361. q__1=clarnd_(&c__5, &iseed[1]);
  1362. dummy.r = q__1.r, dummy.i = q__1.i;
  1363. q__1.r = realc * dummy.r, q__1.i = realc *
  1364. dummy.i;
  1365. c__.r = q__1.r, c__.i = q__1.i;
  1366. q__1.r = s.r * dummy.r - s.i * dummy.i,
  1367. q__1.i = s.r * dummy.i + s.i *
  1368. dummy.r;
  1369. s.r = q__1.r, s.i = q__1.i;
  1370. }
  1371. ic = f2cmax(1,ic);
  1372. /* Computing MIN */
  1373. i__5 = *n - 1, i__6 = jch + jku;
  1374. icol = f2cmin(i__5,i__6);
  1375. iltemp = jch + jku < *n;
  1376. ctemp.r = 0.f, ctemp.i = 0.f;
  1377. i__5 = icol + 2 - ic;
  1378. clarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
  1379. s, &a[jch - iskew * ic + ioffst + ic *
  1380. a_dim1], &ilda, &extra, &ctemp);
  1381. if (iltemp) {
  1382. clartg_(&a[jch - iskew * icol + ioffst + icol
  1383. * a_dim1], &ctemp, &realc, &s, &dummy)
  1384. ;
  1385. //clarnd_(&q__1, &c__5, &iseed[1]);
  1386. q__1=clarnd_(&c__5, &iseed[1]);
  1387. dummy.r = q__1.r, dummy.i = q__1.i;
  1388. q__1.r = realc * dummy.r, q__1.i = realc *
  1389. dummy.i;
  1390. c__.r = q__1.r, c__.i = q__1.i;
  1391. q__1.r = s.r * dummy.r - s.i * dummy.i,
  1392. q__1.i = s.r * dummy.i + s.i *
  1393. dummy.r;
  1394. s.r = q__1.r, s.i = q__1.i;
  1395. /* Computing MIN */
  1396. i__5 = iendch, i__6 = jch + jkl + jku;
  1397. il = f2cmin(i__5,i__6) + 2 - jch;
  1398. extra.r = 0.f, extra.i = 0.f;
  1399. L__1 = jch + jkl + jku <= iendch;
  1400. clarot_(&c_false, &c_true, &L__1, &il, &c__, &
  1401. s, &a[jch - iskew * icol + ioffst +
  1402. icol * a_dim1], &ilda, &ctemp, &extra)
  1403. ;
  1404. ic = icol;
  1405. }
  1406. /* L110: */
  1407. }
  1408. /* L120: */
  1409. }
  1410. /* L130: */
  1411. }
  1412. jku = uub;
  1413. i__1 = llb;
  1414. for (jkl = 1; jkl <= i__1; ++jkl) {
  1415. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1416. /* First row actually rotated is MIN( N+JKL, M ) */
  1417. /* First column actually rotated is N */
  1418. /* Computing MIN */
  1419. i__3 = *n, i__4 = *m + jku;
  1420. iendch = f2cmin(i__3,i__4) - 1;
  1421. /* Computing MIN */
  1422. i__3 = *n + jkl;
  1423. i__4 = 1 - jku;
  1424. for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
  1425. extra.r = 0.f, extra.i = 0.f;
  1426. angle = slarnd_(&c__1, &iseed[1]) *
  1427. 6.2831853071795864769252867663f;
  1428. r__1 = cos(angle);
  1429. //clarnd_(&q__2, &c__5, &iseed[1]);
  1430. q__2=clarnd_(&c__5, &iseed[1]);
  1431. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1432. c__.r = q__1.r, c__.i = q__1.i;
  1433. r__1 = sin(angle);
  1434. //clarnd_(&q__2, &c__5, &iseed[1]);
  1435. q__2=clarnd_(&c__5, &iseed[1]);
  1436. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1437. s.r = q__1.r, s.i = q__1.i;
  1438. /* Computing MAX */
  1439. i__3 = 1, i__2 = jr - jkl + 1;
  1440. icol = f2cmax(i__3,i__2);
  1441. if (jr > 0) {
  1442. /* Computing MIN */
  1443. i__3 = *n, i__2 = jr + jku + 1;
  1444. il = f2cmin(i__3,i__2) + 1 - icol;
  1445. L__1 = jr + jku < *n;
  1446. clarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
  1447. a[jr - iskew * icol + ioffst + icol *
  1448. a_dim1], &ilda, &dummy, &extra);
  1449. }
  1450. /* Chase "EXTRA" back down */
  1451. ir = jr;
  1452. i__3 = iendch;
  1453. i__2 = jkl + jku;
  1454. for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
  1455. i__3; jch += i__2) {
  1456. ilextr = ir > 0;
  1457. if (ilextr) {
  1458. clartg_(&a[ir - iskew * jch + ioffst + jch *
  1459. a_dim1], &extra, &realc, &s, &dummy);
  1460. //clarnd_(&q__1, &c__5, &iseed[1]);
  1461. q__1=clarnd_(&c__5, &iseed[1]);
  1462. dummy.r = q__1.r, dummy.i = q__1.i;
  1463. q__1.r = realc * dummy.r, q__1.i = realc *
  1464. dummy.i;
  1465. c__.r = q__1.r, c__.i = q__1.i;
  1466. q__1.r = s.r * dummy.r - s.i * dummy.i,
  1467. q__1.i = s.r * dummy.i + s.i *
  1468. dummy.r;
  1469. s.r = q__1.r, s.i = q__1.i;
  1470. }
  1471. ir = f2cmax(1,ir);
  1472. /* Computing MIN */
  1473. i__5 = *m - 1, i__6 = jch + jkl;
  1474. irow = f2cmin(i__5,i__6);
  1475. iltemp = jch + jkl < *m;
  1476. ctemp.r = 0.f, ctemp.i = 0.f;
  1477. i__5 = irow + 2 - ir;
  1478. clarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
  1479. s, &a[ir - iskew * jch + ioffst + jch *
  1480. a_dim1], &ilda, &extra, &ctemp);
  1481. if (iltemp) {
  1482. clartg_(&a[irow - iskew * jch + ioffst + jch *
  1483. a_dim1], &ctemp, &realc, &s, &dummy);
  1484. //clarnd_(&q__1, &c__5, &iseed[1]);
  1485. q__1=clarnd_(&c__5, &iseed[1]);
  1486. dummy.r = q__1.r, dummy.i = q__1.i;
  1487. q__1.r = realc * dummy.r, q__1.i = realc *
  1488. dummy.i;
  1489. c__.r = q__1.r, c__.i = q__1.i;
  1490. q__1.r = s.r * dummy.r - s.i * dummy.i,
  1491. q__1.i = s.r * dummy.i + s.i *
  1492. dummy.r;
  1493. s.r = q__1.r, s.i = q__1.i;
  1494. /* Computing MIN */
  1495. i__5 = iendch, i__6 = jch + jkl + jku;
  1496. il = f2cmin(i__5,i__6) + 2 - jch;
  1497. extra.r = 0.f, extra.i = 0.f;
  1498. L__1 = jch + jkl + jku <= iendch;
  1499. clarot_(&c_true, &c_true, &L__1, &il, &c__, &
  1500. s, &a[irow - iskew * jch + ioffst +
  1501. jch * a_dim1], &ilda, &ctemp, &extra);
  1502. ir = irow;
  1503. }
  1504. /* L140: */
  1505. }
  1506. /* L150: */
  1507. }
  1508. /* L160: */
  1509. }
  1510. }
  1511. } else {
  1512. /* Symmetric -- A = U D U' */
  1513. /* Hermitian -- A = U D U* */
  1514. ipackg = ipack;
  1515. ioffg = ioffst;
  1516. if (topdwn) {
  1517. /* Top-Down -- Generate Upper triangle only */
  1518. if (ipack >= 5) {
  1519. ipackg = 6;
  1520. ioffg = uub + 1;
  1521. } else {
  1522. ipackg = 1;
  1523. }
  1524. i__1 = mnmin;
  1525. for (j = 1; j <= i__1; ++j) {
  1526. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1527. i__2 = j;
  1528. q__1.r = d__[i__2], q__1.i = 0.f;
  1529. a[i__4].r = q__1.r, a[i__4].i = q__1.i;
  1530. /* L170: */
  1531. }
  1532. i__1 = uub;
  1533. for (k = 1; k <= i__1; ++k) {
  1534. i__4 = *n - 1;
  1535. for (jc = 1; jc <= i__4; ++jc) {
  1536. /* Computing MAX */
  1537. i__2 = 1, i__3 = jc - k;
  1538. irow = f2cmax(i__2,i__3);
  1539. /* Computing MIN */
  1540. i__2 = jc + 1, i__3 = k + 2;
  1541. il = f2cmin(i__2,i__3);
  1542. extra.r = 0.f, extra.i = 0.f;
  1543. i__2 = jc - iskew * (jc + 1) + ioffg + (jc + 1) *
  1544. a_dim1;
  1545. ctemp.r = a[i__2].r, ctemp.i = a[i__2].i;
  1546. angle = slarnd_(&c__1, &iseed[1]) *
  1547. 6.2831853071795864769252867663f;
  1548. r__1 = cos(angle);
  1549. //clarnd_(&q__2, &c__5, &iseed[1]);
  1550. q__2=clarnd_(&c__5, &iseed[1]);
  1551. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1552. c__.r = q__1.r, c__.i = q__1.i;
  1553. r__1 = sin(angle);
  1554. //clarnd_(&q__2, &c__5, &iseed[1]);
  1555. q__2=clarnd_(&c__5, &iseed[1]);
  1556. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1557. s.r = q__1.r, s.i = q__1.i;
  1558. if (csym) {
  1559. ct.r = c__.r, ct.i = c__.i;
  1560. st.r = s.r, st.i = s.i;
  1561. } else {
  1562. r_cnjg(&q__1, &ctemp);
  1563. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1564. r_cnjg(&q__1, &c__);
  1565. ct.r = q__1.r, ct.i = q__1.i;
  1566. r_cnjg(&q__1, &s);
  1567. st.r = q__1.r, st.i = q__1.i;
  1568. }
  1569. L__1 = jc > k;
  1570. clarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
  1571. irow - iskew * jc + ioffg + jc * a_dim1], &
  1572. ilda, &extra, &ctemp);
  1573. /* Computing MIN */
  1574. i__3 = k, i__5 = *n - jc;
  1575. i__2 = f2cmin(i__3,i__5) + 1;
  1576. clarot_(&c_true, &c_true, &c_false, &i__2, &ct, &st, &
  1577. a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
  1578. ilda, &ctemp, &dummy);
  1579. /* Chase EXTRA back up the matrix */
  1580. icol = jc;
  1581. i__2 = -k;
  1582. for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
  1583. jch += i__2) {
  1584. clartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
  1585. (icol + 1) * a_dim1], &extra, &realc, &s,
  1586. &dummy);
  1587. //clarnd_(&q__1, &c__5, &iseed[1]);
  1588. q__1=clarnd_(&c__5, &iseed[1]);
  1589. dummy.r = q__1.r, dummy.i = q__1.i;
  1590. q__2.r = realc * dummy.r, q__2.i = realc *
  1591. dummy.i;
  1592. r_cnjg(&q__1, &q__2);
  1593. c__.r = q__1.r, c__.i = q__1.i;
  1594. q__3.r = -s.r, q__3.i = -s.i;
  1595. q__2.r = q__3.r * dummy.r - q__3.i * dummy.i,
  1596. q__2.i = q__3.r * dummy.i + q__3.i *
  1597. dummy.r;
  1598. r_cnjg(&q__1, &q__2);
  1599. s.r = q__1.r, s.i = q__1.i;
  1600. i__3 = jch - iskew * (jch + 1) + ioffg + (jch + 1)
  1601. * a_dim1;
  1602. ctemp.r = a[i__3].r, ctemp.i = a[i__3].i;
  1603. if (csym) {
  1604. ct.r = c__.r, ct.i = c__.i;
  1605. st.r = s.r, st.i = s.i;
  1606. } else {
  1607. r_cnjg(&q__1, &ctemp);
  1608. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1609. r_cnjg(&q__1, &c__);
  1610. ct.r = q__1.r, ct.i = q__1.i;
  1611. r_cnjg(&q__1, &s);
  1612. st.r = q__1.r, st.i = q__1.i;
  1613. }
  1614. i__3 = k + 2;
  1615. clarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1616. s, &a[(1 - iskew) * jch + ioffg + jch *
  1617. a_dim1], &ilda, &ctemp, &extra);
  1618. /* Computing MAX */
  1619. i__3 = 1, i__5 = jch - k;
  1620. irow = f2cmax(i__3,i__5);
  1621. /* Computing MIN */
  1622. i__3 = jch + 1, i__5 = k + 2;
  1623. il = f2cmin(i__3,i__5);
  1624. extra.r = 0.f, extra.i = 0.f;
  1625. L__1 = jch > k;
  1626. clarot_(&c_false, &L__1, &c_true, &il, &ct, &st, &
  1627. a[irow - iskew * jch + ioffg + jch *
  1628. a_dim1], &ilda, &extra, &ctemp);
  1629. icol = jch;
  1630. /* L180: */
  1631. }
  1632. /* L190: */
  1633. }
  1634. /* L200: */
  1635. }
  1636. /* If we need lower triangle, copy from upper. Note that */
  1637. /* the order of copying is chosen to work for 'q' -> 'b' */
  1638. if (ipack != ipackg && ipack != 3) {
  1639. i__1 = *n;
  1640. for (jc = 1; jc <= i__1; ++jc) {
  1641. irow = ioffst - iskew * jc;
  1642. if (csym) {
  1643. /* Computing MIN */
  1644. i__2 = *n, i__3 = jc + uub;
  1645. i__4 = f2cmin(i__2,i__3);
  1646. for (jr = jc; jr <= i__4; ++jr) {
  1647. i__2 = jr + irow + jc * a_dim1;
  1648. i__3 = jc - iskew * jr + ioffg + jr * a_dim1;
  1649. a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
  1650. /* L210: */
  1651. }
  1652. } else {
  1653. /* Computing MIN */
  1654. i__2 = *n, i__3 = jc + uub;
  1655. i__4 = f2cmin(i__2,i__3);
  1656. for (jr = jc; jr <= i__4; ++jr) {
  1657. i__2 = jr + irow + jc * a_dim1;
  1658. r_cnjg(&q__1, &a[jc - iskew * jr + ioffg + jr
  1659. * a_dim1]);
  1660. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1661. /* L220: */
  1662. }
  1663. }
  1664. /* L230: */
  1665. }
  1666. if (ipack == 5) {
  1667. i__1 = *n;
  1668. for (jc = *n - uub + 1; jc <= i__1; ++jc) {
  1669. i__4 = uub + 1;
  1670. for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
  1671. i__2 = jr + jc * a_dim1;
  1672. a[i__2].r = 0.f, a[i__2].i = 0.f;
  1673. /* L240: */
  1674. }
  1675. /* L250: */
  1676. }
  1677. }
  1678. if (ipackg == 6) {
  1679. ipackg = ipack;
  1680. } else {
  1681. ipackg = 0;
  1682. }
  1683. }
  1684. } else {
  1685. /* Bottom-Up -- Generate Lower triangle only */
  1686. if (ipack >= 5) {
  1687. ipackg = 5;
  1688. if (ipack == 6) {
  1689. ioffg = 1;
  1690. }
  1691. } else {
  1692. ipackg = 2;
  1693. }
  1694. i__1 = mnmin;
  1695. for (j = 1; j <= i__1; ++j) {
  1696. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1697. i__2 = j;
  1698. q__1.r = d__[i__2], q__1.i = 0.f;
  1699. a[i__4].r = q__1.r, a[i__4].i = q__1.i;
  1700. /* L260: */
  1701. }
  1702. i__1 = uub;
  1703. for (k = 1; k <= i__1; ++k) {
  1704. for (jc = *n - 1; jc >= 1; --jc) {
  1705. /* Computing MIN */
  1706. i__4 = *n + 1 - jc, i__2 = k + 2;
  1707. il = f2cmin(i__4,i__2);
  1708. extra.r = 0.f, extra.i = 0.f;
  1709. i__4 = (1 - iskew) * jc + 1 + ioffg + jc * a_dim1;
  1710. ctemp.r = a[i__4].r, ctemp.i = a[i__4].i;
  1711. angle = slarnd_(&c__1, &iseed[1]) *
  1712. 6.2831853071795864769252867663f;
  1713. r__1 = cos(angle);
  1714. //clarnd_(&q__2, &c__5, &iseed[1]);
  1715. q__2=clarnd_(&c__5, &iseed[1]);
  1716. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1717. c__.r = q__1.r, c__.i = q__1.i;
  1718. r__1 = sin(angle);
  1719. //clarnd_(&q__2, &c__5, &iseed[1]);
  1720. q__2=clarnd_(&c__5, &iseed[1]);
  1721. q__1.r = r__1 * q__2.r, q__1.i = r__1 * q__2.i;
  1722. s.r = q__1.r, s.i = q__1.i;
  1723. if (csym) {
  1724. ct.r = c__.r, ct.i = c__.i;
  1725. st.r = s.r, st.i = s.i;
  1726. } else {
  1727. r_cnjg(&q__1, &ctemp);
  1728. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1729. r_cnjg(&q__1, &c__);
  1730. ct.r = q__1.r, ct.i = q__1.i;
  1731. r_cnjg(&q__1, &s);
  1732. st.r = q__1.r, st.i = q__1.i;
  1733. }
  1734. L__1 = *n - jc > k;
  1735. clarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
  1736. 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
  1737. &ctemp, &extra);
  1738. /* Computing MAX */
  1739. i__4 = 1, i__2 = jc - k + 1;
  1740. icol = f2cmax(i__4,i__2);
  1741. i__4 = jc + 2 - icol;
  1742. clarot_(&c_true, &c_false, &c_true, &i__4, &ct, &st, &
  1743. a[jc - iskew * icol + ioffg + icol * a_dim1],
  1744. &ilda, &dummy, &ctemp);
  1745. /* Chase EXTRA back down the matrix */
  1746. icol = jc;
  1747. i__4 = *n - 1;
  1748. i__2 = k;
  1749. for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
  1750. i__4; jch += i__2) {
  1751. clartg_(&a[jch - iskew * icol + ioffg + icol *
  1752. a_dim1], &extra, &realc, &s, &dummy);
  1753. //clarnd_(&q__1, &c__5, &iseed[1]);
  1754. q__1=clarnd_(&c__5, &iseed[1]);
  1755. dummy.r = q__1.r, dummy.i = q__1.i;
  1756. q__1.r = realc * dummy.r, q__1.i = realc *
  1757. dummy.i;
  1758. c__.r = q__1.r, c__.i = q__1.i;
  1759. q__1.r = s.r * dummy.r - s.i * dummy.i, q__1.i =
  1760. s.r * dummy.i + s.i * dummy.r;
  1761. s.r = q__1.r, s.i = q__1.i;
  1762. i__3 = (1 - iskew) * jch + 1 + ioffg + jch *
  1763. a_dim1;
  1764. ctemp.r = a[i__3].r, ctemp.i = a[i__3].i;
  1765. if (csym) {
  1766. ct.r = c__.r, ct.i = c__.i;
  1767. st.r = s.r, st.i = s.i;
  1768. } else {
  1769. r_cnjg(&q__1, &ctemp);
  1770. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1771. r_cnjg(&q__1, &c__);
  1772. ct.r = q__1.r, ct.i = q__1.i;
  1773. r_cnjg(&q__1, &s);
  1774. st.r = q__1.r, st.i = q__1.i;
  1775. }
  1776. i__3 = k + 2;
  1777. clarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1778. s, &a[jch - iskew * icol + ioffg + icol *
  1779. a_dim1], &ilda, &extra, &ctemp);
  1780. /* Computing MIN */
  1781. i__3 = *n + 1 - jch, i__5 = k + 2;
  1782. il = f2cmin(i__3,i__5);
  1783. extra.r = 0.f, extra.i = 0.f;
  1784. L__1 = *n - jch > k;
  1785. clarot_(&c_false, &c_true, &L__1, &il, &ct, &st, &
  1786. a[(1 - iskew) * jch + ioffg + jch *
  1787. a_dim1], &ilda, &ctemp, &extra);
  1788. icol = jch;
  1789. /* L270: */
  1790. }
  1791. /* L280: */
  1792. }
  1793. /* L290: */
  1794. }
  1795. /* If we need upper triangle, copy from lower. Note that */
  1796. /* the order of copying is chosen to work for 'b' -> 'q' */
  1797. if (ipack != ipackg && ipack != 4) {
  1798. for (jc = *n; jc >= 1; --jc) {
  1799. irow = ioffst - iskew * jc;
  1800. if (csym) {
  1801. /* Computing MAX */
  1802. i__2 = 1, i__4 = jc - uub;
  1803. i__1 = f2cmax(i__2,i__4);
  1804. for (jr = jc; jr >= i__1; --jr) {
  1805. i__2 = jr + irow + jc * a_dim1;
  1806. i__4 = jc - iskew * jr + ioffg + jr * a_dim1;
  1807. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1808. /* L300: */
  1809. }
  1810. } else {
  1811. /* Computing MAX */
  1812. i__2 = 1, i__4 = jc - uub;
  1813. i__1 = f2cmax(i__2,i__4);
  1814. for (jr = jc; jr >= i__1; --jr) {
  1815. i__2 = jr + irow + jc * a_dim1;
  1816. r_cnjg(&q__1, &a[jc - iskew * jr + ioffg + jr
  1817. * a_dim1]);
  1818. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1819. /* L310: */
  1820. }
  1821. }
  1822. /* L320: */
  1823. }
  1824. if (ipack == 6) {
  1825. i__1 = uub;
  1826. for (jc = 1; jc <= i__1; ++jc) {
  1827. i__2 = uub + 1 - jc;
  1828. for (jr = 1; jr <= i__2; ++jr) {
  1829. i__4 = jr + jc * a_dim1;
  1830. a[i__4].r = 0.f, a[i__4].i = 0.f;
  1831. /* L330: */
  1832. }
  1833. /* L340: */
  1834. }
  1835. }
  1836. if (ipackg == 5) {
  1837. ipackg = ipack;
  1838. } else {
  1839. ipackg = 0;
  1840. }
  1841. }
  1842. }
  1843. /* Ensure that the diagonal is real if Hermitian */
  1844. if (! csym) {
  1845. i__1 = *n;
  1846. for (jc = 1; jc <= i__1; ++jc) {
  1847. irow = ioffst + (1 - iskew) * jc;
  1848. i__2 = irow + jc * a_dim1;
  1849. i__4 = irow + jc * a_dim1;
  1850. r__1 = a[i__4].r;
  1851. q__1.r = r__1, q__1.i = 0.f;
  1852. a[i__2].r = q__1.r, a[i__2].i = q__1.i;
  1853. /* L350: */
  1854. }
  1855. }
  1856. }
  1857. } else {
  1858. /* 4) Generate Banded Matrix by first */
  1859. /* Rotating by random Unitary matrices, */
  1860. /* then reducing the bandwidth using Householder */
  1861. /* transformations. */
  1862. /* Note: we should get here only if LDA .ge. N */
  1863. if (isym == 1) {
  1864. /* Non-symmetric -- A = U D V */
  1865. clagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
  1866. 1], &work[1], &iinfo);
  1867. } else {
  1868. /* Symmetric -- A = U D U' or */
  1869. /* Hermitian -- A = U D U* */
  1870. if (csym) {
  1871. clagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1872. 1], &iinfo);
  1873. } else {
  1874. claghe_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1875. 1], &iinfo);
  1876. }
  1877. }
  1878. if (iinfo != 0) {
  1879. *info = 3;
  1880. return;
  1881. }
  1882. }
  1883. /* 5) Pack the matrix */
  1884. if (ipack != ipackg) {
  1885. if (ipack == 1) {
  1886. /* 'U' -- Upper triangular, not packed */
  1887. i__1 = *m;
  1888. for (j = 1; j <= i__1; ++j) {
  1889. i__2 = *m;
  1890. for (i__ = j + 1; i__ <= i__2; ++i__) {
  1891. i__4 = i__ + j * a_dim1;
  1892. a[i__4].r = 0.f, a[i__4].i = 0.f;
  1893. /* L360: */
  1894. }
  1895. /* L370: */
  1896. }
  1897. } else if (ipack == 2) {
  1898. /* 'L' -- Lower triangular, not packed */
  1899. i__1 = *m;
  1900. for (j = 2; j <= i__1; ++j) {
  1901. i__2 = j - 1;
  1902. for (i__ = 1; i__ <= i__2; ++i__) {
  1903. i__4 = i__ + j * a_dim1;
  1904. a[i__4].r = 0.f, a[i__4].i = 0.f;
  1905. /* L380: */
  1906. }
  1907. /* L390: */
  1908. }
  1909. } else if (ipack == 3) {
  1910. /* 'C' -- Upper triangle packed Columnwise. */
  1911. icol = 1;
  1912. irow = 0;
  1913. i__1 = *m;
  1914. for (j = 1; j <= i__1; ++j) {
  1915. i__2 = j;
  1916. for (i__ = 1; i__ <= i__2; ++i__) {
  1917. ++irow;
  1918. if (irow > *lda) {
  1919. irow = 1;
  1920. ++icol;
  1921. }
  1922. i__4 = irow + icol * a_dim1;
  1923. i__3 = i__ + j * a_dim1;
  1924. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1925. /* L400: */
  1926. }
  1927. /* L410: */
  1928. }
  1929. } else if (ipack == 4) {
  1930. /* 'R' -- Lower triangle packed Columnwise. */
  1931. icol = 1;
  1932. irow = 0;
  1933. i__1 = *m;
  1934. for (j = 1; j <= i__1; ++j) {
  1935. i__2 = *m;
  1936. for (i__ = j; i__ <= i__2; ++i__) {
  1937. ++irow;
  1938. if (irow > *lda) {
  1939. irow = 1;
  1940. ++icol;
  1941. }
  1942. i__4 = irow + icol * a_dim1;
  1943. i__3 = i__ + j * a_dim1;
  1944. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1945. /* L420: */
  1946. }
  1947. /* L430: */
  1948. }
  1949. } else if (ipack >= 5) {
  1950. /* 'B' -- The lower triangle is packed as a band matrix. */
  1951. /* 'Q' -- The upper triangle is packed as a band matrix. */
  1952. /* 'Z' -- The whole matrix is packed as a band matrix. */
  1953. if (ipack == 5) {
  1954. uub = 0;
  1955. }
  1956. if (ipack == 6) {
  1957. llb = 0;
  1958. }
  1959. i__1 = uub;
  1960. for (j = 1; j <= i__1; ++j) {
  1961. /* Computing MIN */
  1962. i__2 = j + llb;
  1963. for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
  1964. i__2 = i__ - j + uub + 1 + j * a_dim1;
  1965. i__4 = i__ + j * a_dim1;
  1966. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1967. /* L440: */
  1968. }
  1969. /* L450: */
  1970. }
  1971. i__1 = *n;
  1972. for (j = uub + 2; j <= i__1; ++j) {
  1973. /* Computing MIN */
  1974. i__4 = j + llb;
  1975. i__2 = f2cmin(i__4,*m);
  1976. for (i__ = j - uub; i__ <= i__2; ++i__) {
  1977. i__4 = i__ - j + uub + 1 + j * a_dim1;
  1978. i__3 = i__ + j * a_dim1;
  1979. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1980. /* L460: */
  1981. }
  1982. /* L470: */
  1983. }
  1984. }
  1985. /* If packed, zero out extraneous elements. */
  1986. /* Symmetric/Triangular Packed -- */
  1987. /* zero out everything after A(IROW,ICOL) */
  1988. if (ipack == 3 || ipack == 4) {
  1989. i__1 = *m;
  1990. for (jc = icol; jc <= i__1; ++jc) {
  1991. i__2 = *lda;
  1992. for (jr = irow + 1; jr <= i__2; ++jr) {
  1993. i__4 = jr + jc * a_dim1;
  1994. a[i__4].r = 0.f, a[i__4].i = 0.f;
  1995. /* L480: */
  1996. }
  1997. irow = 0;
  1998. /* L490: */
  1999. }
  2000. } else if (ipack >= 5) {
  2001. /* Packed Band -- */
  2002. /* 1st row is now in A( UUB+2-j, j), zero above it */
  2003. /* m-th row is now in A( M+UUB-j,j), zero below it */
  2004. /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
  2005. /* zero below it, too. */
  2006. ir1 = uub + llb + 2;
  2007. ir2 = uub + *m + 2;
  2008. i__1 = *n;
  2009. for (jc = 1; jc <= i__1; ++jc) {
  2010. i__2 = uub + 1 - jc;
  2011. for (jr = 1; jr <= i__2; ++jr) {
  2012. i__4 = jr + jc * a_dim1;
  2013. a[i__4].r = 0.f, a[i__4].i = 0.f;
  2014. /* L500: */
  2015. }
  2016. /* Computing MAX */
  2017. /* Computing MIN */
  2018. i__3 = ir1, i__5 = ir2 - jc;
  2019. i__2 = 1, i__4 = f2cmin(i__3,i__5);
  2020. i__6 = *lda;
  2021. for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
  2022. i__2 = jr + jc * a_dim1;
  2023. a[i__2].r = 0.f, a[i__2].i = 0.f;
  2024. /* L510: */
  2025. }
  2026. /* L520: */
  2027. }
  2028. }
  2029. }
  2030. return;
  2031. /* End of CLATMS */
  2032. } /* clatms_ */