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.

dlatms.c 51 kB

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