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