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

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