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

clatms.c 62 kB

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