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.

slatmr.c 57 kB

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