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