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.

dlatmr.c 58 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 DLATMR */
  489. /* =========== DOCUMENTATION =========== */
  490. /* Online html documentation available at */
  491. /* http://www.netlib.org/lapack/explore-html/ */
  492. /* Definition: */
  493. /* =========== */
  494. /* SUBROUTINE DLATMR( 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. /* DOUBLE PRECISION ANORM, COND, CONDL, CONDR, DMAX, SPARSE */
  501. /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
  502. /* DOUBLE PRECISION A( LDA, * ), D( * ), DL( * ), DR( * ) */
  503. /* > \par Purpose: */
  504. /* ============= */
  505. /* > */
  506. /* > \verbatim */
  507. /* > */
  508. /* > DLATMR generates random matrices of various types for testing */
  509. /* > LAPACK programs. */
  510. /* > */
  511. /* > DLATMR 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 DLATMR differ only in the PACK parameter, */
  552. /* > they will generate mathematically equivalent matrices. */
  553. /* > */
  554. /* > If two calls to DLATMR 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 DLATMR */
  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,out] D */
  609. /* > \verbatim */
  610. /* > D is DOUBLE PRECISION 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 DOUBLE PRECISION */
  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 DOUBLE PRECISION */
  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 DOUBLE PRECISION 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 DOUBLE PRECISION */
  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 DOUBLE PRECISION 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 DOUBLE PRECISION */
  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 DLATMR 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, DLATMR */
  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 DOUBLE PRECISION */
  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 DOUBLE PRECISION */
  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 DLATMR differ only in the PACK parameter, */
  852. /* > they will generate mathematically equivalent matrices. */
  853. /* > Not modified. */
  854. /* > \endverbatim */
  855. /* > */
  856. /* > \param[out] A */
  857. /* > \verbatim */
  858. /* > A is DOUBLE PRECISION 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 DLATM1 (computing D) */
  923. /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
  924. /* > 3 => Error return from DLATM1 (computing DL) */
  925. /* > 4 => Error return from DLATM1 (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 double_matgen */
  937. /* ===================================================================== */
  938. /* Subroutine */ int dlatmr_(integer *m, integer *n, char *dist, integer *
  939. iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
  940. doublereal *dmax__, char *rsign, char *grade, doublereal *dl, integer
  941. *model, doublereal *condl, doublereal *dr, integer *moder, doublereal
  942. *condr, char *pivtng, integer *ipivot, integer *kl, integer *ku,
  943. doublereal *sparse, doublereal *anorm, char *pack, doublereal *a,
  944. integer *lda, integer *iwork, integer *info)
  945. {
  946. /* System generated locals */
  947. integer a_dim1, a_offset, i__1, i__2;
  948. doublereal d__1, d__2, d__3;
  949. /* Local variables */
  950. integer isub, jsub;
  951. doublereal temp;
  952. integer isym, i__, j, k;
  953. doublereal alpha;
  954. extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
  955. integer *);
  956. integer ipack;
  957. extern logical lsame_(char *, char *);
  958. doublereal tempa[1];
  959. integer iisub, idist, jjsub, mnmin;
  960. logical dzero;
  961. integer mnsub;
  962. doublereal onorm;
  963. integer mxsub, npvts;
  964. extern /* Subroutine */ int dlatm1_(integer *, doublereal *, integer *,
  965. integer *, integer *, doublereal *, integer *, integer *);
  966. extern doublereal dlatm2_(integer *, integer *, integer *, integer *,
  967. integer *, integer *, integer *, integer *, doublereal *, integer
  968. *, doublereal *, doublereal *, integer *, integer *, doublereal *)
  969. , dlatm3_(integer *, integer *, integer *, integer *, integer *,
  970. integer *, integer *, integer *, integer *, integer *, doublereal
  971. *, integer *, doublereal *, doublereal *, integer *, integer *,
  972. doublereal *), dlangb_(char *, integer *, integer *, integer *,
  973. doublereal *, integer *, doublereal *), dlange_(char *,
  974. integer *, integer *, doublereal *, integer *, doublereal *);
  975. integer igrade;
  976. extern doublereal dlansb_(char *, char *, integer *, integer *,
  977. doublereal *, integer *, doublereal *);
  978. logical fulbnd;
  979. extern /* Subroutine */ int xerbla_(char *, integer *);
  980. logical badpvt;
  981. extern doublereal dlansp_(char *, char *, integer *, doublereal *,
  982. doublereal *), dlansy_(char *, char *, integer *,
  983. doublereal *, integer *, doublereal *);
  984. integer irsign, ipvtng, kll, kuu;
  985. /* -- LAPACK computational routine (version 3.7.0) -- */
  986. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  987. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  988. /* December 2016 */
  989. /* ===================================================================== */
  990. /* 1) Decode and Test the input parameters. */
  991. /* Initialize flags & seed. */
  992. /* Parameter adjustments */
  993. --iseed;
  994. --d__;
  995. --dl;
  996. --dr;
  997. --ipivot;
  998. a_dim1 = *lda;
  999. a_offset = 1 + a_dim1 * 1;
  1000. a -= a_offset;
  1001. --iwork;
  1002. /* Function Body */
  1003. *info = 0;
  1004. /* Quick return if possible */
  1005. if (*m == 0 || *n == 0) {
  1006. return 0;
  1007. }
  1008. /* Decode DIST */
  1009. if (lsame_(dist, "U")) {
  1010. idist = 1;
  1011. } else if (lsame_(dist, "S")) {
  1012. idist = 2;
  1013. } else if (lsame_(dist, "N")) {
  1014. idist = 3;
  1015. } else {
  1016. idist = -1;
  1017. }
  1018. /* Decode SYM */
  1019. if (lsame_(sym, "S")) {
  1020. isym = 0;
  1021. } else if (lsame_(sym, "N")) {
  1022. isym = 1;
  1023. } else if (lsame_(sym, "H")) {
  1024. isym = 0;
  1025. } else {
  1026. isym = -1;
  1027. }
  1028. /* Decode RSIGN */
  1029. if (lsame_(rsign, "F")) {
  1030. irsign = 0;
  1031. } else if (lsame_(rsign, "T")) {
  1032. irsign = 1;
  1033. } else {
  1034. irsign = -1;
  1035. }
  1036. /* Decode PIVTNG */
  1037. if (lsame_(pivtng, "N")) {
  1038. ipvtng = 0;
  1039. } else if (lsame_(pivtng, " ")) {
  1040. ipvtng = 0;
  1041. } else if (lsame_(pivtng, "L")) {
  1042. ipvtng = 1;
  1043. npvts = *m;
  1044. } else if (lsame_(pivtng, "R")) {
  1045. ipvtng = 2;
  1046. npvts = *n;
  1047. } else if (lsame_(pivtng, "B")) {
  1048. ipvtng = 3;
  1049. npvts = f2cmin(*n,*m);
  1050. } else if (lsame_(pivtng, "F")) {
  1051. ipvtng = 3;
  1052. npvts = f2cmin(*n,*m);
  1053. } else {
  1054. ipvtng = -1;
  1055. }
  1056. /* Decode GRADE */
  1057. if (lsame_(grade, "N")) {
  1058. igrade = 0;
  1059. } else if (lsame_(grade, "L")) {
  1060. igrade = 1;
  1061. } else if (lsame_(grade, "R")) {
  1062. igrade = 2;
  1063. } else if (lsame_(grade, "B")) {
  1064. igrade = 3;
  1065. } else if (lsame_(grade, "E")) {
  1066. igrade = 4;
  1067. } else if (lsame_(grade, "H") || lsame_(grade,
  1068. "S")) {
  1069. igrade = 5;
  1070. } else {
  1071. igrade = -1;
  1072. }
  1073. /* Decode PACK */
  1074. if (lsame_(pack, "N")) {
  1075. ipack = 0;
  1076. } else if (lsame_(pack, "U")) {
  1077. ipack = 1;
  1078. } else if (lsame_(pack, "L")) {
  1079. ipack = 2;
  1080. } else if (lsame_(pack, "C")) {
  1081. ipack = 3;
  1082. } else if (lsame_(pack, "R")) {
  1083. ipack = 4;
  1084. } else if (lsame_(pack, "B")) {
  1085. ipack = 5;
  1086. } else if (lsame_(pack, "Q")) {
  1087. ipack = 6;
  1088. } else if (lsame_(pack, "Z")) {
  1089. ipack = 7;
  1090. } else {
  1091. ipack = -1;
  1092. }
  1093. /* Set certain internal parameters */
  1094. mnmin = f2cmin(*m,*n);
  1095. /* Computing MIN */
  1096. i__1 = *kl, i__2 = *m - 1;
  1097. kll = f2cmin(i__1,i__2);
  1098. /* Computing MIN */
  1099. i__1 = *ku, i__2 = *n - 1;
  1100. kuu = f2cmin(i__1,i__2);
  1101. /* If inv(DL) is used, check to see if DL has a zero entry. */
  1102. dzero = FALSE_;
  1103. if (igrade == 4 && *model == 0) {
  1104. i__1 = *m;
  1105. for (i__ = 1; i__ <= i__1; ++i__) {
  1106. if (dl[i__] == 0.) {
  1107. dzero = TRUE_;
  1108. }
  1109. /* L10: */
  1110. }
  1111. }
  1112. /* Check values in IPIVOT */
  1113. badpvt = FALSE_;
  1114. if (ipvtng > 0) {
  1115. i__1 = npvts;
  1116. for (j = 1; j <= i__1; ++j) {
  1117. if (ipivot[j] <= 0 || ipivot[j] > npvts) {
  1118. badpvt = TRUE_;
  1119. }
  1120. /* L20: */
  1121. }
  1122. }
  1123. /* Set INFO if an error */
  1124. if (*m < 0) {
  1125. *info = -1;
  1126. } else if (*m != *n && isym == 0) {
  1127. *info = -1;
  1128. } else if (*n < 0) {
  1129. *info = -2;
  1130. } else if (idist == -1) {
  1131. *info = -3;
  1132. } else if (isym == -1) {
  1133. *info = -5;
  1134. } else if (*mode < -6 || *mode > 6) {
  1135. *info = -7;
  1136. } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.) {
  1137. *info = -8;
  1138. } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
  1139. *info = -10;
  1140. } else if (igrade == -1 || igrade == 4 && *m != *n || igrade >= 1 &&
  1141. igrade <= 4 && isym == 0) {
  1142. *info = -11;
  1143. } else if (igrade == 4 && dzero) {
  1144. *info = -12;
  1145. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  1146. *model < -6 || *model > 6)) {
  1147. *info = -13;
  1148. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  1149. *model != -6 && *model != 0 && *model != 6) && *condl < 1.) {
  1150. *info = -14;
  1151. } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
  1152. *info = -16;
  1153. } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
  1154. *moder != 6) && *condr < 1.) {
  1155. *info = -17;
  1156. } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
  1157. ipvtng == 2) && isym == 0) {
  1158. *info = -18;
  1159. } else if (ipvtng != 0 && badpvt) {
  1160. *info = -19;
  1161. } else if (*kl < 0) {
  1162. *info = -20;
  1163. } else if (*ku < 0 || isym == 0 && *kl != *ku) {
  1164. *info = -21;
  1165. } else if (*sparse < 0. || *sparse > 1.) {
  1166. *info = -22;
  1167. } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
  1168. ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
  1169. || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
  1170. {
  1171. *info = -24;
  1172. } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
  1173. (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
  1174. 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
  1175. *info = -26;
  1176. }
  1177. if (*info != 0) {
  1178. i__1 = -(*info);
  1179. xerbla_("DLATMR", &i__1);
  1180. return 0;
  1181. }
  1182. /* Decide if we can pivot consistently */
  1183. fulbnd = FALSE_;
  1184. if (kuu == *n - 1 && kll == *m - 1) {
  1185. fulbnd = TRUE_;
  1186. }
  1187. /* Initialize random number generator */
  1188. for (i__ = 1; i__ <= 4; ++i__) {
  1189. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  1190. /* L30: */
  1191. }
  1192. iseed[4] = (iseed[4] / 2 << 1) + 1;
  1193. /* 2) Set up D, DL, and DR, if indicated. */
  1194. /* Compute D according to COND and MODE */
  1195. dlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
  1196. if (*info != 0) {
  1197. *info = 1;
  1198. return 0;
  1199. }
  1200. if (*mode != 0 && *mode != -6 && *mode != 6) {
  1201. /* Scale by DMAX */
  1202. temp = abs(d__[1]);
  1203. i__1 = mnmin;
  1204. for (i__ = 2; i__ <= i__1; ++i__) {
  1205. /* Computing MAX */
  1206. d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
  1207. temp = f2cmax(d__2,d__3);
  1208. /* L40: */
  1209. }
  1210. if (temp == 0. && *dmax__ != 0.) {
  1211. *info = 2;
  1212. return 0;
  1213. }
  1214. if (temp != 0.) {
  1215. alpha = *dmax__ / temp;
  1216. } else {
  1217. alpha = 1.;
  1218. }
  1219. i__1 = mnmin;
  1220. for (i__ = 1; i__ <= i__1; ++i__) {
  1221. d__[i__] = alpha * d__[i__];
  1222. /* L50: */
  1223. }
  1224. }
  1225. /* Compute DL if grading set */
  1226. if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) {
  1227. dlatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
  1228. if (*info != 0) {
  1229. *info = 3;
  1230. return 0;
  1231. }
  1232. }
  1233. /* Compute DR if grading set */
  1234. if (igrade == 2 || igrade == 3) {
  1235. dlatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
  1236. if (*info != 0) {
  1237. *info = 4;
  1238. return 0;
  1239. }
  1240. }
  1241. /* 3) Generate IWORK if pivoting */
  1242. if (ipvtng > 0) {
  1243. i__1 = npvts;
  1244. for (i__ = 1; i__ <= i__1; ++i__) {
  1245. iwork[i__] = i__;
  1246. /* L60: */
  1247. }
  1248. if (fulbnd) {
  1249. i__1 = npvts;
  1250. for (i__ = 1; i__ <= i__1; ++i__) {
  1251. k = ipivot[i__];
  1252. j = iwork[i__];
  1253. iwork[i__] = iwork[k];
  1254. iwork[k] = j;
  1255. /* L70: */
  1256. }
  1257. } else {
  1258. for (i__ = npvts; i__ >= 1; --i__) {
  1259. k = ipivot[i__];
  1260. j = iwork[i__];
  1261. iwork[i__] = iwork[k];
  1262. iwork[k] = j;
  1263. /* L80: */
  1264. }
  1265. }
  1266. }
  1267. /* 4) Generate matrices for each kind of PACKing */
  1268. /* Always sweep matrix columnwise (if symmetric, upper */
  1269. /* half only) so that matrix generated does not depend */
  1270. /* on PACK */
  1271. if (fulbnd) {
  1272. /* Use DLATM3 so matrices generated with differing PIVOTing only */
  1273. /* differ only in the order of their rows and/or columns. */
  1274. if (ipack == 0) {
  1275. if (isym == 0) {
  1276. i__1 = *n;
  1277. for (j = 1; j <= i__1; ++j) {
  1278. i__2 = j;
  1279. for (i__ = 1; i__ <= i__2; ++i__) {
  1280. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1281. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1282. dr[1], &ipvtng, &iwork[1], sparse);
  1283. a[isub + jsub * a_dim1] = temp;
  1284. a[jsub + isub * a_dim1] = temp;
  1285. /* L90: */
  1286. }
  1287. /* L100: */
  1288. }
  1289. } else if (isym == 1) {
  1290. i__1 = *n;
  1291. for (j = 1; j <= i__1; ++j) {
  1292. i__2 = *m;
  1293. for (i__ = 1; i__ <= i__2; ++i__) {
  1294. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1295. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1296. dr[1], &ipvtng, &iwork[1], sparse);
  1297. a[isub + jsub * a_dim1] = temp;
  1298. /* L110: */
  1299. }
  1300. /* L120: */
  1301. }
  1302. }
  1303. } else if (ipack == 1) {
  1304. i__1 = *n;
  1305. for (j = 1; j <= i__1; ++j) {
  1306. i__2 = j;
  1307. for (i__ = 1; i__ <= i__2; ++i__) {
  1308. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1309. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1310. , &ipvtng, &iwork[1], sparse);
  1311. mnsub = f2cmin(isub,jsub);
  1312. mxsub = f2cmax(isub,jsub);
  1313. a[mnsub + mxsub * a_dim1] = temp;
  1314. if (mnsub != mxsub) {
  1315. a[mxsub + mnsub * a_dim1] = 0.;
  1316. }
  1317. /* L130: */
  1318. }
  1319. /* L140: */
  1320. }
  1321. } else if (ipack == 2) {
  1322. i__1 = *n;
  1323. for (j = 1; j <= i__1; ++j) {
  1324. i__2 = j;
  1325. for (i__ = 1; i__ <= i__2; ++i__) {
  1326. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1327. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1328. , &ipvtng, &iwork[1], sparse);
  1329. mnsub = f2cmin(isub,jsub);
  1330. mxsub = f2cmax(isub,jsub);
  1331. a[mxsub + mnsub * a_dim1] = temp;
  1332. if (mnsub != mxsub) {
  1333. a[mnsub + mxsub * a_dim1] = 0.;
  1334. }
  1335. /* L150: */
  1336. }
  1337. /* L160: */
  1338. }
  1339. } else if (ipack == 3) {
  1340. i__1 = *n;
  1341. for (j = 1; j <= i__1; ++j) {
  1342. i__2 = j;
  1343. for (i__ = 1; i__ <= i__2; ++i__) {
  1344. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1345. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1346. , &ipvtng, &iwork[1], sparse);
  1347. /* Compute K = location of (ISUB,JSUB) entry in packed */
  1348. /* array */
  1349. mnsub = f2cmin(isub,jsub);
  1350. mxsub = f2cmax(isub,jsub);
  1351. k = mxsub * (mxsub - 1) / 2 + mnsub;
  1352. /* Convert K to (IISUB,JJSUB) location */
  1353. jjsub = (k - 1) / *lda + 1;
  1354. iisub = k - *lda * (jjsub - 1);
  1355. a[iisub + jjsub * a_dim1] = temp;
  1356. /* L170: */
  1357. }
  1358. /* L180: */
  1359. }
  1360. } else if (ipack == 4) {
  1361. i__1 = *n;
  1362. for (j = 1; j <= i__1; ++j) {
  1363. i__2 = j;
  1364. for (i__ = 1; i__ <= i__2; ++i__) {
  1365. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1366. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1367. , &ipvtng, &iwork[1], sparse);
  1368. /* Compute K = location of (I,J) entry in packed array */
  1369. mnsub = f2cmin(isub,jsub);
  1370. mxsub = f2cmax(isub,jsub);
  1371. if (mnsub == 1) {
  1372. k = mxsub;
  1373. } else {
  1374. k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
  1375. mnsub + 2) / 2 + mxsub - mnsub + 1;
  1376. }
  1377. /* Convert K to (IISUB,JJSUB) location */
  1378. jjsub = (k - 1) / *lda + 1;
  1379. iisub = k - *lda * (jjsub - 1);
  1380. a[iisub + jjsub * a_dim1] = temp;
  1381. /* L190: */
  1382. }
  1383. /* L200: */
  1384. }
  1385. } else if (ipack == 5) {
  1386. i__1 = *n;
  1387. for (j = 1; j <= i__1; ++j) {
  1388. i__2 = j;
  1389. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1390. if (i__ < 1) {
  1391. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
  1392. } else {
  1393. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1394. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1395. dr[1], &ipvtng, &iwork[1], sparse);
  1396. mnsub = f2cmin(isub,jsub);
  1397. mxsub = f2cmax(isub,jsub);
  1398. a[mxsub - mnsub + 1 + mnsub * a_dim1] = temp;
  1399. }
  1400. /* L210: */
  1401. }
  1402. /* L220: */
  1403. }
  1404. } else if (ipack == 6) {
  1405. i__1 = *n;
  1406. for (j = 1; j <= i__1; ++j) {
  1407. i__2 = j;
  1408. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1409. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1410. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1411. , &ipvtng, &iwork[1], sparse);
  1412. mnsub = f2cmin(isub,jsub);
  1413. mxsub = f2cmax(isub,jsub);
  1414. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1415. /* L230: */
  1416. }
  1417. /* L240: */
  1418. }
  1419. } else if (ipack == 7) {
  1420. if (isym == 0) {
  1421. i__1 = *n;
  1422. for (j = 1; j <= i__1; ++j) {
  1423. i__2 = j;
  1424. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1425. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1426. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1427. dr[1], &ipvtng, &iwork[1], sparse);
  1428. mnsub = f2cmin(isub,jsub);
  1429. mxsub = f2cmax(isub,jsub);
  1430. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1431. if (i__ < 1) {
  1432. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
  1433. }
  1434. if (i__ >= 1 && mnsub != mxsub) {
  1435. a[mxsub - mnsub + 1 + kuu + mnsub * a_dim1] =
  1436. temp;
  1437. }
  1438. /* L250: */
  1439. }
  1440. /* L260: */
  1441. }
  1442. } else if (isym == 1) {
  1443. i__1 = *n;
  1444. for (j = 1; j <= i__1; ++j) {
  1445. i__2 = j + kll;
  1446. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1447. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1448. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1449. dr[1], &ipvtng, &iwork[1], sparse);
  1450. a[isub - jsub + kuu + 1 + jsub * a_dim1] = temp;
  1451. /* L270: */
  1452. }
  1453. /* L280: */
  1454. }
  1455. }
  1456. }
  1457. } else {
  1458. /* Use DLATM2 */
  1459. if (ipack == 0) {
  1460. if (isym == 0) {
  1461. i__1 = *n;
  1462. for (j = 1; j <= i__1; ++j) {
  1463. i__2 = j;
  1464. for (i__ = 1; i__ <= i__2; ++i__) {
  1465. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1466. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1467. dr[1], &ipvtng, &iwork[1], sparse);
  1468. a[j + i__ * a_dim1] = a[i__ + j * a_dim1];
  1469. /* L290: */
  1470. }
  1471. /* L300: */
  1472. }
  1473. } else if (isym == 1) {
  1474. i__1 = *n;
  1475. for (j = 1; j <= i__1; ++j) {
  1476. i__2 = *m;
  1477. for (i__ = 1; i__ <= i__2; ++i__) {
  1478. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1479. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1480. dr[1], &ipvtng, &iwork[1], sparse);
  1481. /* L310: */
  1482. }
  1483. /* L320: */
  1484. }
  1485. }
  1486. } else if (ipack == 1) {
  1487. i__1 = *n;
  1488. for (j = 1; j <= i__1; ++j) {
  1489. i__2 = j;
  1490. for (i__ = 1; i__ <= i__2; ++i__) {
  1491. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
  1492. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1493. , &ipvtng, &iwork[1], sparse);
  1494. if (i__ != j) {
  1495. a[j + i__ * a_dim1] = 0.;
  1496. }
  1497. /* L330: */
  1498. }
  1499. /* L340: */
  1500. }
  1501. } else if (ipack == 2) {
  1502. i__1 = *n;
  1503. for (j = 1; j <= i__1; ++j) {
  1504. i__2 = j;
  1505. for (i__ = 1; i__ <= i__2; ++i__) {
  1506. a[j + i__ * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
  1507. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1508. , &ipvtng, &iwork[1], sparse);
  1509. if (i__ != j) {
  1510. a[i__ + j * a_dim1] = 0.;
  1511. }
  1512. /* L350: */
  1513. }
  1514. /* L360: */
  1515. }
  1516. } else if (ipack == 3) {
  1517. isub = 0;
  1518. jsub = 1;
  1519. i__1 = *n;
  1520. for (j = 1; j <= i__1; ++j) {
  1521. i__2 = j;
  1522. for (i__ = 1; i__ <= i__2; ++i__) {
  1523. ++isub;
  1524. if (isub > *lda) {
  1525. isub = 1;
  1526. ++jsub;
  1527. }
  1528. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1529. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[
  1530. 1], &ipvtng, &iwork[1], sparse);
  1531. /* L370: */
  1532. }
  1533. /* L380: */
  1534. }
  1535. } else if (ipack == 4) {
  1536. if (isym == 0) {
  1537. i__1 = *n;
  1538. for (j = 1; j <= i__1; ++j) {
  1539. i__2 = j;
  1540. for (i__ = 1; i__ <= i__2; ++i__) {
  1541. /* Compute K = location of (I,J) entry in packed array */
  1542. if (i__ == 1) {
  1543. k = j;
  1544. } else {
  1545. k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
  1546. i__ + 2) / 2 + j - i__ + 1;
  1547. }
  1548. /* Convert K to (ISUB,JSUB) location */
  1549. jsub = (k - 1) / *lda + 1;
  1550. isub = k - *lda * (jsub - 1);
  1551. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
  1552. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1553. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1554. /* L390: */
  1555. }
  1556. /* L400: */
  1557. }
  1558. } else {
  1559. isub = 0;
  1560. jsub = 1;
  1561. i__1 = *n;
  1562. for (j = 1; j <= i__1; ++j) {
  1563. i__2 = *m;
  1564. for (i__ = j; i__ <= i__2; ++i__) {
  1565. ++isub;
  1566. if (isub > *lda) {
  1567. isub = 1;
  1568. ++jsub;
  1569. }
  1570. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
  1571. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1572. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1573. /* L410: */
  1574. }
  1575. /* L420: */
  1576. }
  1577. }
  1578. } else if (ipack == 5) {
  1579. i__1 = *n;
  1580. for (j = 1; j <= i__1; ++j) {
  1581. i__2 = j;
  1582. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1583. if (i__ < 1) {
  1584. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
  1585. } else {
  1586. a[j - i__ + 1 + i__ * a_dim1] = dlatm2_(m, n, &i__, &
  1587. j, kl, ku, &idist, &iseed[1], &d__[1], &
  1588. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1589. sparse);
  1590. }
  1591. /* L430: */
  1592. }
  1593. /* L440: */
  1594. }
  1595. } else if (ipack == 6) {
  1596. i__1 = *n;
  1597. for (j = 1; j <= i__1; ++j) {
  1598. i__2 = j;
  1599. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1600. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &i__, &
  1601. j, kl, ku, &idist, &iseed[1], &d__[1], &igrade, &
  1602. dl[1], &dr[1], &ipvtng, &iwork[1], sparse);
  1603. /* L450: */
  1604. }
  1605. /* L460: */
  1606. }
  1607. } else if (ipack == 7) {
  1608. if (isym == 0) {
  1609. i__1 = *n;
  1610. for (j = 1; j <= i__1; ++j) {
  1611. i__2 = j;
  1612. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1613. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
  1614. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1615. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1616. sparse);
  1617. if (i__ < 1) {
  1618. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
  1619. }
  1620. if (i__ >= 1 && i__ != j) {
  1621. a[j - i__ + 1 + kuu + i__ * a_dim1] = a[i__ - j +
  1622. kuu + 1 + j * a_dim1];
  1623. }
  1624. /* L470: */
  1625. }
  1626. /* L480: */
  1627. }
  1628. } else if (isym == 1) {
  1629. i__1 = *n;
  1630. for (j = 1; j <= i__1; ++j) {
  1631. i__2 = j + kll;
  1632. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1633. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
  1634. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1635. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1636. sparse);
  1637. /* L490: */
  1638. }
  1639. /* L500: */
  1640. }
  1641. }
  1642. }
  1643. }
  1644. /* 5) Scaling the norm */
  1645. if (ipack == 0) {
  1646. onorm = dlange_("M", m, n, &a[a_offset], lda, tempa);
  1647. } else if (ipack == 1) {
  1648. onorm = dlansy_("M", "U", n, &a[a_offset], lda, tempa);
  1649. } else if (ipack == 2) {
  1650. onorm = dlansy_("M", "L", n, &a[a_offset], lda, tempa);
  1651. } else if (ipack == 3) {
  1652. onorm = dlansp_("M", "U", n, &a[a_offset], tempa);
  1653. } else if (ipack == 4) {
  1654. onorm = dlansp_("M", "L", n, &a[a_offset], tempa);
  1655. } else if (ipack == 5) {
  1656. onorm = dlansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
  1657. } else if (ipack == 6) {
  1658. onorm = dlansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
  1659. } else if (ipack == 7) {
  1660. onorm = dlangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
  1661. }
  1662. if (*anorm >= 0.) {
  1663. if (*anorm > 0. && onorm == 0.) {
  1664. /* Desired scaling impossible */
  1665. *info = 5;
  1666. return 0;
  1667. } else if (*anorm > 1. && onorm < 1. || *anorm < 1. && onorm > 1.) {
  1668. /* Scale carefully to avoid over / underflow */
  1669. if (ipack <= 2) {
  1670. i__1 = *n;
  1671. for (j = 1; j <= i__1; ++j) {
  1672. d__1 = 1. / onorm;
  1673. dscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
  1674. dscal_(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. d__1 = 1. / onorm;
  1680. dscal_(&i__1, &d__1, &a[a_offset], &c__1);
  1681. i__1 = *n * (*n + 1) / 2;
  1682. dscal_(&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. d__1 = 1. / onorm;
  1688. dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1689. i__2 = kll + kuu + 1;
  1690. dscal_(&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. d__1 = *anorm / onorm;
  1700. dscal_(m, &d__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. d__1 = *anorm / onorm;
  1706. dscal_(&i__1, &d__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. d__1 = *anorm / onorm;
  1712. dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1713. /* L540: */
  1714. }
  1715. }
  1716. }
  1717. }
  1718. /* End of DLATMR */
  1719. return 0;
  1720. } /* dlatmr_ */