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.

dlatmt.c 51 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780
  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 integer c__1 = 1;
  363. static doublereal c_b22 = 0.;
  364. static logical c_true = TRUE_;
  365. static logical c_false = FALSE_;
  366. /* > \brief \b DLATMT */
  367. /* =========== DOCUMENTATION =========== */
  368. /* Online html documentation available at */
  369. /* http://www.netlib.org/lapack/explore-html/ */
  370. /* Definition: */
  371. /* =========== */
  372. /* SUBROUTINE DLATMT( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
  373. /* RANK, KL, KU, PACK, A, LDA, WORK, INFO ) */
  374. /* DOUBLE PRECISION COND, DMAX */
  375. /* INTEGER INFO, KL, KU, LDA, M, MODE, N, RANK */
  376. /* CHARACTER DIST, PACK, SYM */
  377. /* DOUBLE PRECISION A( LDA, * ), D( * ), WORK( * ) */
  378. /* INTEGER ISEED( 4 ) */
  379. /* > \par Purpose: */
  380. /* ============= */
  381. /* > */
  382. /* > \verbatim */
  383. /* > */
  384. /* > DLATMT generates random matrices with specified singular values */
  385. /* > (or symmetric/hermitian with specified eigenvalues) */
  386. /* > for testing LAPACK programs. */
  387. /* > */
  388. /* > DLATMT operates by applying the following sequence of */
  389. /* > operations: */
  390. /* > */
  391. /* > Set the diagonal to D, where D may be input or */
  392. /* > computed according to MODE, COND, DMAX, and SYM */
  393. /* > as described below. */
  394. /* > */
  395. /* > Generate a matrix with the appropriate band structure, by one */
  396. /* > of two methods: */
  397. /* > */
  398. /* > Method A: */
  399. /* > Generate a dense M x N matrix by multiplying D on the left */
  400. /* > and the right by random unitary matrices, then: */
  401. /* > */
  402. /* > Reduce the bandwidth according to KL and KU, using */
  403. /* > Householder transformations. */
  404. /* > */
  405. /* > Method B: */
  406. /* > Convert the bandwidth-0 (i.e., diagonal) matrix to a */
  407. /* > bandwidth-1 matrix using Givens rotations, "chasing" */
  408. /* > out-of-band elements back, much as in QR; then */
  409. /* > convert the bandwidth-1 to a bandwidth-2 matrix, etc. */
  410. /* > Note that for reasonably small bandwidths (relative to */
  411. /* > M and N) this requires less storage, as a dense matrix */
  412. /* > is not generated. Also, for symmetric matrices, only */
  413. /* > one triangle is generated. */
  414. /* > */
  415. /* > Method A is chosen if the bandwidth is a large fraction of the */
  416. /* > order of the matrix, and LDA is at least M (so a dense */
  417. /* > matrix can be stored.) Method B is chosen if the bandwidth */
  418. /* > is small (< 1/2 N for symmetric, < .3 N+M for */
  419. /* > non-symmetric), or LDA is less than M and not less than the */
  420. /* > bandwidth. */
  421. /* > */
  422. /* > Pack the matrix if desired. Options specified by PACK are: */
  423. /* > no packing */
  424. /* > zero out upper half (if symmetric) */
  425. /* > zero out lower half (if symmetric) */
  426. /* > store the upper half columnwise (if symmetric or upper */
  427. /* > triangular) */
  428. /* > store the lower half columnwise (if symmetric or lower */
  429. /* > triangular) */
  430. /* > store the lower triangle in banded format (if symmetric */
  431. /* > or lower triangular) */
  432. /* > store the upper triangle in banded format (if symmetric */
  433. /* > or upper triangular) */
  434. /* > store the entire matrix in banded format */
  435. /* > If Method B is chosen, and band format is specified, then the */
  436. /* > matrix will be generated in the band format, so no repacking */
  437. /* > will be necessary. */
  438. /* > \endverbatim */
  439. /* Arguments: */
  440. /* ========== */
  441. /* > \param[in] M */
  442. /* > \verbatim */
  443. /* > M is INTEGER */
  444. /* > The number of rows of A. Not modified. */
  445. /* > \endverbatim */
  446. /* > */
  447. /* > \param[in] N */
  448. /* > \verbatim */
  449. /* > N is INTEGER */
  450. /* > The number of columns of A. Not modified. */
  451. /* > \endverbatim */
  452. /* > */
  453. /* > \param[in] DIST */
  454. /* > \verbatim */
  455. /* > DIST is CHARACTER*1 */
  456. /* > On entry, DIST specifies the type of distribution to be used */
  457. /* > to generate the random eigen-/singular values. */
  458. /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
  459. /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
  460. /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
  461. /* > Not modified. */
  462. /* > \endverbatim */
  463. /* > */
  464. /* > \param[in,out] ISEED */
  465. /* > \verbatim */
  466. /* > ISEED is INTEGER array, dimension ( 4 ) */
  467. /* > On entry ISEED specifies the seed of the random number */
  468. /* > generator. They should lie between 0 and 4095 inclusive, */
  469. /* > and ISEED(4) should be odd. The random number generator */
  470. /* > uses a linear congruential sequence limited to small */
  471. /* > integers, and so should produce machine independent */
  472. /* > random numbers. The values of ISEED are changed on */
  473. /* > exit, and can be used in the next call to DLATMT */
  474. /* > to continue the same random number sequence. */
  475. /* > Changed on exit. */
  476. /* > \endverbatim */
  477. /* > */
  478. /* > \param[in] SYM */
  479. /* > \verbatim */
  480. /* > SYM is CHARACTER*1 */
  481. /* > If SYM='S' or 'H', the generated matrix is symmetric, with */
  482. /* > eigenvalues specified by D, COND, MODE, and DMAX; they */
  483. /* > may be positive, negative, or zero. */
  484. /* > If SYM='P', the generated matrix is symmetric, with */
  485. /* > eigenvalues (= singular values) specified by D, COND, */
  486. /* > MODE, and DMAX; they will not be negative. */
  487. /* > If SYM='N', the generated matrix is nonsymmetric, with */
  488. /* > singular values specified by D, COND, MODE, and DMAX; */
  489. /* > they will not be negative. */
  490. /* > Not modified. */
  491. /* > \endverbatim */
  492. /* > */
  493. /* > \param[in,out] D */
  494. /* > \verbatim */
  495. /* > D is DOUBLE PRECISION array, dimension ( MIN( M , N ) ) */
  496. /* > This array is used to specify the singular values or */
  497. /* > eigenvalues of A (see SYM, above.) If MODE=0, then D is */
  498. /* > assumed to contain the singular/eigenvalues, otherwise */
  499. /* > they will be computed according to MODE, COND, and DMAX, */
  500. /* > and placed in D. */
  501. /* > Modified if MODE is nonzero. */
  502. /* > \endverbatim */
  503. /* > */
  504. /* > \param[in] MODE */
  505. /* > \verbatim */
  506. /* > MODE is INTEGER */
  507. /* > On entry this describes how the singular/eigenvalues are to */
  508. /* > be specified: */
  509. /* > MODE = 0 means use D as input */
  510. /* > */
  511. /* > MODE = 1 sets D(1)=1 and D(2:RANK)=1.0/COND */
  512. /* > MODE = 2 sets D(1:RANK-1)=1 and D(RANK)=1.0/COND */
  513. /* > MODE = 3 sets D(I)=COND**(-(I-1)/(RANK-1)) */
  514. /* > */
  515. /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
  516. /* > MODE = 5 sets D to random numbers in the range */
  517. /* > ( 1/COND , 1 ) such that their logarithms */
  518. /* > are uniformly distributed. */
  519. /* > MODE = 6 set D to random numbers from same distribution */
  520. /* > as the rest of the matrix. */
  521. /* > MODE < 0 has the same meaning as ABS(MODE), except that */
  522. /* > the order of the elements of D is reversed. */
  523. /* > Thus if MODE is positive, D has entries ranging from */
  524. /* > 1 to 1/COND, if negative, from 1/COND to 1, */
  525. /* > If SYM='S' or 'H', and MODE is neither 0, 6, nor -6, then */
  526. /* > the elements of D will also be multiplied by a random */
  527. /* > sign (i.e., +1 or -1.) */
  528. /* > Not modified. */
  529. /* > \endverbatim */
  530. /* > */
  531. /* > \param[in] COND */
  532. /* > \verbatim */
  533. /* > COND is DOUBLE PRECISION */
  534. /* > On entry, this is used as described under MODE above. */
  535. /* > If used, it must be >= 1. Not modified. */
  536. /* > \endverbatim */
  537. /* > */
  538. /* > \param[in] DMAX */
  539. /* > \verbatim */
  540. /* > DMAX is DOUBLE PRECISION */
  541. /* > If MODE is neither -6, 0 nor 6, the contents of D, as */
  542. /* > computed according to MODE and COND, will be scaled by */
  543. /* > DMAX / f2cmax(abs(D(i))); thus, the maximum absolute eigen- or */
  544. /* > singular value (which is to say the norm) will be abs(DMAX). */
  545. /* > Note that DMAX need not be positive: if DMAX is negative */
  546. /* > (or zero), D will be scaled by a negative number (or zero). */
  547. /* > Not modified. */
  548. /* > \endverbatim */
  549. /* > */
  550. /* > \param[in] RANK */
  551. /* > \verbatim */
  552. /* > RANK is INTEGER */
  553. /* > The rank of matrix to be generated for modes 1,2,3 only. */
  554. /* > D( RANK+1:N ) = 0. */
  555. /* > Not modified. */
  556. /* > \endverbatim */
  557. /* > */
  558. /* > \param[in] KL */
  559. /* > \verbatim */
  560. /* > KL is INTEGER */
  561. /* > This specifies the lower bandwidth of the matrix. For */
  562. /* > example, KL=0 implies upper triangular, KL=1 implies upper */
  563. /* > Hessenberg, and KL being at least M-1 means that the matrix */
  564. /* > has full lower bandwidth. KL must equal KU if the matrix */
  565. /* > is symmetric. */
  566. /* > Not modified. */
  567. /* > \endverbatim */
  568. /* > */
  569. /* > \param[in] KU */
  570. /* > \verbatim */
  571. /* > KU is INTEGER */
  572. /* > This specifies the upper bandwidth of the matrix. For */
  573. /* > example, KU=0 implies lower triangular, KU=1 implies lower */
  574. /* > Hessenberg, and KU being at least N-1 means that the matrix */
  575. /* > has full upper bandwidth. KL must equal KU if the matrix */
  576. /* > is symmetric. */
  577. /* > Not modified. */
  578. /* > \endverbatim */
  579. /* > */
  580. /* > \param[in] PACK */
  581. /* > \verbatim */
  582. /* > PACK is CHARACTER*1 */
  583. /* > This specifies packing of matrix as follows: */
  584. /* > 'N' => no packing */
  585. /* > 'U' => zero out all subdiagonal entries (if symmetric) */
  586. /* > 'L' => zero out all superdiagonal entries (if symmetric) */
  587. /* > 'C' => store the upper triangle columnwise */
  588. /* > (only if the matrix is symmetric or upper triangular) */
  589. /* > 'R' => store the lower triangle columnwise */
  590. /* > (only if the matrix is symmetric or lower triangular) */
  591. /* > 'B' => store the lower triangle in band storage scheme */
  592. /* > (only if matrix symmetric or lower triangular) */
  593. /* > 'Q' => store the upper triangle in band storage scheme */
  594. /* > (only if matrix symmetric or upper triangular) */
  595. /* > 'Z' => store the entire matrix in band storage scheme */
  596. /* > (pivoting can be provided for by using this */
  597. /* > option to store A in the trailing rows of */
  598. /* > the allocated storage) */
  599. /* > */
  600. /* > Using these options, the various LAPACK packed and banded */
  601. /* > storage schemes can be obtained: */
  602. /* > GB - use 'Z' */
  603. /* > PB, SB or TB - use 'B' or 'Q' */
  604. /* > PP, SP or TP - use 'C' or 'R' */
  605. /* > */
  606. /* > If two calls to DLATMT differ only in the PACK parameter, */
  607. /* > they will generate mathematically equivalent matrices. */
  608. /* > Not modified. */
  609. /* > \endverbatim */
  610. /* > */
  611. /* > \param[in,out] A */
  612. /* > \verbatim */
  613. /* > A is DOUBLE PRECISION array, dimension ( LDA, N ) */
  614. /* > On exit A is the desired test matrix. A is first generated */
  615. /* > in full (unpacked) form, and then packed, if so specified */
  616. /* > by PACK. Thus, the first M elements of the first N */
  617. /* > columns will always be modified. If PACK specifies a */
  618. /* > packed or banded storage scheme, all LDA elements of the */
  619. /* > first N columns will be modified; the elements of the */
  620. /* > array which do not correspond to elements of the generated */
  621. /* > matrix are set to zero. */
  622. /* > Modified. */
  623. /* > \endverbatim */
  624. /* > */
  625. /* > \param[in] LDA */
  626. /* > \verbatim */
  627. /* > LDA is INTEGER */
  628. /* > LDA specifies the first dimension of A as declared in the */
  629. /* > calling program. If PACK='N', 'U', 'L', 'C', or 'R', then */
  630. /* > LDA must be at least M. If PACK='B' or 'Q', then LDA must */
  631. /* > be at least MIN( KL, M-1) (which is equal to MIN(KU,N-1)). */
  632. /* > If PACK='Z', LDA must be large enough to hold the packed */
  633. /* > array: MIN( KU, N-1) + MIN( KL, M-1) + 1. */
  634. /* > Not modified. */
  635. /* > \endverbatim */
  636. /* > */
  637. /* > \param[out] WORK */
  638. /* > \verbatim */
  639. /* > WORK is DOUBLE PRECISION array, dimension ( 3*MAX( N , M ) ) */
  640. /* > Workspace. */
  641. /* > Modified. */
  642. /* > \endverbatim */
  643. /* > */
  644. /* > \param[out] INFO */
  645. /* > \verbatim */
  646. /* > INFO is INTEGER */
  647. /* > Error code. On exit, INFO will be set to one of the */
  648. /* > following values: */
  649. /* > 0 => normal return */
  650. /* > -1 => M negative or unequal to N and SYM='S', 'H', or 'P' */
  651. /* > -2 => N negative */
  652. /* > -3 => DIST illegal string */
  653. /* > -5 => SYM illegal string */
  654. /* > -7 => MODE not in range -6 to 6 */
  655. /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
  656. /* > -10 => KL negative */
  657. /* > -11 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
  658. /* > -12 => PACK illegal string, or PACK='U' or 'L', and SYM='N'; */
  659. /* > or PACK='C' or 'Q' and SYM='N' and KL is not zero; */
  660. /* > or PACK='R' or 'B' and SYM='N' and KU is not zero; */
  661. /* > or PACK='U', 'L', 'C', 'R', 'B', or 'Q', and M is not */
  662. /* > N. */
  663. /* > -14 => LDA is less than M, or PACK='Z' and LDA is less than */
  664. /* > MIN(KU,N-1) + MIN(KL,M-1) + 1. */
  665. /* > 1 => Error return from DLATM7 */
  666. /* > 2 => Cannot scale to DMAX (f2cmax. sing. value is 0) */
  667. /* > 3 => Error return from DLAGGE or DLAGSY */
  668. /* > \endverbatim */
  669. /* Authors: */
  670. /* ======== */
  671. /* > \author Univ. of Tennessee */
  672. /* > \author Univ. of California Berkeley */
  673. /* > \author Univ. of Colorado Denver */
  674. /* > \author NAG Ltd. */
  675. /* > \date December 2016 */
  676. /* > \ingroup double_matgen */
  677. /* ===================================================================== */
  678. /* Subroutine */ int dlatmt_(integer *m, integer *n, char *dist, integer *
  679. iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
  680. doublereal *dmax__, integer *rank, integer *kl, integer *ku, char *
  681. pack, doublereal *a, integer *lda, doublereal *work, integer *info)
  682. {
  683. /* System generated locals */
  684. integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6;
  685. doublereal d__1, d__2, d__3;
  686. logical L__1;
  687. /* Local variables */
  688. integer ilda, icol;
  689. doublereal temp;
  690. integer irow, isym;
  691. doublereal c__;
  692. integer i__, j, k;
  693. doublereal s, alpha, angle;
  694. integer ipack;
  695. extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
  696. integer *);
  697. integer ioffg;
  698. extern logical lsame_(char *, char *);
  699. integer iinfo, idist, mnmin;
  700. extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *,
  701. doublereal *, integer *);
  702. integer iskew;
  703. doublereal extra, dummy;
  704. extern /* Subroutine */ int dlatm7_(integer *, doublereal *, integer *,
  705. integer *, integer *, doublereal *, integer *, integer *, integer
  706. *);
  707. integer ic, jc, nc;
  708. extern /* Subroutine */ int dlagge_(integer *, integer *, integer *,
  709. integer *, doublereal *, doublereal *, integer *, integer *,
  710. doublereal *, integer *);
  711. integer il, iendch, ir, jr, ipackg, mr, minlda;
  712. extern doublereal dlarnd_(integer *, integer *);
  713. extern /* Subroutine */ int dlaset_(char *, integer *, integer *,
  714. doublereal *, doublereal *, doublereal *, integer *),
  715. dlartg_(doublereal *, doublereal *, doublereal *, doublereal *,
  716. doublereal *), xerbla_(char *, integer *), dlagsy_(
  717. integer *, integer *, doublereal *, doublereal *, integer *,
  718. integer *, doublereal *, integer *), dlarot_(logical *, logical *,
  719. logical *, integer *, doublereal *, doublereal *, doublereal *,
  720. integer *, doublereal *, doublereal *);
  721. integer ioffst, irsign;
  722. logical givens, iltemp, ilextr, topdwn;
  723. integer ir1, ir2, isympk, jch, llb, jkl, jku, uub;
  724. /* -- LAPACK computational routine (version 3.7.0) -- */
  725. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  726. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  727. /* December 2016 */
  728. /* ===================================================================== */
  729. /* 1) Decode and Test the input parameters. */
  730. /* Initialize flags & seed. */
  731. /* Parameter adjustments */
  732. --iseed;
  733. --d__;
  734. a_dim1 = *lda;
  735. a_offset = 1 + a_dim1 * 1;
  736. a -= a_offset;
  737. --work;
  738. /* Function Body */
  739. *info = 0;
  740. /* Quick return if possible */
  741. if (*m == 0 || *n == 0) {
  742. return 0;
  743. }
  744. /* Decode DIST */
  745. if (lsame_(dist, "U")) {
  746. idist = 1;
  747. } else if (lsame_(dist, "S")) {
  748. idist = 2;
  749. } else if (lsame_(dist, "N")) {
  750. idist = 3;
  751. } else {
  752. idist = -1;
  753. }
  754. /* Decode SYM */
  755. if (lsame_(sym, "N")) {
  756. isym = 1;
  757. irsign = 0;
  758. } else if (lsame_(sym, "P")) {
  759. isym = 2;
  760. irsign = 0;
  761. } else if (lsame_(sym, "S")) {
  762. isym = 2;
  763. irsign = 1;
  764. } else if (lsame_(sym, "H")) {
  765. isym = 2;
  766. irsign = 1;
  767. } else {
  768. isym = -1;
  769. }
  770. /* Decode PACK */
  771. isympk = 0;
  772. if (lsame_(pack, "N")) {
  773. ipack = 0;
  774. } else if (lsame_(pack, "U")) {
  775. ipack = 1;
  776. isympk = 1;
  777. } else if (lsame_(pack, "L")) {
  778. ipack = 2;
  779. isympk = 1;
  780. } else if (lsame_(pack, "C")) {
  781. ipack = 3;
  782. isympk = 2;
  783. } else if (lsame_(pack, "R")) {
  784. ipack = 4;
  785. isympk = 3;
  786. } else if (lsame_(pack, "B")) {
  787. ipack = 5;
  788. isympk = 3;
  789. } else if (lsame_(pack, "Q")) {
  790. ipack = 6;
  791. isympk = 2;
  792. } else if (lsame_(pack, "Z")) {
  793. ipack = 7;
  794. } else {
  795. ipack = -1;
  796. }
  797. /* Set certain internal parameters */
  798. mnmin = f2cmin(*m,*n);
  799. /* Computing MIN */
  800. i__1 = *kl, i__2 = *m - 1;
  801. llb = f2cmin(i__1,i__2);
  802. /* Computing MIN */
  803. i__1 = *ku, i__2 = *n - 1;
  804. uub = f2cmin(i__1,i__2);
  805. /* Computing MIN */
  806. i__1 = *m, i__2 = *n + llb;
  807. mr = f2cmin(i__1,i__2);
  808. /* Computing MIN */
  809. i__1 = *n, i__2 = *m + uub;
  810. nc = f2cmin(i__1,i__2);
  811. if (ipack == 5 || ipack == 6) {
  812. minlda = uub + 1;
  813. } else if (ipack == 7) {
  814. minlda = llb + uub + 1;
  815. } else {
  816. minlda = *m;
  817. }
  818. /* Use Givens rotation method if bandwidth small enough, */
  819. /* or if LDA is too small to store the matrix unpacked. */
  820. givens = FALSE_;
  821. if (isym == 1) {
  822. /* Computing MAX */
  823. i__1 = 1, i__2 = mr + nc;
  824. if ((doublereal) (llb + uub) < (doublereal) f2cmax(i__1,i__2) * .3) {
  825. givens = TRUE_;
  826. }
  827. } else {
  828. if (llb << 1 < *m) {
  829. givens = TRUE_;
  830. }
  831. }
  832. if (*lda < *m && *lda >= minlda) {
  833. givens = TRUE_;
  834. }
  835. /* Set INFO if an error */
  836. if (*m < 0) {
  837. *info = -1;
  838. } else if (*m != *n && isym != 1) {
  839. *info = -1;
  840. } else if (*n < 0) {
  841. *info = -2;
  842. } else if (idist == -1) {
  843. *info = -3;
  844. } else if (isym == -1) {
  845. *info = -5;
  846. } else if (abs(*mode) > 6) {
  847. *info = -7;
  848. } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.) {
  849. *info = -8;
  850. } else if (*kl < 0) {
  851. *info = -10;
  852. } else if (*ku < 0 || isym != 1 && *kl != *ku) {
  853. *info = -11;
  854. } else if (ipack == -1 || isympk == 1 && isym == 1 || isympk == 2 && isym
  855. == 1 && *kl > 0 || isympk == 3 && isym == 1 && *ku > 0 || isympk
  856. != 0 && *m != *n) {
  857. *info = -12;
  858. } else if (*lda < f2cmax(1,minlda)) {
  859. *info = -14;
  860. }
  861. if (*info != 0) {
  862. i__1 = -(*info);
  863. xerbla_("DLATMT", &i__1);
  864. return 0;
  865. }
  866. /* Initialize random number generator */
  867. for (i__ = 1; i__ <= 4; ++i__) {
  868. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  869. /* L100: */
  870. }
  871. if (iseed[4] % 2 != 1) {
  872. ++iseed[4];
  873. }
  874. /* 2) Set up D if indicated. */
  875. /* Compute D according to COND and MODE */
  876. dlatm7_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, rank, &
  877. iinfo);
  878. if (iinfo != 0) {
  879. *info = 1;
  880. return 0;
  881. }
  882. /* Choose Top-Down if D is (apparently) increasing, */
  883. /* Bottom-Up if D is (apparently) decreasing. */
  884. if (abs(d__[1]) <= (d__1 = d__[*rank], abs(d__1))) {
  885. topdwn = TRUE_;
  886. } else {
  887. topdwn = FALSE_;
  888. }
  889. if (*mode != 0 && abs(*mode) != 6) {
  890. /* Scale by DMAX */
  891. temp = abs(d__[1]);
  892. i__1 = *rank;
  893. for (i__ = 2; i__ <= i__1; ++i__) {
  894. /* Computing MAX */
  895. d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
  896. temp = f2cmax(d__2,d__3);
  897. /* L110: */
  898. }
  899. if (temp > 0.) {
  900. alpha = *dmax__ / temp;
  901. } else {
  902. *info = 2;
  903. return 0;
  904. }
  905. dscal_(rank, &alpha, &d__[1], &c__1);
  906. }
  907. /* 3) Generate Banded Matrix using Givens rotations. */
  908. /* Also the special case of UUB=LLB=0 */
  909. /* Compute Addressing constants to cover all */
  910. /* storage formats. Whether GE, SY, GB, or SB, */
  911. /* upper or lower triangle or both, */
  912. /* the (i,j)-th element is in */
  913. /* A( i - ISKEW*j + IOFFST, j ) */
  914. if (ipack > 4) {
  915. ilda = *lda - 1;
  916. iskew = 1;
  917. if (ipack > 5) {
  918. ioffst = uub + 1;
  919. } else {
  920. ioffst = 1;
  921. }
  922. } else {
  923. ilda = *lda;
  924. iskew = 0;
  925. ioffst = 0;
  926. }
  927. /* IPACKG is the format that the matrix is generated in. If this is */
  928. /* different from IPACK, then the matrix must be repacked at the */
  929. /* end. It also signals how to compute the norm, for scaling. */
  930. ipackg = 0;
  931. dlaset_("Full", lda, n, &c_b22, &c_b22, &a[a_offset], lda);
  932. /* Diagonal Matrix -- We are done, unless it */
  933. /* is to be stored SP/PP/TP (PACK='R' or 'C') */
  934. if (llb == 0 && uub == 0) {
  935. i__1 = ilda + 1;
  936. dcopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffst + a_dim1], &i__1)
  937. ;
  938. if (ipack <= 2 || ipack >= 5) {
  939. ipackg = ipack;
  940. }
  941. } else if (givens) {
  942. /* Check whether to use Givens rotations, */
  943. /* Householder transformations, or nothing. */
  944. if (isym == 1) {
  945. /* Non-symmetric -- A = U D V */
  946. if (ipack > 4) {
  947. ipackg = ipack;
  948. } else {
  949. ipackg = 0;
  950. }
  951. i__1 = ilda + 1;
  952. dcopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffst + a_dim1], &
  953. i__1);
  954. if (topdwn) {
  955. jkl = 0;
  956. i__1 = uub;
  957. for (jku = 1; jku <= i__1; ++jku) {
  958. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  959. /* Last row actually rotated is M */
  960. /* Last column actually rotated is MIN( M+JKU, N ) */
  961. /* Computing MIN */
  962. i__3 = *m + jku;
  963. i__2 = f2cmin(i__3,*n) + jkl - 1;
  964. for (jr = 1; jr <= i__2; ++jr) {
  965. extra = 0.;
  966. angle = dlarnd_(&c__1, &iseed[1]) *
  967. 6.2831853071795864769252867663;
  968. c__ = cos(angle);
  969. s = sin(angle);
  970. /* Computing MAX */
  971. i__3 = 1, i__4 = jr - jkl;
  972. icol = f2cmax(i__3,i__4);
  973. if (jr < *m) {
  974. /* Computing MIN */
  975. i__3 = *n, i__4 = jr + jku;
  976. il = f2cmin(i__3,i__4) + 1 - icol;
  977. L__1 = jr > jkl;
  978. dlarot_(&c_true, &L__1, &c_false, &il, &c__, &s, &
  979. a[jr - iskew * icol + ioffst + icol *
  980. a_dim1], &ilda, &extra, &dummy);
  981. }
  982. /* Chase "EXTRA" back up */
  983. ir = jr;
  984. ic = icol;
  985. i__3 = -jkl - jku;
  986. for (jch = jr - jkl; i__3 < 0 ? jch >= 1 : jch <= 1;
  987. jch += i__3) {
  988. if (ir < *m) {
  989. dlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  990. + (ic + 1) * a_dim1], &extra, &c__, &
  991. s, &dummy);
  992. }
  993. /* Computing MAX */
  994. i__4 = 1, i__5 = jch - jku;
  995. irow = f2cmax(i__4,i__5);
  996. il = ir + 2 - irow;
  997. temp = 0.;
  998. iltemp = jch > jku;
  999. d__1 = -s;
  1000. dlarot_(&c_false, &iltemp, &c_true, &il, &c__, &
  1001. d__1, &a[irow - iskew * ic + ioffst + ic *
  1002. a_dim1], &ilda, &temp, &extra);
  1003. if (iltemp) {
  1004. dlartg_(&a[irow + 1 - iskew * (ic + 1) +
  1005. ioffst + (ic + 1) * a_dim1], &temp, &
  1006. c__, &s, &dummy);
  1007. /* Computing MAX */
  1008. i__4 = 1, i__5 = jch - jku - jkl;
  1009. icol = f2cmax(i__4,i__5);
  1010. il = ic + 2 - icol;
  1011. extra = 0.;
  1012. L__1 = jch > jku + jkl;
  1013. d__1 = -s;
  1014. dlarot_(&c_true, &L__1, &c_true, &il, &c__, &
  1015. d__1, &a[irow - iskew * icol + ioffst
  1016. + icol * a_dim1], &ilda, &extra, &
  1017. temp);
  1018. ic = icol;
  1019. ir = irow;
  1020. }
  1021. /* L120: */
  1022. }
  1023. /* L130: */
  1024. }
  1025. /* L140: */
  1026. }
  1027. jku = uub;
  1028. i__1 = llb;
  1029. for (jkl = 1; jkl <= i__1; ++jkl) {
  1030. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1031. /* Computing MIN */
  1032. i__3 = *n + jkl;
  1033. i__2 = f2cmin(i__3,*m) + jku - 1;
  1034. for (jc = 1; jc <= i__2; ++jc) {
  1035. extra = 0.;
  1036. angle = dlarnd_(&c__1, &iseed[1]) *
  1037. 6.2831853071795864769252867663;
  1038. c__ = cos(angle);
  1039. s = sin(angle);
  1040. /* Computing MAX */
  1041. i__3 = 1, i__4 = jc - jku;
  1042. irow = f2cmax(i__3,i__4);
  1043. if (jc < *n) {
  1044. /* Computing MIN */
  1045. i__3 = *m, i__4 = jc + jkl;
  1046. il = f2cmin(i__3,i__4) + 1 - irow;
  1047. L__1 = jc > jku;
  1048. dlarot_(&c_false, &L__1, &c_false, &il, &c__, &s,
  1049. &a[irow - iskew * jc + ioffst + jc *
  1050. a_dim1], &ilda, &extra, &dummy);
  1051. }
  1052. /* Chase "EXTRA" back up */
  1053. ic = jc;
  1054. ir = irow;
  1055. i__3 = -jkl - jku;
  1056. for (jch = jc - jku; i__3 < 0 ? jch >= 1 : jch <= 1;
  1057. jch += i__3) {
  1058. if (ic < *n) {
  1059. dlartg_(&a[ir + 1 - iskew * (ic + 1) + ioffst
  1060. + (ic + 1) * a_dim1], &extra, &c__, &
  1061. s, &dummy);
  1062. }
  1063. /* Computing MAX */
  1064. i__4 = 1, i__5 = jch - jkl;
  1065. icol = f2cmax(i__4,i__5);
  1066. il = ic + 2 - icol;
  1067. temp = 0.;
  1068. iltemp = jch > jkl;
  1069. d__1 = -s;
  1070. dlarot_(&c_true, &iltemp, &c_true, &il, &c__, &
  1071. d__1, &a[ir - iskew * icol + ioffst +
  1072. icol * a_dim1], &ilda, &temp, &extra);
  1073. if (iltemp) {
  1074. dlartg_(&a[ir + 1 - iskew * (icol + 1) +
  1075. ioffst + (icol + 1) * a_dim1], &temp,
  1076. &c__, &s, &dummy);
  1077. /* Computing MAX */
  1078. i__4 = 1, i__5 = jch - jkl - jku;
  1079. irow = f2cmax(i__4,i__5);
  1080. il = ir + 2 - irow;
  1081. extra = 0.;
  1082. L__1 = jch > jkl + jku;
  1083. d__1 = -s;
  1084. dlarot_(&c_false, &L__1, &c_true, &il, &c__, &
  1085. d__1, &a[irow - iskew * icol + ioffst
  1086. + icol * a_dim1], &ilda, &extra, &
  1087. temp);
  1088. ic = icol;
  1089. ir = irow;
  1090. }
  1091. /* L150: */
  1092. }
  1093. /* L160: */
  1094. }
  1095. /* L170: */
  1096. }
  1097. } else {
  1098. /* Bottom-Up -- Start at the bottom right. */
  1099. jkl = 0;
  1100. i__1 = uub;
  1101. for (jku = 1; jku <= i__1; ++jku) {
  1102. /* Transform from bandwidth JKL, JKU-1 to JKL, JKU */
  1103. /* First row actually rotated is M */
  1104. /* First column actually rotated is MIN( M+JKU, N ) */
  1105. /* Computing MIN */
  1106. i__2 = *m, i__3 = *n + jkl;
  1107. iendch = f2cmin(i__2,i__3) - 1;
  1108. /* Computing MIN */
  1109. i__2 = *m + jku;
  1110. i__3 = 1 - jkl;
  1111. for (jc = f2cmin(i__2,*n) - 1; jc >= i__3; --jc) {
  1112. extra = 0.;
  1113. angle = dlarnd_(&c__1, &iseed[1]) *
  1114. 6.2831853071795864769252867663;
  1115. c__ = cos(angle);
  1116. s = sin(angle);
  1117. /* Computing MAX */
  1118. i__2 = 1, i__4 = jc - jku + 1;
  1119. irow = f2cmax(i__2,i__4);
  1120. if (jc > 0) {
  1121. /* Computing MIN */
  1122. i__2 = *m, i__4 = jc + jkl + 1;
  1123. il = f2cmin(i__2,i__4) + 1 - irow;
  1124. L__1 = jc + jkl < *m;
  1125. dlarot_(&c_false, &c_false, &L__1, &il, &c__, &s,
  1126. &a[irow - iskew * jc + ioffst + jc *
  1127. a_dim1], &ilda, &dummy, &extra);
  1128. }
  1129. /* Chase "EXTRA" back down */
  1130. ic = jc;
  1131. i__2 = iendch;
  1132. i__4 = jkl + jku;
  1133. for (jch = jc + jkl; i__4 < 0 ? jch >= i__2 : jch <=
  1134. i__2; jch += i__4) {
  1135. ilextr = ic > 0;
  1136. if (ilextr) {
  1137. dlartg_(&a[jch - iskew * ic + ioffst + ic *
  1138. a_dim1], &extra, &c__, &s, &dummy);
  1139. }
  1140. ic = f2cmax(1,ic);
  1141. /* Computing MIN */
  1142. i__5 = *n - 1, i__6 = jch + jku;
  1143. icol = f2cmin(i__5,i__6);
  1144. iltemp = jch + jku < *n;
  1145. temp = 0.;
  1146. i__5 = icol + 2 - ic;
  1147. dlarot_(&c_true, &ilextr, &iltemp, &i__5, &c__, &
  1148. s, &a[jch - iskew * ic + ioffst + ic *
  1149. a_dim1], &ilda, &extra, &temp);
  1150. if (iltemp) {
  1151. dlartg_(&a[jch - iskew * icol + ioffst + icol
  1152. * a_dim1], &temp, &c__, &s, &dummy);
  1153. /* Computing MIN */
  1154. i__5 = iendch, i__6 = jch + jkl + jku;
  1155. il = f2cmin(i__5,i__6) + 2 - jch;
  1156. extra = 0.;
  1157. L__1 = jch + jkl + jku <= iendch;
  1158. dlarot_(&c_false, &c_true, &L__1, &il, &c__, &
  1159. s, &a[jch - iskew * icol + ioffst +
  1160. icol * a_dim1], &ilda, &temp, &extra);
  1161. ic = icol;
  1162. }
  1163. /* L180: */
  1164. }
  1165. /* L190: */
  1166. }
  1167. /* L200: */
  1168. }
  1169. jku = uub;
  1170. i__1 = llb;
  1171. for (jkl = 1; jkl <= i__1; ++jkl) {
  1172. /* Transform from bandwidth JKL-1, JKU to JKL, JKU */
  1173. /* First row actually rotated is MIN( N+JKL, M ) */
  1174. /* First column actually rotated is N */
  1175. /* Computing MIN */
  1176. i__3 = *n, i__4 = *m + jku;
  1177. iendch = f2cmin(i__3,i__4) - 1;
  1178. /* Computing MIN */
  1179. i__3 = *n + jkl;
  1180. i__4 = 1 - jku;
  1181. for (jr = f2cmin(i__3,*m) - 1; jr >= i__4; --jr) {
  1182. extra = 0.;
  1183. angle = dlarnd_(&c__1, &iseed[1]) *
  1184. 6.2831853071795864769252867663;
  1185. c__ = cos(angle);
  1186. s = sin(angle);
  1187. /* Computing MAX */
  1188. i__3 = 1, i__2 = jr - jkl + 1;
  1189. icol = f2cmax(i__3,i__2);
  1190. if (jr > 0) {
  1191. /* Computing MIN */
  1192. i__3 = *n, i__2 = jr + jku + 1;
  1193. il = f2cmin(i__3,i__2) + 1 - icol;
  1194. L__1 = jr + jku < *n;
  1195. dlarot_(&c_true, &c_false, &L__1, &il, &c__, &s, &
  1196. a[jr - iskew * icol + ioffst + icol *
  1197. a_dim1], &ilda, &dummy, &extra);
  1198. }
  1199. /* Chase "EXTRA" back down */
  1200. ir = jr;
  1201. i__3 = iendch;
  1202. i__2 = jkl + jku;
  1203. for (jch = jr + jku; i__2 < 0 ? jch >= i__3 : jch <=
  1204. i__3; jch += i__2) {
  1205. ilextr = ir > 0;
  1206. if (ilextr) {
  1207. dlartg_(&a[ir - iskew * jch + ioffst + jch *
  1208. a_dim1], &extra, &c__, &s, &dummy);
  1209. }
  1210. ir = f2cmax(1,ir);
  1211. /* Computing MIN */
  1212. i__5 = *m - 1, i__6 = jch + jkl;
  1213. irow = f2cmin(i__5,i__6);
  1214. iltemp = jch + jkl < *m;
  1215. temp = 0.;
  1216. i__5 = irow + 2 - ir;
  1217. dlarot_(&c_false, &ilextr, &iltemp, &i__5, &c__, &
  1218. s, &a[ir - iskew * jch + ioffst + jch *
  1219. a_dim1], &ilda, &extra, &temp);
  1220. if (iltemp) {
  1221. dlartg_(&a[irow - iskew * jch + ioffst + jch *
  1222. a_dim1], &temp, &c__, &s, &dummy);
  1223. /* Computing MIN */
  1224. i__5 = iendch, i__6 = jch + jkl + jku;
  1225. il = f2cmin(i__5,i__6) + 2 - jch;
  1226. extra = 0.;
  1227. L__1 = jch + jkl + jku <= iendch;
  1228. dlarot_(&c_true, &c_true, &L__1, &il, &c__, &
  1229. s, &a[irow - iskew * jch + ioffst +
  1230. jch * a_dim1], &ilda, &temp, &extra);
  1231. ir = irow;
  1232. }
  1233. /* L210: */
  1234. }
  1235. /* L220: */
  1236. }
  1237. /* L230: */
  1238. }
  1239. }
  1240. } else {
  1241. /* Symmetric -- A = U D U' */
  1242. ipackg = ipack;
  1243. ioffg = ioffst;
  1244. if (topdwn) {
  1245. /* Top-Down -- Generate Upper triangle only */
  1246. if (ipack >= 5) {
  1247. ipackg = 6;
  1248. ioffg = uub + 1;
  1249. } else {
  1250. ipackg = 1;
  1251. }
  1252. i__1 = ilda + 1;
  1253. dcopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffg + a_dim1],
  1254. &i__1);
  1255. i__1 = uub;
  1256. for (k = 1; k <= i__1; ++k) {
  1257. i__4 = *n - 1;
  1258. for (jc = 1; jc <= i__4; ++jc) {
  1259. /* Computing MAX */
  1260. i__2 = 1, i__3 = jc - k;
  1261. irow = f2cmax(i__2,i__3);
  1262. /* Computing MIN */
  1263. i__2 = jc + 1, i__3 = k + 2;
  1264. il = f2cmin(i__2,i__3);
  1265. extra = 0.;
  1266. temp = a[jc - iskew * (jc + 1) + ioffg + (jc + 1) *
  1267. a_dim1];
  1268. angle = dlarnd_(&c__1, &iseed[1]) *
  1269. 6.2831853071795864769252867663;
  1270. c__ = cos(angle);
  1271. s = sin(angle);
  1272. L__1 = jc > k;
  1273. dlarot_(&c_false, &L__1, &c_true, &il, &c__, &s, &a[
  1274. irow - iskew * jc + ioffg + jc * a_dim1], &
  1275. ilda, &extra, &temp);
  1276. /* Computing MIN */
  1277. i__3 = k, i__5 = *n - jc;
  1278. i__2 = f2cmin(i__3,i__5) + 1;
  1279. dlarot_(&c_true, &c_true, &c_false, &i__2, &c__, &s, &
  1280. a[(1 - iskew) * jc + ioffg + jc * a_dim1], &
  1281. ilda, &temp, &dummy);
  1282. /* Chase EXTRA back up the matrix */
  1283. icol = jc;
  1284. i__2 = -k;
  1285. for (jch = jc - k; i__2 < 0 ? jch >= 1 : jch <= 1;
  1286. jch += i__2) {
  1287. dlartg_(&a[jch + 1 - iskew * (icol + 1) + ioffg +
  1288. (icol + 1) * a_dim1], &extra, &c__, &s, &
  1289. dummy);
  1290. temp = a[jch - iskew * (jch + 1) + ioffg + (jch +
  1291. 1) * a_dim1];
  1292. i__3 = k + 2;
  1293. d__1 = -s;
  1294. dlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1295. d__1, &a[(1 - iskew) * jch + ioffg + jch *
  1296. a_dim1], &ilda, &temp, &extra);
  1297. /* Computing MAX */
  1298. i__3 = 1, i__5 = jch - k;
  1299. irow = f2cmax(i__3,i__5);
  1300. /* Computing MIN */
  1301. i__3 = jch + 1, i__5 = k + 2;
  1302. il = f2cmin(i__3,i__5);
  1303. extra = 0.;
  1304. L__1 = jch > k;
  1305. d__1 = -s;
  1306. dlarot_(&c_false, &L__1, &c_true, &il, &c__, &
  1307. d__1, &a[irow - iskew * jch + ioffg + jch
  1308. * a_dim1], &ilda, &extra, &temp);
  1309. icol = jch;
  1310. /* L240: */
  1311. }
  1312. /* L250: */
  1313. }
  1314. /* L260: */
  1315. }
  1316. /* If we need lower triangle, copy from upper. Note that */
  1317. /* the order of copying is chosen to work for 'q' -> 'b' */
  1318. if (ipack != ipackg && ipack != 3) {
  1319. i__1 = *n;
  1320. for (jc = 1; jc <= i__1; ++jc) {
  1321. irow = ioffst - iskew * jc;
  1322. /* Computing MIN */
  1323. i__2 = *n, i__3 = jc + uub;
  1324. i__4 = f2cmin(i__2,i__3);
  1325. for (jr = jc; jr <= i__4; ++jr) {
  1326. a[jr + irow + jc * a_dim1] = a[jc - iskew * jr +
  1327. ioffg + jr * a_dim1];
  1328. /* L270: */
  1329. }
  1330. /* L280: */
  1331. }
  1332. if (ipack == 5) {
  1333. i__1 = *n;
  1334. for (jc = *n - uub + 1; jc <= i__1; ++jc) {
  1335. i__4 = uub + 1;
  1336. for (jr = *n + 2 - jc; jr <= i__4; ++jr) {
  1337. a[jr + jc * a_dim1] = 0.;
  1338. /* L290: */
  1339. }
  1340. /* L300: */
  1341. }
  1342. }
  1343. if (ipackg == 6) {
  1344. ipackg = ipack;
  1345. } else {
  1346. ipackg = 0;
  1347. }
  1348. }
  1349. } else {
  1350. /* Bottom-Up -- Generate Lower triangle only */
  1351. if (ipack >= 5) {
  1352. ipackg = 5;
  1353. if (ipack == 6) {
  1354. ioffg = 1;
  1355. }
  1356. } else {
  1357. ipackg = 2;
  1358. }
  1359. i__1 = ilda + 1;
  1360. dcopy_(&mnmin, &d__[1], &c__1, &a[1 - iskew + ioffg + a_dim1],
  1361. &i__1);
  1362. i__1 = uub;
  1363. for (k = 1; k <= i__1; ++k) {
  1364. for (jc = *n - 1; jc >= 1; --jc) {
  1365. /* Computing MIN */
  1366. i__4 = *n + 1 - jc, i__2 = k + 2;
  1367. il = f2cmin(i__4,i__2);
  1368. extra = 0.;
  1369. temp = a[(1 - iskew) * jc + 1 + ioffg + jc * a_dim1];
  1370. angle = dlarnd_(&c__1, &iseed[1]) *
  1371. 6.2831853071795864769252867663;
  1372. c__ = cos(angle);
  1373. s = -sin(angle);
  1374. L__1 = *n - jc > k;
  1375. dlarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &a[(
  1376. 1 - iskew) * jc + ioffg + jc * a_dim1], &ilda,
  1377. &temp, &extra);
  1378. /* Computing MAX */
  1379. i__4 = 1, i__2 = jc - k + 1;
  1380. icol = f2cmax(i__4,i__2);
  1381. i__4 = jc + 2 - icol;
  1382. dlarot_(&c_true, &c_false, &c_true, &i__4, &c__, &s, &
  1383. a[jc - iskew * icol + ioffg + icol * a_dim1],
  1384. &ilda, &dummy, &temp);
  1385. /* Chase EXTRA back down the matrix */
  1386. icol = jc;
  1387. i__4 = *n - 1;
  1388. i__2 = k;
  1389. for (jch = jc + k; i__2 < 0 ? jch >= i__4 : jch <=
  1390. i__4; jch += i__2) {
  1391. dlartg_(&a[jch - iskew * icol + ioffg + icol *
  1392. a_dim1], &extra, &c__, &s, &dummy);
  1393. temp = a[(1 - iskew) * jch + 1 + ioffg + jch *
  1394. a_dim1];
  1395. i__3 = k + 2;
  1396. dlarot_(&c_true, &c_true, &c_true, &i__3, &c__, &
  1397. s, &a[jch - iskew * icol + ioffg + icol *
  1398. a_dim1], &ilda, &extra, &temp);
  1399. /* Computing MIN */
  1400. i__3 = *n + 1 - jch, i__5 = k + 2;
  1401. il = f2cmin(i__3,i__5);
  1402. extra = 0.;
  1403. L__1 = *n - jch > k;
  1404. dlarot_(&c_false, &c_true, &L__1, &il, &c__, &s, &
  1405. a[(1 - iskew) * jch + ioffg + jch *
  1406. a_dim1], &ilda, &temp, &extra);
  1407. icol = jch;
  1408. /* L310: */
  1409. }
  1410. /* L320: */
  1411. }
  1412. /* L330: */
  1413. }
  1414. /* If we need upper triangle, copy from lower. Note that */
  1415. /* the order of copying is chosen to work for 'b' -> 'q' */
  1416. if (ipack != ipackg && ipack != 4) {
  1417. for (jc = *n; jc >= 1; --jc) {
  1418. irow = ioffst - iskew * jc;
  1419. /* Computing MAX */
  1420. i__2 = 1, i__4 = jc - uub;
  1421. i__1 = f2cmax(i__2,i__4);
  1422. for (jr = jc; jr >= i__1; --jr) {
  1423. a[jr + irow + jc * a_dim1] = a[jc - iskew * jr +
  1424. ioffg + jr * a_dim1];
  1425. /* L340: */
  1426. }
  1427. /* L350: */
  1428. }
  1429. if (ipack == 6) {
  1430. i__1 = uub;
  1431. for (jc = 1; jc <= i__1; ++jc) {
  1432. i__2 = uub + 1 - jc;
  1433. for (jr = 1; jr <= i__2; ++jr) {
  1434. a[jr + jc * a_dim1] = 0.;
  1435. /* L360: */
  1436. }
  1437. /* L370: */
  1438. }
  1439. }
  1440. if (ipackg == 5) {
  1441. ipackg = ipack;
  1442. } else {
  1443. ipackg = 0;
  1444. }
  1445. }
  1446. }
  1447. }
  1448. } else {
  1449. /* 4) Generate Banded Matrix by first */
  1450. /* Rotating by random Unitary matrices, */
  1451. /* then reducing the bandwidth using Householder */
  1452. /* transformations. */
  1453. /* Note: we should get here only if LDA .ge. N */
  1454. if (isym == 1) {
  1455. /* Non-symmetric -- A = U D V */
  1456. dlagge_(&mr, &nc, &llb, &uub, &d__[1], &a[a_offset], lda, &iseed[
  1457. 1], &work[1], &iinfo);
  1458. } else {
  1459. /* Symmetric -- A = U D U' */
  1460. dlagsy_(m, &llb, &d__[1], &a[a_offset], lda, &iseed[1], &work[1],
  1461. &iinfo);
  1462. }
  1463. if (iinfo != 0) {
  1464. *info = 3;
  1465. return 0;
  1466. }
  1467. }
  1468. /* 5) Pack the matrix */
  1469. if (ipack != ipackg) {
  1470. if (ipack == 1) {
  1471. /* 'U' -- Upper triangular, not packed */
  1472. i__1 = *m;
  1473. for (j = 1; j <= i__1; ++j) {
  1474. i__2 = *m;
  1475. for (i__ = j + 1; i__ <= i__2; ++i__) {
  1476. a[i__ + j * a_dim1] = 0.;
  1477. /* L380: */
  1478. }
  1479. /* L390: */
  1480. }
  1481. } else if (ipack == 2) {
  1482. /* 'L' -- Lower triangular, not packed */
  1483. i__1 = *m;
  1484. for (j = 2; j <= i__1; ++j) {
  1485. i__2 = j - 1;
  1486. for (i__ = 1; i__ <= i__2; ++i__) {
  1487. a[i__ + j * a_dim1] = 0.;
  1488. /* L400: */
  1489. }
  1490. /* L410: */
  1491. }
  1492. } else if (ipack == 3) {
  1493. /* 'C' -- Upper triangle packed Columnwise. */
  1494. icol = 1;
  1495. irow = 0;
  1496. i__1 = *m;
  1497. for (j = 1; j <= i__1; ++j) {
  1498. i__2 = j;
  1499. for (i__ = 1; i__ <= i__2; ++i__) {
  1500. ++irow;
  1501. if (irow > *lda) {
  1502. irow = 1;
  1503. ++icol;
  1504. }
  1505. a[irow + icol * a_dim1] = a[i__ + j * a_dim1];
  1506. /* L420: */
  1507. }
  1508. /* L430: */
  1509. }
  1510. } else if (ipack == 4) {
  1511. /* 'R' -- Lower triangle packed Columnwise. */
  1512. icol = 1;
  1513. irow = 0;
  1514. i__1 = *m;
  1515. for (j = 1; j <= i__1; ++j) {
  1516. i__2 = *m;
  1517. for (i__ = j; i__ <= i__2; ++i__) {
  1518. ++irow;
  1519. if (irow > *lda) {
  1520. irow = 1;
  1521. ++icol;
  1522. }
  1523. a[irow + icol * a_dim1] = a[i__ + j * a_dim1];
  1524. /* L440: */
  1525. }
  1526. /* L450: */
  1527. }
  1528. } else if (ipack >= 5) {
  1529. /* 'B' -- The lower triangle is packed as a band matrix. */
  1530. /* 'Q' -- The upper triangle is packed as a band matrix. */
  1531. /* 'Z' -- The whole matrix is packed as a band matrix. */
  1532. if (ipack == 5) {
  1533. uub = 0;
  1534. }
  1535. if (ipack == 6) {
  1536. llb = 0;
  1537. }
  1538. i__1 = uub;
  1539. for (j = 1; j <= i__1; ++j) {
  1540. /* Computing MIN */
  1541. i__2 = j + llb;
  1542. for (i__ = f2cmin(i__2,*m); i__ >= 1; --i__) {
  1543. a[i__ - j + uub + 1 + j * a_dim1] = a[i__ + j * a_dim1];
  1544. /* L460: */
  1545. }
  1546. /* L470: */
  1547. }
  1548. i__1 = *n;
  1549. for (j = uub + 2; j <= i__1; ++j) {
  1550. /* Computing MIN */
  1551. i__4 = j + llb;
  1552. i__2 = f2cmin(i__4,*m);
  1553. for (i__ = j - uub; i__ <= i__2; ++i__) {
  1554. a[i__ - j + uub + 1 + j * a_dim1] = a[i__ + j * a_dim1];
  1555. /* L480: */
  1556. }
  1557. /* L490: */
  1558. }
  1559. }
  1560. /* If packed, zero out extraneous elements. */
  1561. /* Symmetric/Triangular Packed -- */
  1562. /* zero out everything after A(IROW,ICOL) */
  1563. if (ipack == 3 || ipack == 4) {
  1564. i__1 = *m;
  1565. for (jc = icol; jc <= i__1; ++jc) {
  1566. i__2 = *lda;
  1567. for (jr = irow + 1; jr <= i__2; ++jr) {
  1568. a[jr + jc * a_dim1] = 0.;
  1569. /* L500: */
  1570. }
  1571. irow = 0;
  1572. /* L510: */
  1573. }
  1574. } else if (ipack >= 5) {
  1575. /* Packed Band -- */
  1576. /* 1st row is now in A( UUB+2-j, j), zero above it */
  1577. /* m-th row is now in A( M+UUB-j,j), zero below it */
  1578. /* last non-zero diagonal is now in A( UUB+LLB+1,j ), */
  1579. /* zero below it, too. */
  1580. ir1 = uub + llb + 2;
  1581. ir2 = uub + *m + 2;
  1582. i__1 = *n;
  1583. for (jc = 1; jc <= i__1; ++jc) {
  1584. i__2 = uub + 1 - jc;
  1585. for (jr = 1; jr <= i__2; ++jr) {
  1586. a[jr + jc * a_dim1] = 0.;
  1587. /* L520: */
  1588. }
  1589. /* Computing MAX */
  1590. /* Computing MIN */
  1591. i__3 = ir1, i__5 = ir2 - jc;
  1592. i__2 = 1, i__4 = f2cmin(i__3,i__5);
  1593. i__6 = *lda;
  1594. for (jr = f2cmax(i__2,i__4); jr <= i__6; ++jr) {
  1595. a[jr + jc * a_dim1] = 0.;
  1596. /* L530: */
  1597. }
  1598. /* L540: */
  1599. }
  1600. }
  1601. }
  1602. return 0;
  1603. /* End of DLATMT */
  1604. } /* dlatmt_ */