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.

clatmr.c 58 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856
  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]/df(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 CLATMR */
  244. /* =========== DOCUMENTATION =========== */
  245. /* Online html documentation available at */
  246. /* http://www.netlib.org/lapack/explore-html/ */
  247. /* Definition: */
  248. /* =========== */
  249. /* SUBROUTINE CLATMR( 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. /* REAL ANORM, COND, CONDL, CONDR, SPARSE */
  256. /* COMPLEX DMAX */
  257. /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
  258. /* COMPLEX A( LDA, * ), D( * ), DL( * ), DR( * ) */
  259. /* > \par Purpose: */
  260. /* ============= */
  261. /* > */
  262. /* > \verbatim */
  263. /* > */
  264. /* > CLATMR generates random matrices of various types for testing */
  265. /* > LAPACK programs. */
  266. /* > */
  267. /* > CLATMR 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 CLATMR differ only in the PACK parameter, */
  311. /* > they will generate mathematically equivalent matrices. */
  312. /* > */
  313. /* > If two calls to CLATMR 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 CLATMR */
  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 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 REAL */
  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 */
  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 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 REAL */
  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 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 REAL */
  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 CLATMR 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, CLATMR */
  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 REAL */
  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 REAL */
  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 CLATMR 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 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 CLATM1 (computing D) */
  697. /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
  698. /* > 3 => Error return from CLATM1 (computing DL) */
  699. /* > 4 => Error return from CLATM1 (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 complex_matgen */
  711. /* ===================================================================== */
  712. /* Subroutine */ void clatmr_(integer *m, integer *n, char *dist, integer *
  713. iseed, char *sym, complex *d__, integer *mode, real *cond, complex *
  714. dmax__, char *rsign, char *grade, complex *dl, integer *model, real *
  715. condl, complex *dr, integer *moder, real *condr, char *pivtng,
  716. integer *ipivot, integer *kl, integer *ku, real *sparse, real *anorm,
  717. char *pack, complex *a, integer *lda, integer *iwork, integer *info)
  718. {
  719. /* System generated locals */
  720. integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
  721. real r__1, r__2;
  722. complex q__1, q__2;
  723. /* Local variables */
  724. integer isub, jsub;
  725. real temp;
  726. integer isym, i__, j, k, ipack;
  727. extern logical lsame_(char *, char *);
  728. real tempa[1];
  729. complex ctemp;
  730. integer iisub, idist, jjsub, mnmin;
  731. logical dzero;
  732. integer mnsub;
  733. real onorm;
  734. integer mxsub, npvts;
  735. extern /* Subroutine */ void clatm1_(integer *, real *, integer *, integer
  736. *, integer *, complex *, integer *, integer *);
  737. extern /* Complex */ VOID clatm2_(complex *, integer *, integer *,
  738. integer *, integer *, integer *, integer *, integer *, integer *,
  739. complex *, integer *, complex *, complex *, integer *, integer *,
  740. real *), clatm3_(complex *, integer *, integer *, integer *,
  741. integer *, integer *, integer *, integer *, integer *, integer *,
  742. integer *, complex *, integer *, complex *, complex *, integer *,
  743. integer *, real *);
  744. complex calpha;
  745. extern real clangb_(char *, integer *, integer *, integer *, complex *,
  746. integer *, real *), clange_(char *, integer *, integer *,
  747. complex *, integer *, real *);
  748. integer igrade;
  749. extern real clansb_(char *, char *, integer *, integer *, complex *,
  750. integer *, real *);
  751. extern /* Subroutine */ void csscal_(integer *, real *, complex *, integer
  752. *);
  753. logical fulbnd;
  754. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  755. logical badpvt;
  756. extern real clansp_(char *, char *, integer *, complex *, real *), clansy_(char *, char *, integer *, complex *, integer *,
  757. real *);
  758. integer irsign, ipvtng, kll, kuu;
  759. /* -- LAPACK computational routine (version 3.7.0) -- */
  760. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  761. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  762. /* December 2016 */
  763. /* ===================================================================== */
  764. /* 1) Decode and Test the input parameters. */
  765. /* Initialize flags & seed. */
  766. /* Parameter adjustments */
  767. --iseed;
  768. --d__;
  769. --dl;
  770. --dr;
  771. --ipivot;
  772. a_dim1 = *lda;
  773. a_offset = 1 + a_dim1 * 1;
  774. a -= a_offset;
  775. --iwork;
  776. /* Function Body */
  777. *info = 0;
  778. /* Quick return if possible */
  779. if (*m == 0 || *n == 0) {
  780. return;
  781. }
  782. /* Decode DIST */
  783. if (lsame_(dist, "U")) {
  784. idist = 1;
  785. } else if (lsame_(dist, "S")) {
  786. idist = 2;
  787. } else if (lsame_(dist, "N")) {
  788. idist = 3;
  789. } else if (lsame_(dist, "D")) {
  790. idist = 4;
  791. } else {
  792. idist = -1;
  793. }
  794. /* Decode SYM */
  795. if (lsame_(sym, "H")) {
  796. isym = 0;
  797. } else if (lsame_(sym, "N")) {
  798. isym = 1;
  799. } else if (lsame_(sym, "S")) {
  800. isym = 2;
  801. } else {
  802. isym = -1;
  803. }
  804. /* Decode RSIGN */
  805. if (lsame_(rsign, "F")) {
  806. irsign = 0;
  807. } else if (lsame_(rsign, "T")) {
  808. irsign = 1;
  809. } else {
  810. irsign = -1;
  811. }
  812. /* Decode PIVTNG */
  813. if (lsame_(pivtng, "N")) {
  814. ipvtng = 0;
  815. } else if (lsame_(pivtng, " ")) {
  816. ipvtng = 0;
  817. } else if (lsame_(pivtng, "L")) {
  818. ipvtng = 1;
  819. npvts = *m;
  820. } else if (lsame_(pivtng, "R")) {
  821. ipvtng = 2;
  822. npvts = *n;
  823. } else if (lsame_(pivtng, "B")) {
  824. ipvtng = 3;
  825. npvts = f2cmin(*n,*m);
  826. } else if (lsame_(pivtng, "F")) {
  827. ipvtng = 3;
  828. npvts = f2cmin(*n,*m);
  829. } else {
  830. ipvtng = -1;
  831. }
  832. /* Decode GRADE */
  833. if (lsame_(grade, "N")) {
  834. igrade = 0;
  835. } else if (lsame_(grade, "L")) {
  836. igrade = 1;
  837. } else if (lsame_(grade, "R")) {
  838. igrade = 2;
  839. } else if (lsame_(grade, "B")) {
  840. igrade = 3;
  841. } else if (lsame_(grade, "E")) {
  842. igrade = 4;
  843. } else if (lsame_(grade, "H")) {
  844. igrade = 5;
  845. } else if (lsame_(grade, "S")) {
  846. igrade = 6;
  847. } else {
  848. igrade = -1;
  849. }
  850. /* Decode PACK */
  851. if (lsame_(pack, "N")) {
  852. ipack = 0;
  853. } else if (lsame_(pack, "U")) {
  854. ipack = 1;
  855. } else if (lsame_(pack, "L")) {
  856. ipack = 2;
  857. } else if (lsame_(pack, "C")) {
  858. ipack = 3;
  859. } else if (lsame_(pack, "R")) {
  860. ipack = 4;
  861. } else if (lsame_(pack, "B")) {
  862. ipack = 5;
  863. } else if (lsame_(pack, "Q")) {
  864. ipack = 6;
  865. } else if (lsame_(pack, "Z")) {
  866. ipack = 7;
  867. } else {
  868. ipack = -1;
  869. }
  870. /* Set certain internal parameters */
  871. mnmin = f2cmin(*m,*n);
  872. /* Computing MIN */
  873. i__1 = *kl, i__2 = *m - 1;
  874. kll = f2cmin(i__1,i__2);
  875. /* Computing MIN */
  876. i__1 = *ku, i__2 = *n - 1;
  877. kuu = f2cmin(i__1,i__2);
  878. /* If inv(DL) is used, check to see if DL has a zero entry. */
  879. dzero = FALSE_;
  880. if (igrade == 4 && *model == 0) {
  881. i__1 = *m;
  882. for (i__ = 1; i__ <= i__1; ++i__) {
  883. i__2 = i__;
  884. if (dl[i__2].r == 0.f && dl[i__2].i == 0.f) {
  885. dzero = TRUE_;
  886. }
  887. /* L10: */
  888. }
  889. }
  890. /* Check values in IPIVOT */
  891. badpvt = FALSE_;
  892. if (ipvtng > 0) {
  893. i__1 = npvts;
  894. for (j = 1; j <= i__1; ++j) {
  895. if (ipivot[j] <= 0 || ipivot[j] > npvts) {
  896. badpvt = TRUE_;
  897. }
  898. /* L20: */
  899. }
  900. }
  901. /* Set INFO if an error */
  902. if (*m < 0) {
  903. *info = -1;
  904. } else if (*m != *n && (isym == 0 || isym == 2)) {
  905. *info = -1;
  906. } else if (*n < 0) {
  907. *info = -2;
  908. } else if (idist == -1) {
  909. *info = -3;
  910. } else if (isym == -1) {
  911. *info = -5;
  912. } else if (*mode < -6 || *mode > 6) {
  913. *info = -7;
  914. } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.f) {
  915. *info = -8;
  916. } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
  917. *info = -10;
  918. } else if (igrade == -1 || igrade == 4 && *m != *n || (igrade == 1 ||
  919. igrade == 2 || igrade == 3 || igrade == 4 || igrade == 6) && isym
  920. == 0 || (igrade == 1 || igrade == 2 || igrade == 3 || igrade == 4
  921. || igrade == 5) && isym == 2) {
  922. *info = -11;
  923. } else if (igrade == 4 && dzero) {
  924. *info = -12;
  925. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
  926. igrade == 6) && (*model < -6 || *model > 6)) {
  927. *info = -13;
  928. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
  929. igrade == 6) && (*model != -6 && *model != 0 && *model != 6) && *
  930. condl < 1.f) {
  931. *info = -14;
  932. } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
  933. *info = -16;
  934. } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
  935. *moder != 6) && *condr < 1.f) {
  936. *info = -17;
  937. } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
  938. ipvtng == 2) && (isym == 0 || isym == 2)) {
  939. *info = -18;
  940. } else if (ipvtng != 0 && badpvt) {
  941. *info = -19;
  942. } else if (*kl < 0) {
  943. *info = -20;
  944. } else if (*ku < 0 || (isym == 0 || isym == 2) && *kl != *ku) {
  945. *info = -21;
  946. } else if (*sparse < 0.f || *sparse > 1.f) {
  947. *info = -22;
  948. } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
  949. ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
  950. || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
  951. {
  952. *info = -24;
  953. } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
  954. (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
  955. 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
  956. *info = -26;
  957. }
  958. if (*info != 0) {
  959. i__1 = -(*info);
  960. xerbla_("CLATMR", &i__1, 6);
  961. return;
  962. }
  963. /* Decide if we can pivot consistently */
  964. fulbnd = FALSE_;
  965. if (kuu == *n - 1 && kll == *m - 1) {
  966. fulbnd = TRUE_;
  967. }
  968. /* Initialize random number generator */
  969. for (i__ = 1; i__ <= 4; ++i__) {
  970. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  971. /* L30: */
  972. }
  973. iseed[4] = (iseed[4] / 2 << 1) + 1;
  974. /* 2) Set up D, DL, and DR, if indicated. */
  975. /* Compute D according to COND and MODE */
  976. clatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
  977. if (*info != 0) {
  978. *info = 1;
  979. return;
  980. }
  981. if (*mode != 0 && *mode != -6 && *mode != 6) {
  982. /* Scale by DMAX */
  983. temp = c_abs(&d__[1]);
  984. i__1 = mnmin;
  985. for (i__ = 2; i__ <= i__1; ++i__) {
  986. /* Computing MAX */
  987. r__1 = temp, r__2 = c_abs(&d__[i__]);
  988. temp = f2cmax(r__1,r__2);
  989. /* L40: */
  990. }
  991. if (temp == 0.f && (dmax__->r != 0.f || dmax__->i != 0.f)) {
  992. *info = 2;
  993. return;
  994. }
  995. if (temp != 0.f) {
  996. q__1.r = dmax__->r / temp, q__1.i = dmax__->i / temp;
  997. calpha.r = q__1.r, calpha.i = q__1.i;
  998. } else {
  999. calpha.r = 1.f, calpha.i = 0.f;
  1000. }
  1001. i__1 = mnmin;
  1002. for (i__ = 1; i__ <= i__1; ++i__) {
  1003. i__2 = i__;
  1004. i__3 = i__;
  1005. q__1.r = calpha.r * d__[i__3].r - calpha.i * d__[i__3].i, q__1.i =
  1006. calpha.r * d__[i__3].i + calpha.i * d__[i__3].r;
  1007. d__[i__2].r = q__1.r, d__[i__2].i = q__1.i;
  1008. /* L50: */
  1009. }
  1010. }
  1011. /* If matrix Hermitian, make D real */
  1012. if (isym == 0) {
  1013. i__1 = mnmin;
  1014. for (i__ = 1; i__ <= i__1; ++i__) {
  1015. i__2 = i__;
  1016. i__3 = i__;
  1017. r__1 = d__[i__3].r;
  1018. d__[i__2].r = r__1, d__[i__2].i = 0.f;
  1019. /* L60: */
  1020. }
  1021. }
  1022. /* Compute DL if grading set */
  1023. if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || igrade ==
  1024. 6) {
  1025. clatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
  1026. if (*info != 0) {
  1027. *info = 3;
  1028. return;
  1029. }
  1030. }
  1031. /* Compute DR if grading set */
  1032. if (igrade == 2 || igrade == 3) {
  1033. clatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
  1034. if (*info != 0) {
  1035. *info = 4;
  1036. return;
  1037. }
  1038. }
  1039. /* 3) Generate IWORK if pivoting */
  1040. if (ipvtng > 0) {
  1041. i__1 = npvts;
  1042. for (i__ = 1; i__ <= i__1; ++i__) {
  1043. iwork[i__] = i__;
  1044. /* L70: */
  1045. }
  1046. if (fulbnd) {
  1047. i__1 = npvts;
  1048. for (i__ = 1; i__ <= i__1; ++i__) {
  1049. k = ipivot[i__];
  1050. j = iwork[i__];
  1051. iwork[i__] = iwork[k];
  1052. iwork[k] = j;
  1053. /* L80: */
  1054. }
  1055. } else {
  1056. for (i__ = npvts; i__ >= 1; --i__) {
  1057. k = ipivot[i__];
  1058. j = iwork[i__];
  1059. iwork[i__] = iwork[k];
  1060. iwork[k] = j;
  1061. /* L90: */
  1062. }
  1063. }
  1064. }
  1065. /* 4) Generate matrices for each kind of PACKing */
  1066. /* Always sweep matrix columnwise (if symmetric, upper */
  1067. /* half only) so that matrix generated does not depend */
  1068. /* on PACK */
  1069. if (fulbnd) {
  1070. /* Use CLATM3 so matrices generated with differing PIVOTing only */
  1071. /* differ only in the order of their rows and/or columns. */
  1072. if (ipack == 0) {
  1073. if (isym == 0) {
  1074. i__1 = *n;
  1075. for (j = 1; j <= i__1; ++j) {
  1076. i__2 = j;
  1077. for (i__ = 1; i__ <= i__2; ++i__) {
  1078. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1079. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1080. dr[1], &ipvtng, &iwork[1], sparse);
  1081. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1082. i__3 = isub + jsub * a_dim1;
  1083. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1084. i__3 = jsub + isub * a_dim1;
  1085. r_cnjg(&q__1, &ctemp);
  1086. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1087. /* L100: */
  1088. }
  1089. /* L110: */
  1090. }
  1091. } else if (isym == 1) {
  1092. i__1 = *n;
  1093. for (j = 1; j <= i__1; ++j) {
  1094. i__2 = *m;
  1095. for (i__ = 1; i__ <= i__2; ++i__) {
  1096. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1097. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1098. dr[1], &ipvtng, &iwork[1], sparse);
  1099. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1100. i__3 = isub + jsub * a_dim1;
  1101. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1102. /* L120: */
  1103. }
  1104. /* L130: */
  1105. }
  1106. } else if (isym == 2) {
  1107. i__1 = *n;
  1108. for (j = 1; j <= i__1; ++j) {
  1109. i__2 = j;
  1110. for (i__ = 1; i__ <= i__2; ++i__) {
  1111. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1112. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1113. dr[1], &ipvtng, &iwork[1], sparse);
  1114. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1115. i__3 = isub + jsub * a_dim1;
  1116. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1117. i__3 = jsub + isub * a_dim1;
  1118. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1119. /* L140: */
  1120. }
  1121. /* L150: */
  1122. }
  1123. }
  1124. } else if (ipack == 1) {
  1125. i__1 = *n;
  1126. for (j = 1; j <= i__1; ++j) {
  1127. i__2 = j;
  1128. for (i__ = 1; i__ <= i__2; ++i__) {
  1129. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1130. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1131. , &ipvtng, &iwork[1], sparse);
  1132. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1133. mnsub = f2cmin(isub,jsub);
  1134. mxsub = f2cmax(isub,jsub);
  1135. if (mxsub == isub && isym == 0) {
  1136. i__3 = mnsub + mxsub * a_dim1;
  1137. r_cnjg(&q__1, &ctemp);
  1138. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1139. } else {
  1140. i__3 = mnsub + mxsub * a_dim1;
  1141. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1142. }
  1143. if (mnsub != mxsub) {
  1144. i__3 = mxsub + mnsub * a_dim1;
  1145. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1146. }
  1147. /* L160: */
  1148. }
  1149. /* L170: */
  1150. }
  1151. } else if (ipack == 2) {
  1152. i__1 = *n;
  1153. for (j = 1; j <= i__1; ++j) {
  1154. i__2 = j;
  1155. for (i__ = 1; i__ <= i__2; ++i__) {
  1156. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1157. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1158. , &ipvtng, &iwork[1], sparse);
  1159. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1160. mnsub = f2cmin(isub,jsub);
  1161. mxsub = f2cmax(isub,jsub);
  1162. if (mxsub == jsub && isym == 0) {
  1163. i__3 = mxsub + mnsub * a_dim1;
  1164. r_cnjg(&q__1, &ctemp);
  1165. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1166. } else {
  1167. i__3 = mxsub + mnsub * a_dim1;
  1168. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1169. }
  1170. if (mnsub != mxsub) {
  1171. i__3 = mnsub + mxsub * a_dim1;
  1172. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1173. }
  1174. /* L180: */
  1175. }
  1176. /* L190: */
  1177. }
  1178. } else if (ipack == 3) {
  1179. i__1 = *n;
  1180. for (j = 1; j <= i__1; ++j) {
  1181. i__2 = j;
  1182. for (i__ = 1; i__ <= i__2; ++i__) {
  1183. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1184. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1185. , &ipvtng, &iwork[1], sparse);
  1186. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1187. /* Compute K = location of (ISUB,JSUB) entry in packed */
  1188. /* array */
  1189. mnsub = f2cmin(isub,jsub);
  1190. mxsub = f2cmax(isub,jsub);
  1191. k = mxsub * (mxsub - 1) / 2 + mnsub;
  1192. /* Convert K to (IISUB,JJSUB) location */
  1193. jjsub = (k - 1) / *lda + 1;
  1194. iisub = k - *lda * (jjsub - 1);
  1195. if (mxsub == isub && isym == 0) {
  1196. i__3 = iisub + jjsub * a_dim1;
  1197. r_cnjg(&q__1, &ctemp);
  1198. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1199. } else {
  1200. i__3 = iisub + jjsub * a_dim1;
  1201. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1202. }
  1203. /* L200: */
  1204. }
  1205. /* L210: */
  1206. }
  1207. } else if (ipack == 4) {
  1208. i__1 = *n;
  1209. for (j = 1; j <= i__1; ++j) {
  1210. i__2 = j;
  1211. for (i__ = 1; i__ <= i__2; ++i__) {
  1212. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1213. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1214. , &ipvtng, &iwork[1], sparse);
  1215. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1216. /* Compute K = location of (I,J) entry in packed array */
  1217. mnsub = f2cmin(isub,jsub);
  1218. mxsub = f2cmax(isub,jsub);
  1219. if (mnsub == 1) {
  1220. k = mxsub;
  1221. } else {
  1222. k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
  1223. mnsub + 2) / 2 + mxsub - mnsub + 1;
  1224. }
  1225. /* Convert K to (IISUB,JJSUB) location */
  1226. jjsub = (k - 1) / *lda + 1;
  1227. iisub = k - *lda * (jjsub - 1);
  1228. if (mxsub == jsub && isym == 0) {
  1229. i__3 = iisub + jjsub * a_dim1;
  1230. r_cnjg(&q__1, &ctemp);
  1231. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1232. } else {
  1233. i__3 = iisub + jjsub * a_dim1;
  1234. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1235. }
  1236. /* L220: */
  1237. }
  1238. /* L230: */
  1239. }
  1240. } else if (ipack == 5) {
  1241. i__1 = *n;
  1242. for (j = 1; j <= i__1; ++j) {
  1243. i__2 = j;
  1244. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1245. if (i__ < 1) {
  1246. i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
  1247. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1248. } else {
  1249. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1250. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1251. dr[1], &ipvtng, &iwork[1], sparse);
  1252. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1253. mnsub = f2cmin(isub,jsub);
  1254. mxsub = f2cmax(isub,jsub);
  1255. if (mxsub == jsub && isym == 0) {
  1256. i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
  1257. r_cnjg(&q__1, &ctemp);
  1258. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1259. } else {
  1260. i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
  1261. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1262. }
  1263. }
  1264. /* L240: */
  1265. }
  1266. /* L250: */
  1267. }
  1268. } else if (ipack == 6) {
  1269. i__1 = *n;
  1270. for (j = 1; j <= i__1; ++j) {
  1271. i__2 = j;
  1272. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1273. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1274. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1275. , &ipvtng, &iwork[1], sparse);
  1276. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1277. mnsub = f2cmin(isub,jsub);
  1278. mxsub = f2cmax(isub,jsub);
  1279. if (mxsub == isub && isym == 0) {
  1280. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1281. r_cnjg(&q__1, &ctemp);
  1282. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1283. } else {
  1284. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1285. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1286. }
  1287. /* L260: */
  1288. }
  1289. /* L270: */
  1290. }
  1291. } else if (ipack == 7) {
  1292. if (isym != 1) {
  1293. i__1 = *n;
  1294. for (j = 1; j <= i__1; ++j) {
  1295. i__2 = j;
  1296. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1297. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1298. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1299. dr[1], &ipvtng, &iwork[1], sparse);
  1300. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1301. mnsub = f2cmin(isub,jsub);
  1302. mxsub = f2cmax(isub,jsub);
  1303. if (i__ < 1) {
  1304. i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
  1305. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1306. }
  1307. if (mxsub == isub && isym == 0) {
  1308. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1309. r_cnjg(&q__1, &ctemp);
  1310. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1311. } else {
  1312. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1313. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1314. }
  1315. if (i__ >= 1 && mnsub != mxsub) {
  1316. if (mnsub == isub && isym == 0) {
  1317. i__3 = mxsub - mnsub + 1 + kuu + mnsub *
  1318. a_dim1;
  1319. r_cnjg(&q__1, &ctemp);
  1320. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1321. } else {
  1322. i__3 = mxsub - mnsub + 1 + kuu + mnsub *
  1323. a_dim1;
  1324. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1325. }
  1326. }
  1327. /* L280: */
  1328. }
  1329. /* L290: */
  1330. }
  1331. } else if (isym == 1) {
  1332. i__1 = *n;
  1333. for (j = 1; j <= i__1; ++j) {
  1334. i__2 = j + kll;
  1335. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1336. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1337. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1338. dr[1], &ipvtng, &iwork[1], sparse);
  1339. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1340. i__3 = isub - jsub + kuu + 1 + jsub * a_dim1;
  1341. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1342. /* L300: */
  1343. }
  1344. /* L310: */
  1345. }
  1346. }
  1347. }
  1348. } else {
  1349. /* Use CLATM2 */
  1350. if (ipack == 0) {
  1351. if (isym == 0) {
  1352. i__1 = *n;
  1353. for (j = 1; j <= i__1; ++j) {
  1354. i__2 = j;
  1355. for (i__ = 1; i__ <= i__2; ++i__) {
  1356. i__3 = i__ + j * a_dim1;
  1357. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1358. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1359. &iwork[1], sparse);
  1360. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1361. i__3 = j + i__ * a_dim1;
  1362. r_cnjg(&q__1, &a[i__ + j * a_dim1]);
  1363. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1364. /* L320: */
  1365. }
  1366. /* L330: */
  1367. }
  1368. } else if (isym == 1) {
  1369. i__1 = *n;
  1370. for (j = 1; j <= i__1; ++j) {
  1371. i__2 = *m;
  1372. for (i__ = 1; i__ <= i__2; ++i__) {
  1373. i__3 = i__ + j * a_dim1;
  1374. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1375. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1376. &iwork[1], sparse);
  1377. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1378. /* L340: */
  1379. }
  1380. /* L350: */
  1381. }
  1382. } else if (isym == 2) {
  1383. i__1 = *n;
  1384. for (j = 1; j <= i__1; ++j) {
  1385. i__2 = j;
  1386. for (i__ = 1; i__ <= i__2; ++i__) {
  1387. i__3 = i__ + j * a_dim1;
  1388. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1389. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1390. &iwork[1], sparse);
  1391. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1392. i__3 = j + i__ * a_dim1;
  1393. i__4 = i__ + j * a_dim1;
  1394. a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
  1395. /* L360: */
  1396. }
  1397. /* L370: */
  1398. }
  1399. }
  1400. } else if (ipack == 1) {
  1401. i__1 = *n;
  1402. for (j = 1; j <= i__1; ++j) {
  1403. i__2 = j;
  1404. for (i__ = 1; i__ <= i__2; ++i__) {
  1405. i__3 = i__ + j * a_dim1;
  1406. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1407. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1408. 1], sparse);
  1409. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1410. if (i__ != j) {
  1411. i__3 = j + i__ * a_dim1;
  1412. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1413. }
  1414. /* L380: */
  1415. }
  1416. /* L390: */
  1417. }
  1418. } else if (ipack == 2) {
  1419. i__1 = *n;
  1420. for (j = 1; j <= i__1; ++j) {
  1421. i__2 = j;
  1422. for (i__ = 1; i__ <= i__2; ++i__) {
  1423. if (isym == 0) {
  1424. i__3 = j + i__ * a_dim1;
  1425. clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1426. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1427. &iwork[1], sparse);
  1428. r_cnjg(&q__1, &q__2);
  1429. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1430. } else {
  1431. i__3 = j + i__ * a_dim1;
  1432. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1433. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1434. &iwork[1], sparse);
  1435. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1436. }
  1437. if (i__ != j) {
  1438. i__3 = i__ + j * a_dim1;
  1439. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1440. }
  1441. /* L400: */
  1442. }
  1443. /* L410: */
  1444. }
  1445. } else if (ipack == 3) {
  1446. isub = 0;
  1447. jsub = 1;
  1448. i__1 = *n;
  1449. for (j = 1; j <= i__1; ++j) {
  1450. i__2 = j;
  1451. for (i__ = 1; i__ <= i__2; ++i__) {
  1452. ++isub;
  1453. if (isub > *lda) {
  1454. isub = 1;
  1455. ++jsub;
  1456. }
  1457. i__3 = isub + jsub * a_dim1;
  1458. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1459. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1460. 1], sparse);
  1461. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1462. /* L420: */
  1463. }
  1464. /* L430: */
  1465. }
  1466. } else if (ipack == 4) {
  1467. if (isym == 0 || isym == 2) {
  1468. i__1 = *n;
  1469. for (j = 1; j <= i__1; ++j) {
  1470. i__2 = j;
  1471. for (i__ = 1; i__ <= i__2; ++i__) {
  1472. /* Compute K = location of (I,J) entry in packed array */
  1473. if (i__ == 1) {
  1474. k = j;
  1475. } else {
  1476. k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
  1477. i__ + 2) / 2 + j - i__ + 1;
  1478. }
  1479. /* Convert K to (ISUB,JSUB) location */
  1480. jsub = (k - 1) / *lda + 1;
  1481. isub = k - *lda * (jsub - 1);
  1482. i__3 = isub + jsub * a_dim1;
  1483. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1484. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1485. &iwork[1], sparse);
  1486. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1487. if (isym == 0) {
  1488. i__3 = isub + jsub * a_dim1;
  1489. r_cnjg(&q__1, &a[isub + jsub * a_dim1]);
  1490. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1491. }
  1492. /* L440: */
  1493. }
  1494. /* L450: */
  1495. }
  1496. } else {
  1497. isub = 0;
  1498. jsub = 1;
  1499. i__1 = *n;
  1500. for (j = 1; j <= i__1; ++j) {
  1501. i__2 = *m;
  1502. for (i__ = j; i__ <= i__2; ++i__) {
  1503. ++isub;
  1504. if (isub > *lda) {
  1505. isub = 1;
  1506. ++jsub;
  1507. }
  1508. i__3 = isub + jsub * a_dim1;
  1509. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1510. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1511. &iwork[1], sparse);
  1512. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1513. /* L460: */
  1514. }
  1515. /* L470: */
  1516. }
  1517. }
  1518. } else if (ipack == 5) {
  1519. i__1 = *n;
  1520. for (j = 1; j <= i__1; ++j) {
  1521. i__2 = j;
  1522. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1523. if (i__ < 1) {
  1524. i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
  1525. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1526. } else {
  1527. if (isym == 0) {
  1528. i__3 = j - i__ + 1 + i__ * a_dim1;
  1529. clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &
  1530. iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1531. , &ipvtng, &iwork[1], sparse);
  1532. r_cnjg(&q__1, &q__2);
  1533. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1534. } else {
  1535. i__3 = j - i__ + 1 + i__ * a_dim1;
  1536. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &
  1537. iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1538. , &ipvtng, &iwork[1], sparse);
  1539. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1540. }
  1541. }
  1542. /* L480: */
  1543. }
  1544. /* L490: */
  1545. }
  1546. } else if (ipack == 6) {
  1547. i__1 = *n;
  1548. for (j = 1; j <= i__1; ++j) {
  1549. i__2 = j;
  1550. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1551. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1552. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1553. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1554. 1], sparse);
  1555. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1556. /* L500: */
  1557. }
  1558. /* L510: */
  1559. }
  1560. } else if (ipack == 7) {
  1561. if (isym != 1) {
  1562. i__1 = *n;
  1563. for (j = 1; j <= i__1; ++j) {
  1564. i__2 = j;
  1565. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1566. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1567. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1568. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1569. &iwork[1], sparse);
  1570. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1571. if (i__ < 1) {
  1572. i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
  1573. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1574. }
  1575. if (i__ >= 1 && i__ != j) {
  1576. if (isym == 0) {
  1577. i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
  1578. r_cnjg(&q__1, &a[i__ - j + kuu + 1 + j *
  1579. a_dim1]);
  1580. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1581. } else {
  1582. i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
  1583. i__4 = i__ - j + kuu + 1 + j * a_dim1;
  1584. a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
  1585. }
  1586. }
  1587. /* L520: */
  1588. }
  1589. /* L530: */
  1590. }
  1591. } else if (isym == 1) {
  1592. i__1 = *n;
  1593. for (j = 1; j <= i__1; ++j) {
  1594. i__2 = j + kll;
  1595. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1596. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1597. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1598. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1599. &iwork[1], sparse);
  1600. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1601. /* L540: */
  1602. }
  1603. /* L550: */
  1604. }
  1605. }
  1606. }
  1607. }
  1608. /* 5) Scaling the norm */
  1609. if (ipack == 0) {
  1610. onorm = clange_("M", m, n, &a[a_offset], lda, tempa);
  1611. } else if (ipack == 1) {
  1612. onorm = clansy_("M", "U", n, &a[a_offset], lda, tempa);
  1613. } else if (ipack == 2) {
  1614. onorm = clansy_("M", "L", n, &a[a_offset], lda, tempa);
  1615. } else if (ipack == 3) {
  1616. onorm = clansp_("M", "U", n, &a[a_offset], tempa);
  1617. } else if (ipack == 4) {
  1618. onorm = clansp_("M", "L", n, &a[a_offset], tempa);
  1619. } else if (ipack == 5) {
  1620. onorm = clansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
  1621. } else if (ipack == 6) {
  1622. onorm = clansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
  1623. } else if (ipack == 7) {
  1624. onorm = clangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
  1625. }
  1626. if (*anorm >= 0.f) {
  1627. if (*anorm > 0.f && onorm == 0.f) {
  1628. /* Desired scaling impossible */
  1629. *info = 5;
  1630. return;
  1631. } else if (*anorm > 1.f && onorm < 1.f || *anorm < 1.f && onorm > 1.f)
  1632. {
  1633. /* Scale carefully to avoid over / underflow */
  1634. if (ipack <= 2) {
  1635. i__1 = *n;
  1636. for (j = 1; j <= i__1; ++j) {
  1637. r__1 = 1.f / onorm;
  1638. csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
  1639. csscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
  1640. /* L560: */
  1641. }
  1642. } else if (ipack == 3 || ipack == 4) {
  1643. i__1 = *n * (*n + 1) / 2;
  1644. r__1 = 1.f / onorm;
  1645. csscal_(&i__1, &r__1, &a[a_offset], &c__1);
  1646. i__1 = *n * (*n + 1) / 2;
  1647. csscal_(&i__1, anorm, &a[a_offset], &c__1);
  1648. } else if (ipack >= 5) {
  1649. i__1 = *n;
  1650. for (j = 1; j <= i__1; ++j) {
  1651. i__2 = kll + kuu + 1;
  1652. r__1 = 1.f / onorm;
  1653. csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
  1654. i__2 = kll + kuu + 1;
  1655. csscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
  1656. /* L570: */
  1657. }
  1658. }
  1659. } else {
  1660. /* Scale straightforwardly */
  1661. if (ipack <= 2) {
  1662. i__1 = *n;
  1663. for (j = 1; j <= i__1; ++j) {
  1664. r__1 = *anorm / onorm;
  1665. csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
  1666. /* L580: */
  1667. }
  1668. } else if (ipack == 3 || ipack == 4) {
  1669. i__1 = *n * (*n + 1) / 2;
  1670. r__1 = *anorm / onorm;
  1671. csscal_(&i__1, &r__1, &a[a_offset], &c__1);
  1672. } else if (ipack >= 5) {
  1673. i__1 = *n;
  1674. for (j = 1; j <= i__1; ++j) {
  1675. i__2 = kll + kuu + 1;
  1676. r__1 = *anorm / onorm;
  1677. csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
  1678. /* L590: */
  1679. }
  1680. }
  1681. }
  1682. }
  1683. /* End of CLATMR */
  1684. return;
  1685. } /* clatmr_ */