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.

zlatms.c 59 kB

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