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.

zlatmt.c 59 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981
  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 ZLATMT */
  247. /* =========== DOCUMENTATION =========== */
  248. /* Online html documentation available at */
  249. /* http://www.netlib.org/lapack/explore-html/ */
  250. /* Definition: */
  251. /* =========== */
  252. /* SUBROUTINE ZLATMT( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
  253. /* RANK, KL, KU, PACK, A, LDA, WORK, INFO ) */
  254. /* DOUBLE PRECISION COND, DMAX */
  255. /* INTEGER INFO, KL, KU, LDA, M, MODE, N, RANK */
  256. /* CHARACTER DIST, PACK, SYM */
  257. /* COMPLEX*16 A( LDA, * ), WORK( * ) */
  258. /* DOUBLE PRECISION D( * ) */
  259. /* INTEGER ISEED( 4 ) */
  260. /* > \par Purpose: */
  261. /* ============= */
  262. /* > */
  263. /* > \verbatim */
  264. /* > */
  265. /* > ZLATMT generates random matrices with specified singular values */
  266. /* > (or hermitian with specified eigenvalues) */
  267. /* > for testing LAPACK programs. */
  268. /* > */
  269. /* > ZLATMT 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 ZLATMT */
  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:RANK)=1.0/COND */
  397. /* > MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND */
  398. /* > MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-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] RANK */
  435. /* > \verbatim */
  436. /* > RANK is INTEGER */
  437. /* > The rank of matrix to be generated for modes 1,2,3 only. */
  438. /* > D( RANK+1:N ) = 0. */
  439. /* > Not modified. */
  440. /* > \endverbatim */
  441. /* > */
  442. /* > \param[in] KL */
  443. /* > \verbatim */
  444. /* > KL is INTEGER */
  445. /* > This specifies the lower bandwidth of the matrix. For */
  446. /* > example, KL=0 implies upper triangular, KL=1 implies upper */
  447. /* > Hessenberg, and KL being at least M-1 means that the matrix */
  448. /* > has full lower bandwidth. KL must equal KU if the matrix */
  449. /* > is symmetric or hermitian. */
  450. /* > Not modified. */
  451. /* > \endverbatim */
  452. /* > */
  453. /* > \param[in] KU */
  454. /* > \verbatim */
  455. /* > KU is INTEGER */
  456. /* > This specifies the upper bandwidth of the matrix. For */
  457. /* > example, KU=0 implies lower triangular, KU=1 implies lower */
  458. /* > Hessenberg, and KU being at least N-1 means that the matrix */
  459. /* > has full upper bandwidth. KL must equal KU if the matrix */
  460. /* > is symmetric or hermitian. */
  461. /* > Not modified. */
  462. /* > \endverbatim */
  463. /* > */
  464. /* > \param[in] PACK */
  465. /* > \verbatim */
  466. /* > PACK is CHARACTER*1 */
  467. /* > This specifies packing of matrix as follows: */
  468. /* > 'N' => no packing */
  469. /* > 'U' => zero out all subdiagonal entries (if symmetric */
  470. /* > or hermitian) */
  471. /* > 'L' => zero out all superdiagonal entries (if symmetric */
  472. /* > or hermitian) */
  473. /* > 'C' => store the upper triangle columnwise (only if the */
  474. /* > matrix is symmetric, hermitian, or upper triangular) */
  475. /* > 'R' => store the lower triangle columnwise (only if the */
  476. /* > matrix is symmetric, hermitian, or lower triangular) */
  477. /* > 'B' => store the lower triangle in band storage scheme */
  478. /* > (only if the matrix is symmetric, hermitian, or */
  479. /* > lower triangular) */
  480. /* > 'Q' => store the upper triangle in band storage scheme */
  481. /* > (only if the matrix is symmetric, hermitian, or */
  482. /* > upper triangular) */
  483. /* > 'Z' => store the entire matrix in band storage scheme */
  484. /* > (pivoting can be provided for by using this */
  485. /* > option to store A in the trailing rows of */
  486. /* > the allocated storage) */
  487. /* > */
  488. /* > Using these options, the various LAPACK packed and banded */
  489. /* > storage schemes can be obtained: */
  490. /* > GB - use 'Z' */
  491. /* > PB, SB, HB, or TB - use 'B' or 'Q' */
  492. /* > PP, SP, HB, or TP - use 'C' or 'R' */
  493. /* > */
  494. /* > If two calls to ZLATMT differ only in the PACK parameter, */
  495. /* > they will generate mathematically equivalent matrices. */
  496. /* > Not modified. */
  497. /* > \endverbatim */
  498. /* > */
  499. /* > \param[in,out] A */
  500. /* > \verbatim */
  501. /* > A is COMPLEX*16 array, dimension ( LDA, N ) */
  502. /* > On exit A is the desired test matrix. A is first generated */
  503. /* > in full (unpacked) form, and then packed, if so specified */
  504. /* > by PACK. Thus, the first M elements of the first N */
  505. /* > columns will always be modified. If PACK specifies a */
  506. /* > packed or banded storage scheme, all LDA elements of the */
  507. /* > first N columns will be modified; the elements of the */
  508. /* > array which do not correspond to elements of the generated */
  509. /* > matrix are set to zero. */
  510. /* > Modified. */
  511. /* > \endverbatim */
  512. /* > */
  513. /* > \param[in] LDA */
  514. /* > \verbatim */
  515. /* > LDA is INTEGER */
  516. /* > LDA specifies the first dimension of A as declared in the */
  517. /* > calling program. If PACK='N', 'U', 'L', 'C', or 'R', then */
  518. /* > LDA must be at least M. If PACK='B' or 'Q', then LDA must */
  519. /* > be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)). */
  520. /* > If PACK='Z', LDA must be large enough to hold the packed */
  521. /* > array: MIN( KU, N-1) + MIN( KL, M-1) + 1. */
  522. /* > Not modified. */
  523. /* > \endverbatim */
  524. /* > */
  525. /* > \param[out] WORK */
  526. /* > \verbatim */
  527. /* > WORK is COMPLEX*16 array, dimension ( 3*MAX( N, M ) ) */
  528. /* > Workspace. */
  529. /* > Modified. */
  530. /* > \endverbatim */
  531. /* > */
  532. /* > \param[out] INFO */
  533. /* > \verbatim */
  534. /* > INFO is INTEGER */
  535. /* > Error code. On exit, INFO will be set to one of the */
  536. /* > following values: */
  537. /* > 0 => normal return */
  538. /* > -1 => M negative or unequal to N and SYM='S', 'H', or 'P' */
  539. /* > -2 => N negative */
  540. /* > -3 => DIST illegal string */
  541. /* > -5 => SYM illegal string */
  542. /* > -7 => MODE not in range -6 to 6 */
  543. /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
  544. /* > -10 => KL negative */
  545. /* > -11 => KU negative, or SYM is not 'N' and KU is not equal to */
  546. /* > KL */
  547. /* > -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N'; */
  548. /* > or PACK='C' or 'Q' and SYM='N' and KL is not zero; */
  549. /* > or PACK='R' or 'B' and SYM='N' and KU is not zero; */
  550. /* > or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not */
  551. /* > N. */
  552. /* > -14 => LDA is less than M, or PACK='Z' and LDA is less than */
  553. /* > MIN(KU,N-1) + MIN(KL,M-1) + 1. */
  554. /* > 1 => Error return from DLATM7 */
  555. /* > 2 => Cannot scale to DMAX (f2cmax. sing. value is 0) */
  556. /* > 3 => Error return from ZLAGGE, ZLAGHE or ZLAGSY */
  557. /* > \endverbatim */
  558. /* Authors: */
  559. /* ======== */
  560. /* > \author Univ. of Tennessee */
  561. /* > \author Univ. of California Berkeley */
  562. /* > \author Univ. of Colorado Denver */
  563. /* > \author NAG Ltd. */
  564. /* > \date December 2016 */
  565. /* > \ingroup complex16_matgen */
  566. /* ===================================================================== */
  567. /* Subroutine */ void zlatmt_(integer *m, integer *n, char *dist, integer *
  568. iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
  569. doublereal *dmax__, integer *rank, integer *kl, integer *ku, char *
  570. pack, doublecomplex *a, integer *lda, doublecomplex *work, integer *
  571. info)
  572. {
  573. /* System generated locals */
  574. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  575. doublereal d__1, d__2, d__3;
  576. doublecomplex z__1, z__2, z__3;
  577. logical L__1;
  578. /* Local variables */
  579. integer ilda, icol;
  580. doublereal temp;
  581. logical csym;
  582. integer irow, isym;
  583. doublecomplex c__;
  584. integer i__, j, k;
  585. doublecomplex s;
  586. doublereal alpha, angle, realc;
  587. integer ipack, ioffg;
  588. extern /* Subroutine */ void dscal_(integer *, doublereal *, doublereal *,
  589. integer *);
  590. extern logical lsame_(char *, char *);
  591. integer iinfo, idist, mnmin;
  592. doublecomplex extra;
  593. integer iskew;
  594. doublecomplex dummy, ztemp;
  595. extern /* Subroutine */ void dlatm7_(integer *, doublereal *, integer *,
  596. integer *, integer *, doublereal *, integer *, integer *, integer
  597. *);
  598. integer ic, jc, nc, il;
  599. doublecomplex ct;
  600. integer iendch, ir, jr, ipackg, mr, minlda;
  601. extern doublereal dlarnd_(integer *, integer *);
  602. doublecomplex st;
  603. extern /* Subroutine */ void zlagge_(integer *, integer *, integer *,
  604. integer *, doublereal *, doublecomplex *, integer *, integer *,
  605. doublecomplex *, integer *), zlaghe_(integer *, integer *,
  606. doublereal *, doublecomplex *, integer *, integer *,
  607. doublecomplex *, integer *);
  608. extern int xerbla_(char *, integer *, ftnlen);
  609. integer ioffst, irsign;
  610. logical givens, iltemp;
  611. //extern /* Double Complex */ VOID zlarnd_(doublecomplex *, integer *,
  612. extern doublecomplex zlarnd_(integer *,
  613. integer *);
  614. extern /* Subroutine */ void zlaset_(char *, integer *, integer *,
  615. doublecomplex *, doublecomplex *, doublecomplex *, integer *), zlartg_(doublecomplex *, doublecomplex *, doublereal *,
  616. doublecomplex *, doublecomplex *);
  617. logical ilextr;
  618. extern /* Subroutine */ void zlagsy_(integer *, integer *, doublereal *,
  619. doublecomplex *, integer *, integer *, doublecomplex *, integer *)
  620. ;
  621. integer ir1, ir2, isympk;
  622. logical topdwn;
  623. extern /* Subroutine */ void zlarot_(logical *, logical *, logical *,
  624. integer *, doublecomplex *, doublecomplex *, doublecomplex *,
  625. integer *, doublecomplex *, doublecomplex *);
  626. integer jch, llb, jkl, jku, uub;
  627. /* -- LAPACK computational routine (version 3.7.0) -- */
  628. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  629. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  630. /* December 2016 */
  631. /* ===================================================================== */
  632. /* 1) Decode and Test the input parameters. */
  633. /* Initialize flags & seed. */
  634. /* Parameter adjustments */
  635. --iseed;
  636. --d__;
  637. a_dim1 = *lda;
  638. a_offset = 1 + a_dim1 * 1;
  639. a -= a_offset;
  640. --work;
  641. /* Function Body */
  642. *info = 0;
  643. /* Quick return if possible */
  644. if (*m == 0 || *n == 0) {
  645. return;
  646. }
  647. /* Decode DIST */
  648. if (lsame_(dist, "U")) {
  649. idist = 1;
  650. } else if (lsame_(dist, "S")) {
  651. idist = 2;
  652. } else if (lsame_(dist, "N")) {
  653. idist = 3;
  654. } else {
  655. idist = -1;
  656. }
  657. /* Decode SYM */
  658. if (lsame_(sym, "N")) {
  659. isym = 1;
  660. irsign = 0;
  661. csym = FALSE_;
  662. } else if (lsame_(sym, "P")) {
  663. isym = 2;
  664. irsign = 0;
  665. csym = FALSE_;
  666. } else if (lsame_(sym, "S")) {
  667. isym = 2;
  668. irsign = 0;
  669. csym = TRUE_;
  670. } else if (lsame_(sym, "H")) {
  671. isym = 2;
  672. irsign = 1;
  673. csym = FALSE_;
  674. } else {
  675. isym = -1;
  676. }
  677. /* Decode PACK */
  678. isympk = 0;
  679. if (lsame_(pack, "N")) {
  680. ipack = 0;
  681. } else if (lsame_(pack, "U")) {
  682. ipack = 1;
  683. isympk = 1;
  684. } else if (lsame_(pack, "L")) {
  685. ipack = 2;
  686. isympk = 1;
  687. } else if (lsame_(pack, "C")) {
  688. ipack = 3;
  689. isympk = 2;
  690. } else if (lsame_(pack, "R")) {
  691. ipack = 4;
  692. isympk = 3;
  693. } else if (lsame_(pack, "B")) {
  694. ipack = 5;
  695. isympk = 3;
  696. } else if (lsame_(pack, "Q")) {
  697. ipack = 6;
  698. isympk = 2;
  699. } else if (lsame_(pack, "Z")) {
  700. ipack = 7;
  701. } else {
  702. ipack = -1;
  703. }
  704. /* Set certain internal parameters */
  705. mnmin = f2cmin(*m,*n);
  706. /* Computing MIN */
  707. i__1 = *kl, i__2 = *m - 1;
  708. llb = f2cmin(i__1,i__2);
  709. /* Computing MIN */
  710. i__1 = *ku, i__2 = *n - 1;
  711. uub = f2cmin(i__1,i__2);
  712. /* Computing MIN */
  713. i__1 = *m, i__2 = *n + llb;
  714. mr = f2cmin(i__1,i__2);
  715. /* Computing MIN */
  716. i__1 = *n, i__2 = *m + uub;
  717. nc = f2cmin(i__1,i__2);
  718. if (ipack == 5 || ipack == 6) {
  719. minlda = uub + 1;
  720. } else if (ipack == 7) {
  721. minlda = llb + uub + 1;
  722. } else {
  723. minlda = *m;
  724. }
  725. /* Use Givens rotation method if bandwidth small enough, */
  726. /* or if LDA is too small to store the matrix unpacked. */
  727. givens = FALSE_;
  728. if (isym == 1) {
  729. /* Computing MAX */
  730. i__1 = 1, i__2 = mr + nc;
  731. if ((doublereal) (llb + uub) < (doublereal) f2cmax(i__1,i__2) * .3) {
  732. givens = TRUE_;
  733. }
  734. } else {
  735. if (llb << 1 < *m) {
  736. givens = TRUE_;
  737. }
  738. }
  739. if (*lda < *m && *lda >= minlda) {
  740. givens = TRUE_;
  741. }
  742. /* Set INFO if an error */
  743. if (*m < 0) {
  744. *info = -1;
  745. } else if (*m != *n && isym != 1) {
  746. *info = -1;
  747. } else if (*n < 0) {
  748. *info = -2;
  749. } else if (idist == -1) {
  750. *info = -3;
  751. } else if (isym == -1) {
  752. *info = -5;
  753. } else if (abs(*mode) > 6) {
  754. *info = -7;
  755. } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
  756. *info = -8;
  757. } else if (*kl < 0) {
  758. *info = -10;
  759. } else if (*ku < 0 || isym != 1 && *kl != *ku) {
  760. *info = -11;
  761. } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
  762. == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
  763. != 0 && *m != *n) {
  764. *info = -12;
  765. } else if (*lda < f2cmax(1,minlda)) {
  766. *info = -14;
  767. }
  768. if (*info != 0) {
  769. i__1 = -(*info);
  770. xerbla_("ZLATMT", &i__1, 6);
  771. return;
  772. }
  773. /* Initialize random number generator */
  774. for (i__ = 1; i__ <= 4; ++i__) {
  775. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  776. /* L100: */
  777. }
  778. if (iseed[4] % 2 != 1) {
  779. ++iseed[4];
  780. }
  781. /* 2) Set up D if indicated. */
  782. /* Compute D according to COND and MODE */
  783. dlatm7_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, rank, &
  784. iinfo);
  785. if (iinfo != 0) {
  786. *info = 1;
  787. return;
  788. }
  789. /* Choose Top-Down if D is (apparently) increasing, */
  790. /* Bottom-Up if D is (apparently) decreasing. */
  791. if (abs(d__[1]) <= (d__1 = d__[*rank], abs(d__1))) {
  792. topdwn = TRUE_;
  793. } else {
  794. topdwn = FALSE_;
  795. }
  796. if (*mode != 0 && abs(*mode) != 6) {
  797. /* Scale by DMAX */
  798. temp = abs(d__[1]);
  799. i__1 = *rank;
  800. for (i__ = 2; i__ <= i__1; ++i__) {
  801. /* Computing MAX */
  802. d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
  803. temp = f2cmax(d__2,d__3);
  804. /* L110: */
  805. }
  806. if (temp > 0.) {
  807. alpha = *dmax__ / temp;
  808. } else {
  809. *info = 2;
  810. return;
  811. }
  812. dscal_(rank, &alpha, &d__[1], &c__1);
  813. }
  814. zlaset_("Full", lda, n, &c_b1, &c_b1, &a[a_offset], lda);
  815. /* 3) Generate Banded Matrix using Givens rotations. */
  816. /* Also the special case of UUB=LLB=0 */
  817. /* Compute Addressing constants to cover all */
  818. /* storage formats. Whether GE, HE, SY, GB, HB, or SB, */
  819. /* upper or lower triangle or both, */
  820. /* the (i,j)-th element is in */
  821. /* A( i - ISKEW*j + IOFFST, j ) */
  822. if (ipack > 4) {
  823. ilda = *lda - 1;
  824. iskew = 1;
  825. if (ipack > 5) {
  826. ioffst = uub + 1;
  827. } else {
  828. ioffst = 1;
  829. }
  830. } else {
  831. ilda = *lda;
  832. iskew = 0;
  833. ioffst = 0;
  834. }
  835. /* IPACKG is the format that the matrix is generated in. If this is */
  836. /* different from IPACK, then the matrix must be repacked at the */
  837. /* end. It also signals how to compute the norm, for scaling. */
  838. ipackg = 0;
  839. /* Diagonal Matrix -- We are done, unless it */
  840. /* is to be stored HP/SP/PP/TP (PACK='R' or 'C') */
  841. if (llb == 0 && uub == 0) {
  842. i__1 = mnmin;
  843. for (j = 1; j <= i__1; ++j) {
  844. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  845. i__3 = j;
  846. z__1.r = d__[i__3], z__1.i = 0.;
  847. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  848. /* L120: */
  849. }
  850. if (ipack <= 2 || ipack >= 5) {
  851. ipackg = ipack;
  852. }
  853. } else if (givens) {
  854. /* Check whether to use Givens rotations, */
  855. /* Householder transformations, or nothing. */
  856. if (isym == 1) {
  857. /* Non-symmetric -- A = U D V */
  858. if (ipack > 4) {
  859. ipackg = ipack;
  860. } else {
  861. ipackg = 0;
  862. }
  863. i__1 = mnmin;
  864. for (j = 1; j <= i__1; ++j) {
  865. i__2 = (1 - iskew) * j + ioffst + j * a_dim1;
  866. i__3 = j;
  867. z__1.r = d__[i__3], z__1.i = 0.;
  868. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  869. /* L130: */
  870. }
  871. if (topdwn) {
  872. jkl = 0;
  873. i__1 = uub;
  874. for (jku = 1; jku <= i__1; ++jku) {
  875. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  876. /* Last row actually rotated is M */
  877. /* Last column actually rotated is MIN( M+JKU, N ) */
  878. /* Computing MIN */
  879. i__3 = *m + jku;
  880. i__2 = f2cmin(i__3,*n) + jkl - 1;
  881. for (jr = 1; jr <= i__2; ++jr) {
  882. extra.r = 0., extra.i = 0.;
  883. angle = dlarnd_(&c__1, &iseed[1]) *
  884. 6.2831853071795864769252867663;
  885. d__1 = cos(angle);
  886. //zlarnd_(&z__2, &c__5, &iseed[1]);
  887. z__2=zlarnd_(&c__5, &iseed[1]);
  888. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  889. c__.r = z__1.r, c__.i = z__1.i;
  890. d__1 = sin(angle);
  891. //zlarnd_(&z__2, &c__5, &iseed[1]);
  892. z__2=zlarnd_( &c__5, &iseed[1]);
  893. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  894. s.r = z__1.r, s.i = z__1.i;
  895. /* Computing MAX */
  896. i__3 = 1, i__4 = jr - jkl;
  897. icol = f2cmax(i__3,i__4);
  898. if (jr < *m) {
  899. /* Computing MIN */
  900. i__3 = *n, i__4 = jr + jku;
  901. il = f2cmin(i__3,i__4) + 1 - icol;
  902. L__1 = jr > jkl;
  903. zlarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
  904. a[jr - iskew * icol + ioffst + icol *
  905. a_dim1], &ilda, &extra, &dummy);
  906. }
  907. /* Chase "EXTRA" back up */
  908. ir = jr;
  909. ic = icol;
  910. i__3 = -jkl - jku;
  911. for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
  912. jch += i__3) {
  913. if (ir < *m) {
  914. zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  915. + (ic + 1) * a_dim1], &extra, &realc,
  916. &s, &dummy);
  917. d__1 = dlarnd_(&c__5, &iseed[1]);
  918. dummy.r = d__1, dummy.i = 0.;
  919. z__2.r = realc * dummy.r, z__2.i = realc *
  920. dummy.i;
  921. d_cnjg(&z__1, &z__2);
  922. c__.r = z__1.r, c__.i = z__1.i;
  923. z__3.r = -s.r, z__3.i = -s.i;
  924. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  925. z__2.i = z__3.r * dummy.i + z__3.i *
  926. dummy.r;
  927. d_cnjg(&z__1, &z__2);
  928. s.r = z__1.r, s.i = z__1.i;
  929. }
  930. /* Computing MAX */
  931. i__4 = 1, i__5 = jch - jku;
  932. irow = f2cmax(i__4,i__5);
  933. il = ir + 2 - irow;
  934. ztemp.r = 0., ztemp.i = 0.;
  935. iltemp = jch > jku;
  936. zlarot_(&c_false, &iltemp, &c_true, &il, &c__, &s,
  937. &a[irow - iskew * ic + ioffst + ic *
  938. a_dim1], &ilda, &ztemp, &extra);
  939. if (iltemp) {
  940. zlartg_(&a[irow + 1 - iskew * (ic + 1) +
  941. ioffst + (ic + 1) * a_dim1], &ztemp, &
  942. realc, &s, &dummy);
  943. //zlarnd_(&z__1, &c__5, &iseed[1]);
  944. z__1=zlarnd_( &c__5, &iseed[1]);
  945. dummy.r = z__1.r, dummy.i = z__1.i;
  946. z__2.r = realc * dummy.r, z__2.i = realc *
  947. dummy.i;
  948. d_cnjg(&z__1, &z__2);
  949. c__.r = z__1.r, c__.i = z__1.i;
  950. z__3.r = -s.r, z__3.i = -s.i;
  951. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  952. z__2.i = z__3.r * dummy.i + z__3.i *
  953. dummy.r;
  954. d_cnjg(&z__1, &z__2);
  955. s.r = z__1.r, s.i = z__1.i;
  956. /* Computing MAX */
  957. i__4 = 1, i__5 = jch - jku - jkl;
  958. icol = f2cmax(i__4,i__5);
  959. il = ic + 2 - icol;
  960. extra.r = 0., extra.i = 0.;
  961. L__1 = jch > jku + jkl;
  962. zlarot_(&c_true, &L__1, &c_true, &il, &c__, &
  963. s, &a[irow - iskew * icol + ioffst +
  964. icol * a_dim1], &ilda, &extra, &ztemp)
  965. ;
  966. ic = icol;
  967. ir = irow;
  968. }
  969. /* L140: */
  970. }
  971. /* L150: */
  972. }
  973. /* L160: */
  974. }
  975. jku = uub;
  976. i__1 = llb;
  977. for (jkl = 1; jkl <= i__1; ++jkl) {
  978. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  979. /* Computing MIN */
  980. i__3 = *n + jkl;
  981. i__2 = f2cmin(i__3,*m) + jku - 1;
  982. for (jc = 1; jc <= i__2; ++jc) {
  983. extra.r = 0., extra.i = 0.;
  984. angle = dlarnd_(&c__1, &iseed[1]) *
  985. 6.2831853071795864769252867663;
  986. d__1 = cos(angle);
  987. //zlarnd_(&z__2, &c__5, &iseed[1]);
  988. z__2=zlarnd_(&c__5, &iseed[1]);
  989. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  990. c__.r = z__1.r, c__.i = z__1.i;
  991. d__1 = sin(angle);
  992. //zlarnd_(&z__2, &c__5, &iseed[1]);
  993. z__2=zlarnd_(&c__5, &iseed[1]);
  994. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  995. s.r = z__1.r, s.i = z__1.i;
  996. /* Computing MAX */
  997. i__3 = 1, i__4 = jc - jku;
  998. irow = f2cmax(i__3,i__4);
  999. if (jc < *n) {
  1000. /* Computing MIN */
  1001. i__3 = *m, i__4 = jc + jkl;
  1002. il = f2cmin(i__3,i__4) + 1 - irow;
  1003. L__1 = jc > jku;
  1004. zlarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
  1005. &a[irow - iskew * jc + ioffst + jc *
  1006. a_dim1], &ilda, &extra, &dummy);
  1007. }
  1008. /* Chase "EXTRA" back up */
  1009. ic = jc;
  1010. ir = irow;
  1011. i__3 = -jkl - jku;
  1012. for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
  1013. jch += i__3) {
  1014. if (ic < *n) {
  1015. zlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1016. + (ic + 1) * a_dim1], &extra, &realc,
  1017. &s, &dummy);
  1018. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1019. z__1=zlarnd_(&c__5, &iseed[1]);
  1020. dummy.r = z__1.r, dummy.i = z__1.i;
  1021. z__2.r = realc * dummy.r, z__2.i = realc *
  1022. dummy.i;
  1023. d_cnjg(&z__1, &z__2);
  1024. c__.r = z__1.r, c__.i = z__1.i;
  1025. z__3.r = -s.r, z__3.i = -s.i;
  1026. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1027. z__2.i = z__3.r * dummy.i + z__3.i *
  1028. dummy.r;
  1029. d_cnjg(&z__1, &z__2);
  1030. s.r = z__1.r, s.i = z__1.i;
  1031. }
  1032. /* Computing MAX */
  1033. i__4 = 1, i__5 = jch - jkl;
  1034. icol = f2cmax(i__4,i__5);
  1035. il = ic + 2 - icol;
  1036. ztemp.r = 0., ztemp.i = 0.;
  1037. iltemp = jch > jkl;
  1038. zlarot_(&c_true, &iltemp, &c_true, &il, &c__, &s,
  1039. &a[ir - iskew * icol + ioffst + icol *
  1040. a_dim1], &ilda, &ztemp, &extra);
  1041. if (iltemp) {
  1042. zlartg_(&a[ir + 1 - iskew * (icol + 1) +
  1043. ioffst + (icol + 1) * a_dim1], &ztemp,
  1044. &realc, &s, &dummy);
  1045. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1046. z__1=zlarnd_(&c__5, &iseed[1]);
  1047. dummy.r = z__1.r, dummy.i = z__1.i;
  1048. z__2.r = realc * dummy.r, z__2.i = realc *
  1049. dummy.i;
  1050. d_cnjg(&z__1, &z__2);
  1051. c__.r = z__1.r, c__.i = z__1.i;
  1052. z__3.r = -s.r, z__3.i = -s.i;
  1053. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1054. z__2.i = z__3.r * dummy.i + z__3.i *
  1055. dummy.r;
  1056. d_cnjg(&z__1, &z__2);
  1057. s.r = z__1.r, s.i = z__1.i;
  1058. /* Computing MAX */
  1059. i__4 = 1, i__5 = jch - jkl - jku;
  1060. irow = f2cmax(i__4,i__5);
  1061. il = ir + 2 - irow;
  1062. extra.r = 0., extra.i = 0.;
  1063. L__1 = jch > jkl + jku;
  1064. zlarot_(&c_false, &L__1, &c_true, &il, &c__, &
  1065. s, &a[irow - iskew * icol + ioffst +
  1066. icol * a_dim1], &ilda, &extra, &ztemp)
  1067. ;
  1068. ic = icol;
  1069. ir = irow;
  1070. }
  1071. /* L170: */
  1072. }
  1073. /* L180: */
  1074. }
  1075. /* L190: */
  1076. }
  1077. } else {
  1078. /* Bottom-Up -- Start at the bottom right. */
  1079. jkl = 0;
  1080. i__1 = uub;
  1081. for (jku = 1; jku <= i__1; ++jku) {
  1082. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1083. /* First row actually rotated is M */
  1084. /* First column actually rotated is MIN( M+JKU, N ) */
  1085. /* Computing MIN */
  1086. i__2 = *m, i__3 = *n + jkl;
  1087. iendch = f2cmin(i__2,i__3) - 1;
  1088. /* Computing MIN */
  1089. i__2 = *m + jku;
  1090. i__3 = 1 - jkl;
  1091. for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
  1092. extra.r = 0., extra.i = 0.;
  1093. angle = dlarnd_(&c__1, &iseed[1]) *
  1094. 6.2831853071795864769252867663;
  1095. d__1 = cos(angle);
  1096. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1097. z__2=zlarnd_( &c__5, &iseed[1]);
  1098. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1099. c__.r = z__1.r, c__.i = z__1.i;
  1100. d__1 = sin(angle);
  1101. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1102. z__2=zlarnd_( &c__5, &iseed[1]);
  1103. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1104. s.r = z__1.r, s.i = z__1.i;
  1105. /* Computing MAX */
  1106. i__2 = 1, i__4 = jc - jku + 1;
  1107. irow = f2cmax(i__2,i__4);
  1108. if (jc > 0) {
  1109. /* Computing MIN */
  1110. i__2 = *m, i__4 = jc + jkl + 1;
  1111. il = f2cmin(i__2,i__4) + 1 - irow;
  1112. L__1 = jc + jkl < *m;
  1113. zlarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
  1114. &a[irow - iskew * jc + ioffst + jc *
  1115. a_dim1], &ilda, &dummy, &extra);
  1116. }
  1117. /* Chase "EXTRA" back down */
  1118. ic = jc;
  1119. i__2 = iendch;
  1120. i__4 = jkl + jku;
  1121. for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
  1122. i__2; jch += i__4) {
  1123. ilextr = ic > 0;
  1124. if (ilextr) {
  1125. zlartg_(&a[jch - iskew * ic + ioffst + ic *
  1126. a_dim1], &extra, &realc, &s, &dummy);
  1127. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1128. z__1=zlarnd_(&c__5, &iseed[1]);
  1129. dummy.r = z__1.r, dummy.i = z__1.i;
  1130. z__1.r = realc * dummy.r, z__1.i = realc *
  1131. dummy.i;
  1132. c__.r = z__1.r, c__.i = z__1.i;
  1133. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1134. z__1.i = s.r * dummy.i + s.i *
  1135. dummy.r;
  1136. s.r = z__1.r, s.i = z__1.i;
  1137. }
  1138. ic = f2cmax(1,ic);
  1139. /* Computing MIN */
  1140. i__5 = *n - 1, i__6 = jch + jku;
  1141. icol = f2cmin(i__5,i__6);
  1142. iltemp = jch + jku < *n;
  1143. ztemp.r = 0., ztemp.i = 0.;
  1144. i__5 = icol + 2 - ic;
  1145. zlarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
  1146. s, &a[jch - iskew * ic + ioffst + ic *
  1147. a_dim1], &ilda, &extra, &ztemp);
  1148. if (iltemp) {
  1149. zlartg_(&a[jch - iskew * icol + ioffst + icol
  1150. * a_dim1], &ztemp, &realc, &s, &dummy)
  1151. ;
  1152. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1153. z__1=zlarnd_(&c__5, &iseed[1]);
  1154. dummy.r = z__1.r, dummy.i = z__1.i;
  1155. z__1.r = realc * dummy.r, z__1.i = realc *
  1156. dummy.i;
  1157. c__.r = z__1.r, c__.i = z__1.i;
  1158. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1159. z__1.i = s.r * dummy.i + s.i *
  1160. dummy.r;
  1161. s.r = z__1.r, s.i = z__1.i;
  1162. /* Computing MIN */
  1163. i__5 = iendch, i__6 = jch + jkl + jku;
  1164. il = f2cmin(i__5,i__6) + 2 - jch;
  1165. extra.r = 0., extra.i = 0.;
  1166. L__1 = jch + jkl + jku <= iendch;
  1167. zlarot_(&c_false, &c_true, &L__1, &il, &c__, &
  1168. s, &a[jch - iskew * icol + ioffst +
  1169. icol * a_dim1], &ilda, &ztemp, &extra)
  1170. ;
  1171. ic = icol;
  1172. }
  1173. /* L200: */
  1174. }
  1175. /* L210: */
  1176. }
  1177. /* L220: */
  1178. }
  1179. jku = uub;
  1180. i__1 = llb;
  1181. for (jkl = 1; jkl <= i__1; ++jkl) {
  1182. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1183. /* First row actually rotated is MIN( N+JKL, M ) */
  1184. /* First column actually rotated is N */
  1185. /* Computing MIN */
  1186. i__3 = *n, i__4 = *m + jku;
  1187. iendch = f2cmin(i__3,i__4) - 1;
  1188. /* Computing MIN */
  1189. i__3 = *n + jkl;
  1190. i__4 = 1 - jku;
  1191. for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
  1192. extra.r = 0., extra.i = 0.;
  1193. angle = dlarnd_(&c__1, &iseed[1]) *
  1194. 6.2831853071795864769252867663;
  1195. d__1 = cos(angle);
  1196. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1197. z__2=zlarnd_(&c__5, &iseed[1]);
  1198. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1199. c__.r = z__1.r, c__.i = z__1.i;
  1200. d__1 = sin(angle);
  1201. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1202. z__2=zlarnd_(&c__5, &iseed[1]);
  1203. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1204. s.r = z__1.r, s.i = z__1.i;
  1205. /* Computing MAX */
  1206. i__3 = 1, i__2 = jr - jkl + 1;
  1207. icol = f2cmax(i__3,i__2);
  1208. if (jr > 0) {
  1209. /* Computing MIN */
  1210. i__3 = *n, i__2 = jr + jku + 1;
  1211. il = f2cmin(i__3,i__2) + 1 - icol;
  1212. L__1 = jr + jku < *n;
  1213. zlarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
  1214. a[jr - iskew * icol + ioffst + icol *
  1215. a_dim1], &ilda, &dummy, &extra);
  1216. }
  1217. /* Chase "EXTRA" back down */
  1218. ir = jr;
  1219. i__3 = iendch;
  1220. i__2 = jkl + jku;
  1221. for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
  1222. i__3; jch += i__2) {
  1223. ilextr = ir > 0;
  1224. if (ilextr) {
  1225. zlartg_(&a[ir - iskew * jch + ioffst + jch *
  1226. a_dim1], &extra, &realc, &s, &dummy);
  1227. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1228. z__1=zlarnd_( &c__5, &iseed[1]);
  1229. dummy.r = z__1.r, dummy.i = z__1.i;
  1230. z__1.r = realc * dummy.r, z__1.i = realc *
  1231. dummy.i;
  1232. c__.r = z__1.r, c__.i = z__1.i;
  1233. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1234. z__1.i = s.r * dummy.i + s.i *
  1235. dummy.r;
  1236. s.r = z__1.r, s.i = z__1.i;
  1237. }
  1238. ir = f2cmax(1,ir);
  1239. /* Computing MIN */
  1240. i__5 = *m - 1, i__6 = jch + jkl;
  1241. irow = f2cmin(i__5,i__6);
  1242. iltemp = jch + jkl < *m;
  1243. ztemp.r = 0., ztemp.i = 0.;
  1244. i__5 = irow + 2 - ir;
  1245. zlarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
  1246. s, &a[ir - iskew * jch + ioffst + jch *
  1247. a_dim1], &ilda, &extra, &ztemp);
  1248. if (iltemp) {
  1249. zlartg_(&a[irow - iskew * jch + ioffst + jch *
  1250. a_dim1], &ztemp, &realc, &s, &dummy);
  1251. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1252. z__1=zlarnd_(&c__5, &iseed[1]);
  1253. dummy.r = z__1.r, dummy.i = z__1.i;
  1254. z__1.r = realc * dummy.r, z__1.i = realc *
  1255. dummy.i;
  1256. c__.r = z__1.r, c__.i = z__1.i;
  1257. z__1.r = s.r * dummy.r - s.i * dummy.i,
  1258. z__1.i = s.r * dummy.i + s.i *
  1259. dummy.r;
  1260. s.r = z__1.r, s.i = z__1.i;
  1261. /* Computing MIN */
  1262. i__5 = iendch, i__6 = jch + jkl + jku;
  1263. il = f2cmin(i__5,i__6) + 2 - jch;
  1264. extra.r = 0., extra.i = 0.;
  1265. L__1 = jch + jkl + jku <= iendch;
  1266. zlarot_(&c_true, &c_true, &L__1, &il, &c__, &
  1267. s, &a[irow - iskew * jch + ioffst +
  1268. jch * a_dim1], &ilda, &ztemp, &extra);
  1269. ir = irow;
  1270. }
  1271. /* L230: */
  1272. }
  1273. /* L240: */
  1274. }
  1275. /* L250: */
  1276. }
  1277. }
  1278. } else {
  1279. /* Symmetric -- A = U D U' */
  1280. /* Hermitian -- A = U D U* */
  1281. ipackg = ipack;
  1282. ioffg = ioffst;
  1283. if (topdwn) {
  1284. /* Top-Down -- Generate Upper triangle only */
  1285. if (ipack >= 5) {
  1286. ipackg = 6;
  1287. ioffg = uub + 1;
  1288. } else {
  1289. ipackg = 1;
  1290. }
  1291. i__1 = mnmin;
  1292. for (j = 1; j <= i__1; ++j) {
  1293. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1294. i__2 = j;
  1295. z__1.r = d__[i__2], z__1.i = 0.;
  1296. a[i__4].r = z__1.r, a[i__4].i = z__1.i;
  1297. /* L260: */
  1298. }
  1299. i__1 = uub;
  1300. for (k = 1; k <= i__1; ++k) {
  1301. i__4 = *n - 1;
  1302. for (jc = 1; jc <= i__4; ++jc) {
  1303. /* Computing MAX */
  1304. i__2 = 1, i__3 = jc - k;
  1305. irow = f2cmax(i__2,i__3);
  1306. /* Computing MIN */
  1307. i__2 = jc + 1, i__3 = k + 2;
  1308. il = f2cmin(i__2,i__3);
  1309. extra.r = 0., extra.i = 0.;
  1310. i__2 = jc - iskew * (jc + 1) + ioffg + (jc + 1) *
  1311. a_dim1;
  1312. ztemp.r = a[i__2].r, ztemp.i = a[i__2].i;
  1313. angle = dlarnd_(&c__1, &iseed[1]) *
  1314. 6.2831853071795864769252867663;
  1315. d__1 = cos(angle);
  1316. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1317. z__2=zlarnd_(&c__5, &iseed[1]);
  1318. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1319. c__.r = z__1.r, c__.i = z__1.i;
  1320. d__1 = sin(angle);
  1321. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1322. z__2=zlarnd_( &c__5, &iseed[1]);
  1323. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1324. s.r = z__1.r, s.i = z__1.i;
  1325. if (csym) {
  1326. ct.r = c__.r, ct.i = c__.i;
  1327. st.r = s.r, st.i = s.i;
  1328. } else {
  1329. d_cnjg(&z__1, &ztemp);
  1330. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1331. d_cnjg(&z__1, &c__);
  1332. ct.r = z__1.r, ct.i = z__1.i;
  1333. d_cnjg(&z__1, &s);
  1334. st.r = z__1.r, st.i = z__1.i;
  1335. }
  1336. L__1 = jc > k;
  1337. zlarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
  1338. irow - iskew * jc + ioffg + jc * a_dim1], &
  1339. ilda, &extra, &ztemp);
  1340. /* Computing MIN */
  1341. i__3 = k, i__5 = *n - jc;
  1342. i__2 = f2cmin(i__3,i__5) + 1;
  1343. zlarot_(&c_true, &c_true, &c_false, &i__2, &ct, &st, &
  1344. a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
  1345. ilda, &ztemp, &dummy);
  1346. /* Chase EXTRA back up the matrix */
  1347. icol = jc;
  1348. i__2 = -k;
  1349. for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
  1350. jch += i__2) {
  1351. zlartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
  1352. (icol + 1) * a_dim1], &extra, &realc, &s,
  1353. &dummy);
  1354. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1355. z__1=zlarnd_(&c__5, &iseed[1]);
  1356. dummy.r = z__1.r, dummy.i = z__1.i;
  1357. z__2.r = realc * dummy.r, z__2.i = realc *
  1358. dummy.i;
  1359. d_cnjg(&z__1, &z__2);
  1360. c__.r = z__1.r, c__.i = z__1.i;
  1361. z__3.r = -s.r, z__3.i = -s.i;
  1362. z__2.r = z__3.r * dummy.r - z__3.i * dummy.i,
  1363. z__2.i = z__3.r * dummy.i + z__3.i *
  1364. dummy.r;
  1365. d_cnjg(&z__1, &z__2);
  1366. s.r = z__1.r, s.i = z__1.i;
  1367. i__3 = jch - iskew * (jch + 1) + ioffg + (jch + 1)
  1368. * a_dim1;
  1369. ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
  1370. if (csym) {
  1371. ct.r = c__.r, ct.i = c__.i;
  1372. st.r = s.r, st.i = s.i;
  1373. } else {
  1374. d_cnjg(&z__1, &ztemp);
  1375. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1376. d_cnjg(&z__1, &c__);
  1377. ct.r = z__1.r, ct.i = z__1.i;
  1378. d_cnjg(&z__1, &s);
  1379. st.r = z__1.r, st.i = z__1.i;
  1380. }
  1381. i__3 = k + 2;
  1382. zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1383. s, &a[(1 - iskew) * jch + ioffg + jch *
  1384. a_dim1], &ilda, &ztemp, &extra);
  1385. /* Computing MAX */
  1386. i__3 = 1, i__5 = jch - k;
  1387. irow = f2cmax(i__3,i__5);
  1388. /* Computing MIN */
  1389. i__3 = jch + 1, i__5 = k + 2;
  1390. il = f2cmin(i__3,i__5);
  1391. extra.r = 0., extra.i = 0.;
  1392. L__1 = jch > k;
  1393. zlarot_(&c_false, &L__1, &c_true, &il, &ct, &st, &
  1394. a[irow - iskew * jch + ioffg + jch *
  1395. a_dim1], &ilda, &extra, &ztemp);
  1396. icol = jch;
  1397. /* L270: */
  1398. }
  1399. /* L280: */
  1400. }
  1401. /* L290: */
  1402. }
  1403. /* If we need lower triangle, copy from upper. Note that */
  1404. /* the order of copying is chosen to work for 'q' -> 'b' */
  1405. if (ipack != ipackg && ipack != 3) {
  1406. i__1 = *n;
  1407. for (jc = 1; jc <= i__1; ++jc) {
  1408. irow = ioffst - iskew * jc;
  1409. if (csym) {
  1410. /* Computing MIN */
  1411. i__2 = *n, i__3 = jc + uub;
  1412. i__4 = f2cmin(i__2,i__3);
  1413. for (jr = jc; jr <= i__4; ++jr) {
  1414. i__2 = jr + irow + jc * a_dim1;
  1415. i__3 = jc - iskew * jr + ioffg + jr * a_dim1;
  1416. a[i__2].r = a[i__3].r, a[i__2].i = a[i__3].i;
  1417. /* L300: */
  1418. }
  1419. } else {
  1420. /* Computing MIN */
  1421. i__2 = *n, i__3 = jc + uub;
  1422. i__4 = f2cmin(i__2,i__3);
  1423. for (jr = jc; jr <= i__4; ++jr) {
  1424. i__2 = jr + irow + jc * a_dim1;
  1425. d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
  1426. * a_dim1]);
  1427. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1428. /* L310: */
  1429. }
  1430. }
  1431. /* L320: */
  1432. }
  1433. if (ipack == 5) {
  1434. i__1 = *n;
  1435. for (jc = *n - uub + 1; jc <= i__1; ++jc) {
  1436. i__4 = uub + 1;
  1437. for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
  1438. i__2 = jr + jc * a_dim1;
  1439. a[i__2].r = 0., a[i__2].i = 0.;
  1440. /* L330: */
  1441. }
  1442. /* L340: */
  1443. }
  1444. }
  1445. if (ipackg == 6) {
  1446. ipackg = ipack;
  1447. } else {
  1448. ipackg = 0;
  1449. }
  1450. }
  1451. } else {
  1452. /* Bottom-Up -- Generate Lower triangle only */
  1453. if (ipack >= 5) {
  1454. ipackg = 5;
  1455. if (ipack == 6) {
  1456. ioffg = 1;
  1457. }
  1458. } else {
  1459. ipackg = 2;
  1460. }
  1461. i__1 = mnmin;
  1462. for (j = 1; j <= i__1; ++j) {
  1463. i__4 = (1 - iskew) * j + ioffg + j * a_dim1;
  1464. i__2 = j;
  1465. z__1.r = d__[i__2], z__1.i = 0.;
  1466. a[i__4].r = z__1.r, a[i__4].i = z__1.i;
  1467. /* L350: */
  1468. }
  1469. i__1 = uub;
  1470. for (k = 1; k <= i__1; ++k) {
  1471. for (jc = *n - 1; jc >= 1; --jc) {
  1472. /* Computing MIN */
  1473. i__4 = *n + 1 - jc, i__2 = k + 2;
  1474. il = f2cmin(i__4,i__2);
  1475. extra.r = 0., extra.i = 0.;
  1476. i__4 = (1 - iskew) * jc + 1 + ioffg + jc * a_dim1;
  1477. ztemp.r = a[i__4].r, ztemp.i = a[i__4].i;
  1478. angle = dlarnd_(&c__1, &iseed[1]) *
  1479. 6.2831853071795864769252867663;
  1480. d__1 = cos(angle);
  1481. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1482. z__2=zlarnd_(&c__5, &iseed[1]);
  1483. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1484. c__.r = z__1.r, c__.i = z__1.i;
  1485. d__1 = sin(angle);
  1486. //zlarnd_(&z__2, &c__5, &iseed[1]);
  1487. z__2=zlarnd_(&c__5, &iseed[1]);
  1488. z__1.r = d__1 * z__2.r, z__1.i = d__1 * z__2.i;
  1489. s.r = z__1.r, s.i = z__1.i;
  1490. if (csym) {
  1491. ct.r = c__.r, ct.i = c__.i;
  1492. st.r = s.r, st.i = s.i;
  1493. } else {
  1494. d_cnjg(&z__1, &ztemp);
  1495. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1496. d_cnjg(&z__1, &c__);
  1497. ct.r = z__1.r, ct.i = z__1.i;
  1498. d_cnjg(&z__1, &s);
  1499. st.r = z__1.r, st.i = z__1.i;
  1500. }
  1501. L__1 = *n - jc > k;
  1502. zlarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
  1503. 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
  1504. &ztemp, &extra);
  1505. /* Computing MAX */
  1506. i__4 = 1, i__2 = jc - k + 1;
  1507. icol = f2cmax(i__4,i__2);
  1508. i__4 = jc + 2 - icol;
  1509. zlarot_(&c_true, &c_false, &c_true, &i__4, &ct, &st, &
  1510. a[jc - iskew * icol + ioffg + icol * a_dim1],
  1511. &ilda, &dummy, &ztemp);
  1512. /* Chase EXTRA back down the matrix */
  1513. icol = jc;
  1514. i__4 = *n - 1;
  1515. i__2 = k;
  1516. for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
  1517. i__4; jch += i__2) {
  1518. zlartg_(&a[jch - iskew * icol + ioffg + icol *
  1519. a_dim1], &extra, &realc, &s, &dummy);
  1520. //zlarnd_(&z__1, &c__5, &iseed[1]);
  1521. z__1=zlarnd_(&c__5, &iseed[1]);
  1522. dummy.r = z__1.r, dummy.i = z__1.i;
  1523. z__1.r = realc * dummy.r, z__1.i = realc *
  1524. dummy.i;
  1525. c__.r = z__1.r, c__.i = z__1.i;
  1526. z__1.r = s.r * dummy.r - s.i * dummy.i, z__1.i =
  1527. s.r * dummy.i + s.i * dummy.r;
  1528. s.r = z__1.r, s.i = z__1.i;
  1529. i__3 = (1 - iskew) * jch + 1 + ioffg + jch *
  1530. a_dim1;
  1531. ztemp.r = a[i__3].r, ztemp.i = a[i__3].i;
  1532. if (csym) {
  1533. ct.r = c__.r, ct.i = c__.i;
  1534. st.r = s.r, st.i = s.i;
  1535. } else {
  1536. d_cnjg(&z__1, &ztemp);
  1537. ztemp.r = z__1.r, ztemp.i = z__1.i;
  1538. d_cnjg(&z__1, &c__);
  1539. ct.r = z__1.r, ct.i = z__1.i;
  1540. d_cnjg(&z__1, &s);
  1541. st.r = z__1.r, st.i = z__1.i;
  1542. }
  1543. i__3 = k + 2;
  1544. zlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1545. s, &a[jch - iskew * icol + ioffg + icol *
  1546. a_dim1], &ilda, &extra, &ztemp);
  1547. /* Computing MIN */
  1548. i__3 = *n + 1 - jch, i__5 = k + 2;
  1549. il = f2cmin(i__3,i__5);
  1550. extra.r = 0., extra.i = 0.;
  1551. L__1 = *n - jch > k;
  1552. zlarot_(&c_false, &c_true, &L__1, &il, &ct, &st, &
  1553. a[(1 - iskew) * jch + ioffg + jch *
  1554. a_dim1], &ilda, &ztemp, &extra);
  1555. icol = jch;
  1556. /* L360: */
  1557. }
  1558. /* L370: */
  1559. }
  1560. /* L380: */
  1561. }
  1562. /* If we need upper triangle, copy from lower. Note that */
  1563. /* the order of copying is chosen to work for 'b' -> 'q' */
  1564. if (ipack != ipackg && ipack != 4) {
  1565. for (jc = *n; jc >= 1; --jc) {
  1566. irow = ioffst - iskew * jc;
  1567. if (csym) {
  1568. /* Computing MAX */
  1569. i__2 = 1, i__4 = jc - uub;
  1570. i__1 = f2cmax(i__2,i__4);
  1571. for (jr = jc; jr >= i__1; --jr) {
  1572. i__2 = jr + irow + jc * a_dim1;
  1573. i__4 = jc - iskew * jr + ioffg + jr * a_dim1;
  1574. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1575. /* L390: */
  1576. }
  1577. } else {
  1578. /* Computing MAX */
  1579. i__2 = 1, i__4 = jc - uub;
  1580. i__1 = f2cmax(i__2,i__4);
  1581. for (jr = jc; jr >= i__1; --jr) {
  1582. i__2 = jr + irow + jc * a_dim1;
  1583. d_cnjg(&z__1, &a[jc - iskew * jr + ioffg + jr
  1584. * a_dim1]);
  1585. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1586. /* L400: */
  1587. }
  1588. }
  1589. /* L410: */
  1590. }
  1591. if (ipack == 6) {
  1592. i__1 = uub;
  1593. for (jc = 1; jc <= i__1; ++jc) {
  1594. i__2 = uub + 1 - jc;
  1595. for (jr = 1; jr <= i__2; ++jr) {
  1596. i__4 = jr + jc * a_dim1;
  1597. a[i__4].r = 0., a[i__4].i = 0.;
  1598. /* L420: */
  1599. }
  1600. /* L430: */
  1601. }
  1602. }
  1603. if (ipackg == 5) {
  1604. ipackg = ipack;
  1605. } else {
  1606. ipackg = 0;
  1607. }
  1608. }
  1609. }
  1610. /* Ensure that the diagonal is real if Hermitian */
  1611. if (! csym) {
  1612. i__1 = *n;
  1613. for (jc = 1; jc <= i__1; ++jc) {
  1614. irow = ioffst + (1 - iskew) * jc;
  1615. i__2 = irow + jc * a_dim1;
  1616. i__4 = irow + jc * a_dim1;
  1617. d__1 = a[i__4].r;
  1618. z__1.r = d__1, z__1.i = 0.;
  1619. a[i__2].r = z__1.r, a[i__2].i = z__1.i;
  1620. /* L440: */
  1621. }
  1622. }
  1623. }
  1624. } else {
  1625. /* 4) Generate Banded Matrix by first */
  1626. /* Rotating by random Unitary matrices, */
  1627. /* then reducing the bandwidth using Householder */
  1628. /* transformations. */
  1629. /* Note: we should get here only if LDA .ge. N */
  1630. if (isym == 1) {
  1631. /* Non-symmetric -- A = U D V */
  1632. zlagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
  1633. 1], &work[1], &iinfo);
  1634. } else {
  1635. /* Symmetric -- A = U D U' or */
  1636. /* Hermitian -- A = U D U* */
  1637. if (csym) {
  1638. zlagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1639. 1], &iinfo);
  1640. } else {
  1641. zlaghe_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[
  1642. 1], &iinfo);
  1643. }
  1644. }
  1645. if (iinfo != 0) {
  1646. *info = 3;
  1647. return;
  1648. }
  1649. }
  1650. /* 5) Pack the matrix */
  1651. if (ipack != ipackg) {
  1652. if (ipack == 1) {
  1653. /* 'U' -- Upper triangular, not packed */
  1654. i__1 = *m;
  1655. for (j = 1; j <= i__1; ++j) {
  1656. i__2 = *m;
  1657. for (i__ = j + 1; i__ <= i__2; ++i__) {
  1658. i__4 = i__ + j * a_dim1;
  1659. a[i__4].r = 0., a[i__4].i = 0.;
  1660. /* L450: */
  1661. }
  1662. /* L460: */
  1663. }
  1664. } else if (ipack == 2) {
  1665. /* 'L' -- Lower triangular, not packed */
  1666. i__1 = *m;
  1667. for (j = 2; j <= i__1; ++j) {
  1668. i__2 = j - 1;
  1669. for (i__ = 1; i__ <= i__2; ++i__) {
  1670. i__4 = i__ + j * a_dim1;
  1671. a[i__4].r = 0., a[i__4].i = 0.;
  1672. /* L470: */
  1673. }
  1674. /* L480: */
  1675. }
  1676. } else if (ipack == 3) {
  1677. /* 'C' -- Upper triangle packed Columnwise. */
  1678. icol = 1;
  1679. irow = 0;
  1680. i__1 = *m;
  1681. for (j = 1; j <= i__1; ++j) {
  1682. i__2 = j;
  1683. for (i__ = 1; i__ <= i__2; ++i__) {
  1684. ++irow;
  1685. if (irow > *lda) {
  1686. irow = 1;
  1687. ++icol;
  1688. }
  1689. i__4 = irow + icol * a_dim1;
  1690. i__3 = i__ + j * a_dim1;
  1691. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1692. /* L490: */
  1693. }
  1694. /* L500: */
  1695. }
  1696. } else if (ipack == 4) {
  1697. /* 'R' -- Lower triangle packed Columnwise. */
  1698. icol = 1;
  1699. irow = 0;
  1700. i__1 = *m;
  1701. for (j = 1; j <= i__1; ++j) {
  1702. i__2 = *m;
  1703. for (i__ = j; i__ <= i__2; ++i__) {
  1704. ++irow;
  1705. if (irow > *lda) {
  1706. irow = 1;
  1707. ++icol;
  1708. }
  1709. i__4 = irow + icol * a_dim1;
  1710. i__3 = i__ + j * a_dim1;
  1711. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1712. /* L510: */
  1713. }
  1714. /* L520: */
  1715. }
  1716. } else if (ipack >= 5) {
  1717. /* 'B' -- The lower triangle is packed as a band matrix. */
  1718. /* 'Q' -- The upper triangle is packed as a band matrix. */
  1719. /* 'Z' -- The whole matrix is packed as a band matrix. */
  1720. if (ipack == 5) {
  1721. uub = 0;
  1722. }
  1723. if (ipack == 6) {
  1724. llb = 0;
  1725. }
  1726. i__1 = uub;
  1727. for (j = 1; j <= i__1; ++j) {
  1728. /* Computing MIN */
  1729. i__2 = j + llb;
  1730. for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
  1731. i__2 = i__ - j + uub + 1 + j * a_dim1;
  1732. i__4 = i__ + j * a_dim1;
  1733. a[i__2].r = a[i__4].r, a[i__2].i = a[i__4].i;
  1734. /* L530: */
  1735. }
  1736. /* L540: */
  1737. }
  1738. i__1 = *n;
  1739. for (j = uub + 2; j <= i__1; ++j) {
  1740. /* Computing MIN */
  1741. i__4 = j + llb;
  1742. i__2 = f2cmin(i__4,*m);
  1743. for (i__ = j - uub; i__ <= i__2; ++i__) {
  1744. i__4 = i__ - j + uub + 1 + j * a_dim1;
  1745. i__3 = i__ + j * a_dim1;
  1746. a[i__4].r = a[i__3].r, a[i__4].i = a[i__3].i;
  1747. /* L550: */
  1748. }
  1749. /* L560: */
  1750. }
  1751. }
  1752. /* If packed, zero out extraneous elements. */
  1753. /* Symmetric/Triangular Packed -- */
  1754. /* zero out everything after A(IROW,ICOL) */
  1755. if (ipack == 3 || ipack == 4) {
  1756. i__1 = *m;
  1757. for (jc = icol; jc <= i__1; ++jc) {
  1758. i__2 = *lda;
  1759. for (jr = irow + 1; jr <= i__2; ++jr) {
  1760. i__4 = jr + jc * a_dim1;
  1761. a[i__4].r = 0., a[i__4].i = 0.;
  1762. /* L570: */
  1763. }
  1764. irow = 0;
  1765. /* L580: */
  1766. }
  1767. } else if (ipack >= 5) {
  1768. /* Packed Band -- */
  1769. /* 1st row is now in A( UUB+2-j, j), zero above it */
  1770. /* m-th row is now in A( M+UUB-j,j), zero below it */
  1771. /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
  1772. /* zero below it, too. */
  1773. ir1 = uub + llb + 2;
  1774. ir2 = uub + *m + 2;
  1775. i__1 = *n;
  1776. for (jc = 1; jc <= i__1; ++jc) {
  1777. i__2 = uub + 1 - jc;
  1778. for (jr = 1; jr <= i__2; ++jr) {
  1779. i__4 = jr + jc * a_dim1;
  1780. a[i__4].r = 0., a[i__4].i = 0.;
  1781. /* L590: */
  1782. }
  1783. /* Computing MAX */
  1784. /* Computing MIN */
  1785. i__3 = ir1, i__5 = ir2 - jc;
  1786. i__2 = 1, i__4 = f2cmin(i__3,i__5);
  1787. i__6 = *lda;
  1788. for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
  1789. i__2 = jr + jc * a_dim1;
  1790. a[i__2].r = 0., a[i__2].i = 0.;
  1791. /* L600: */
  1792. }
  1793. /* L610: */
  1794. }
  1795. }
  1796. }
  1797. return;
  1798. /* End of ZLATMT */
  1799. } /* zlatmt_ */