You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

clatms.c 65 kB

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