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.

clatmt.c 66 kB

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