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.

zlatmr.c 58 kB

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