You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

zlatmr.c 65 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109
  1. #include <math.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <complex.h>
  6. #ifdef complex
  7. #undef complex
  8. #endif
  9. #ifdef I
  10. #undef I
  11. #endif
  12. #if defined(_WIN64)
  13. typedef long long BLASLONG;
  14. typedef unsigned long long BLASULONG;
  15. #else
  16. typedef long BLASLONG;
  17. typedef unsigned long BLASULONG;
  18. #endif
  19. #ifdef LAPACK_ILP64
  20. typedef BLASLONG blasint;
  21. #if defined(_WIN64)
  22. #define blasabs(x) llabs(x)
  23. #else
  24. #define blasabs(x) labs(x)
  25. #endif
  26. #else
  27. typedef int blasint;
  28. #define blasabs(x) abs(x)
  29. #endif
  30. typedef blasint integer;
  31. typedef unsigned int uinteger;
  32. typedef char *address;
  33. typedef short int shortint;
  34. typedef float real;
  35. typedef double doublereal;
  36. typedef struct { real r, i; } complex;
  37. typedef struct { doublereal r, i; } doublecomplex;
  38. #ifdef _MSC_VER
  39. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  40. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  41. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  42. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  43. #else
  44. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  46. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  47. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  48. #endif
  49. #define pCf(z) (*_pCf(z))
  50. #define pCd(z) (*_pCd(z))
  51. typedef int logical;
  52. typedef short int shortlogical;
  53. typedef char logical1;
  54. typedef char integer1;
  55. #define TRUE_ (1)
  56. #define FALSE_ (0)
  57. /* Extern is for use with -E */
  58. #ifndef Extern
  59. #define Extern extern
  60. #endif
  61. /* I/O stuff */
  62. typedef int flag;
  63. typedef int ftnlen;
  64. typedef int ftnint;
  65. /*external read, write*/
  66. typedef struct
  67. { flag cierr;
  68. ftnint ciunit;
  69. flag ciend;
  70. char *cifmt;
  71. ftnint cirec;
  72. } cilist;
  73. /*internal read, write*/
  74. typedef struct
  75. { flag icierr;
  76. char *iciunit;
  77. flag iciend;
  78. char *icifmt;
  79. ftnint icirlen;
  80. ftnint icirnum;
  81. } icilist;
  82. /*open*/
  83. typedef struct
  84. { flag oerr;
  85. ftnint ounit;
  86. char *ofnm;
  87. ftnlen ofnmlen;
  88. char *osta;
  89. char *oacc;
  90. char *ofm;
  91. ftnint orl;
  92. char *oblnk;
  93. } olist;
  94. /*close*/
  95. typedef struct
  96. { flag cerr;
  97. ftnint cunit;
  98. char *csta;
  99. } cllist;
  100. /*rewind, backspace, endfile*/
  101. typedef struct
  102. { flag aerr;
  103. ftnint aunit;
  104. } alist;
  105. /* inquire */
  106. typedef struct
  107. { flag inerr;
  108. ftnint inunit;
  109. char *infile;
  110. ftnlen infilen;
  111. ftnint *inex; /*parameters in standard's order*/
  112. ftnint *inopen;
  113. ftnint *innum;
  114. ftnint *innamed;
  115. char *inname;
  116. ftnlen innamlen;
  117. char *inacc;
  118. ftnlen inacclen;
  119. char *inseq;
  120. ftnlen inseqlen;
  121. char *indir;
  122. ftnlen indirlen;
  123. char *infmt;
  124. ftnlen infmtlen;
  125. char *inform;
  126. ftnint informlen;
  127. char *inunf;
  128. ftnlen inunflen;
  129. ftnint *inrecl;
  130. ftnint *innrec;
  131. char *inblank;
  132. ftnlen inblanklen;
  133. } inlist;
  134. #define VOID void
  135. union Multitype { /* for multiple entry points */
  136. integer1 g;
  137. shortint h;
  138. integer i;
  139. /* longint j; */
  140. real r;
  141. doublereal d;
  142. complex c;
  143. doublecomplex z;
  144. };
  145. typedef union Multitype Multitype;
  146. struct Vardesc { /* for Namelist */
  147. char *name;
  148. char *addr;
  149. ftnlen *dims;
  150. int type;
  151. };
  152. typedef struct Vardesc Vardesc;
  153. struct Namelist {
  154. char *name;
  155. Vardesc **vars;
  156. int nvars;
  157. };
  158. typedef struct Namelist Namelist;
  159. #define abs(x) ((x) >= 0 ? (x) : -(x))
  160. #define dabs(x) (fabs(x))
  161. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  162. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  163. #define dmin(a,b) (f2cmin(a,b))
  164. #define dmax(a,b) (f2cmax(a,b))
  165. #define bit_test(a,b) ((a) >> (b) & 1)
  166. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  167. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  168. #define abort_() { sig_die("Fortran abort routine called", 1); }
  169. #define c_abs(z) (cabsf(Cf(z)))
  170. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  171. #ifdef _MSC_VER
  172. #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
  173. #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);}
  174. #else
  175. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  176. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  177. #endif
  178. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  179. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  180. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  181. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  182. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  183. #define d_abs(x) (fabs(*(x)))
  184. #define d_acos(x) (acos(*(x)))
  185. #define d_asin(x) (asin(*(x)))
  186. #define d_atan(x) (atan(*(x)))
  187. #define d_atn2(x, y) (atan2(*(x),*(y)))
  188. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  189. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  190. #define d_cos(x) (cos(*(x)))
  191. #define d_cosh(x) (cosh(*(x)))
  192. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  193. #define d_exp(x) (exp(*(x)))
  194. #define d_imag(z) (cimag(Cd(z)))
  195. #define r_imag(z) (cimagf(Cf(z)))
  196. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  198. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  200. #define d_log(x) (log(*(x)))
  201. #define d_mod(x, y) (fmod(*(x), *(y)))
  202. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  203. #define d_nint(x) u_nint(*(x))
  204. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  205. #define d_sign(a,b) u_sign(*(a),*(b))
  206. #define r_sign(a,b) u_sign(*(a),*(b))
  207. #define d_sin(x) (sin(*(x)))
  208. #define d_sinh(x) (sinh(*(x)))
  209. #define d_sqrt(x) (sqrt(*(x)))
  210. #define d_tan(x) (tan(*(x)))
  211. #define d_tanh(x) (tanh(*(x)))
  212. #define i_abs(x) abs(*(x))
  213. #define i_dnnt(x) ((integer)u_nint(*(x)))
  214. #define i_len(s, n) (n)
  215. #define i_nint(x) ((integer)u_nint(*(x)))
  216. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  217. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  218. #define pow_si(B,E) spow_ui(*(B),*(E))
  219. #define pow_ri(B,E) spow_ui(*(B),*(E))
  220. #define pow_di(B,E) dpow_ui(*(B),*(E))
  221. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  222. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  223. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  224. #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
  225. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  226. #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
  227. #define sig_die(s, kill) { exit(1); }
  228. #define s_stop(s, n) {exit(0);}
  229. 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 ZLATMR */
  489. /* =========== DOCUMENTATION =========== */
  490. /* Online html documentation available at */
  491. /* http://www.netlib.org/lapack/explore-html/ */
  492. /* Definition: */
  493. /* =========== */
  494. /* SUBROUTINE ZLATMR( 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, SPARSE */
  501. /* COMPLEX*16 DMAX */
  502. /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
  503. /* COMPLEX*16 A( LDA, * ), D( * ), DL( * ), DR( * ) */
  504. /* > \par Purpose: */
  505. /* ============= */
  506. /* > */
  507. /* > \verbatim */
  508. /* > */
  509. /* > ZLATMR generates random matrices of various types for testing */
  510. /* > LAPACK programs. */
  511. /* > */
  512. /* > ZLATMR operates by applying the following sequence of */
  513. /* > operations: */
  514. /* > */
  515. /* > Generate a matrix A with random entries of distribution DIST */
  516. /* > which is symmetric if SYM='S', Hermitian if SYM='H', and */
  517. /* > nonsymmetric if SYM='N'. */
  518. /* > */
  519. /* > Set the diagonal to D, where D may be input or */
  520. /* > computed according to MODE, COND, DMAX and RSIGN */
  521. /* > as described below. */
  522. /* > */
  523. /* > Grade the matrix, if desired, from the left and/or right */
  524. /* > as specified by GRADE. The inputs DL, MODEL, CONDL, DR, */
  525. /* > MODER and CONDR also determine the grading as described */
  526. /* > below. */
  527. /* > */
  528. /* > Permute, if desired, the rows and/or columns as specified by */
  529. /* > PIVTNG and IPIVOT. */
  530. /* > */
  531. /* > Set random entries to zero, if desired, to get a random sparse */
  532. /* > matrix as specified by SPARSE. */
  533. /* > */
  534. /* > Make A a band matrix, if desired, by zeroing out the matrix */
  535. /* > outside a band of lower bandwidth KL and upper bandwidth KU. */
  536. /* > */
  537. /* > Scale A, if desired, to have maximum entry ANORM. */
  538. /* > */
  539. /* > Pack the matrix if desired. Options specified by PACK are: */
  540. /* > no packing */
  541. /* > zero out upper half (if symmetric or Hermitian) */
  542. /* > zero out lower half (if symmetric or Hermitian) */
  543. /* > store the upper half columnwise (if symmetric or Hermitian */
  544. /* > or square upper triangular) */
  545. /* > store the lower half columnwise (if symmetric or Hermitian */
  546. /* > or square lower triangular) */
  547. /* > same as upper half rowwise if symmetric */
  548. /* > same as conjugate upper half rowwise if Hermitian */
  549. /* > store the lower triangle in banded format */
  550. /* > (if symmetric or Hermitian) */
  551. /* > store the upper triangle in banded format */
  552. /* > (if symmetric or Hermitian) */
  553. /* > store the entire matrix in banded format */
  554. /* > */
  555. /* > Note: If two calls to ZLATMR differ only in the PACK parameter, */
  556. /* > they will generate mathematically equivalent matrices. */
  557. /* > */
  558. /* > If two calls to ZLATMR both have full bandwidth (KL = M-1 */
  559. /* > and KU = N-1), and differ only in the PIVTNG and PACK */
  560. /* > parameters, then the matrices generated will differ only */
  561. /* > in the order of the rows and/or columns, and otherwise */
  562. /* > contain the same data. This consistency cannot be and */
  563. /* > is not maintained with less than full bandwidth. */
  564. /* > \endverbatim */
  565. /* Arguments: */
  566. /* ========== */
  567. /* > \param[in] M */
  568. /* > \verbatim */
  569. /* > M is INTEGER */
  570. /* > Number of rows of A. Not modified. */
  571. /* > \endverbatim */
  572. /* > */
  573. /* > \param[in] N */
  574. /* > \verbatim */
  575. /* > N is INTEGER */
  576. /* > Number of columns of A. Not modified. */
  577. /* > \endverbatim */
  578. /* > */
  579. /* > \param[in] DIST */
  580. /* > \verbatim */
  581. /* > DIST is CHARACTER*1 */
  582. /* > On entry, DIST specifies the type of distribution to be used */
  583. /* > to generate a random matrix . */
  584. /* > 'U' => real and imaginary parts are independent */
  585. /* > UNIFORM( 0, 1 ) ( 'U' for uniform ) */
  586. /* > 'S' => real and imaginary parts are independent */
  587. /* > UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
  588. /* > 'N' => real and imaginary parts are independent */
  589. /* > NORMAL( 0, 1 ) ( 'N' for normal ) */
  590. /* > 'D' => uniform on interior of unit disk ( 'D' for disk ) */
  591. /* > Not modified. */
  592. /* > \endverbatim */
  593. /* > */
  594. /* > \param[in,out] ISEED */
  595. /* > \verbatim */
  596. /* > ISEED is INTEGER array, dimension (4) */
  597. /* > On entry ISEED specifies the seed of the random number */
  598. /* > generator. They should lie between 0 and 4095 inclusive, */
  599. /* > and ISEED(4) should be odd. The random number generator */
  600. /* > uses a linear congruential sequence limited to small */
  601. /* > integers, and so should produce machine independent */
  602. /* > random numbers. The values of ISEED are changed on */
  603. /* > exit, and can be used in the next call to ZLATMR */
  604. /* > to continue the same random number sequence. */
  605. /* > Changed on exit. */
  606. /* > \endverbatim */
  607. /* > */
  608. /* > \param[in] SYM */
  609. /* > \verbatim */
  610. /* > SYM is CHARACTER*1 */
  611. /* > If SYM='S', generated matrix is symmetric. */
  612. /* > If SYM='H', generated matrix is Hermitian. */
  613. /* > If SYM='N', generated matrix is nonsymmetric. */
  614. /* > Not modified. */
  615. /* > \endverbatim */
  616. /* > */
  617. /* > \param[in,out] D */
  618. /* > \verbatim */
  619. /* > D is COMPLEX*16 array, dimension (f2cmin(M,N)) */
  620. /* > On entry this array specifies the diagonal entries */
  621. /* > of the diagonal of A. D may either be specified */
  622. /* > on entry, or set according to MODE and COND as described */
  623. /* > below. If the matrix is Hermitian, the real part of D */
  624. /* > will be taken. May be changed on exit if MODE is nonzero. */
  625. /* > \endverbatim */
  626. /* > */
  627. /* > \param[in] MODE */
  628. /* > \verbatim */
  629. /* > MODE is INTEGER */
  630. /* > On entry describes how D is to be used: */
  631. /* > MODE = 0 means use D as input */
  632. /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
  633. /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
  634. /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
  635. /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
  636. /* > MODE = 5 sets D to random numbers in the range */
  637. /* > ( 1/COND , 1 ) such that their logarithms */
  638. /* > are uniformly distributed. */
  639. /* > MODE = 6 set D to random numbers from same distribution */
  640. /* > as the rest of the matrix. */
  641. /* > MODE < 0 has the same meaning as ABS(MODE), except that */
  642. /* > the order of the elements of D is reversed. */
  643. /* > Thus if MODE is positive, D has entries ranging from */
  644. /* > 1 to 1/COND, if negative, from 1/COND to 1, */
  645. /* > Not modified. */
  646. /* > \endverbatim */
  647. /* > */
  648. /* > \param[in] COND */
  649. /* > \verbatim */
  650. /* > COND is DOUBLE PRECISION */
  651. /* > On entry, used as described under MODE above. */
  652. /* > If used, it must be >= 1. Not modified. */
  653. /* > \endverbatim */
  654. /* > */
  655. /* > \param[in] DMAX */
  656. /* > \verbatim */
  657. /* > DMAX is COMPLEX*16 */
  658. /* > If MODE neither -6, 0 nor 6, the diagonal is scaled by */
  659. /* > DMAX / f2cmax(abs(D(i))), so that maximum absolute entry */
  660. /* > of diagonal is abs(DMAX). If DMAX is complex (or zero), */
  661. /* > diagonal will be scaled by a complex number (or zero). */
  662. /* > \endverbatim */
  663. /* > */
  664. /* > \param[in] RSIGN */
  665. /* > \verbatim */
  666. /* > RSIGN is CHARACTER*1 */
  667. /* > If MODE neither -6, 0 nor 6, specifies sign of diagonal */
  668. /* > as follows: */
  669. /* > 'T' => diagonal entries are multiplied by a random complex */
  670. /* > number uniformly distributed with absolute value 1 */
  671. /* > 'F' => diagonal unchanged */
  672. /* > Not modified. */
  673. /* > \endverbatim */
  674. /* > */
  675. /* > \param[in] GRADE */
  676. /* > \verbatim */
  677. /* > GRADE is CHARACTER*1 */
  678. /* > Specifies grading of matrix as follows: */
  679. /* > 'N' => no grading */
  680. /* > 'L' => matrix premultiplied by diag( DL ) */
  681. /* > (only if matrix nonsymmetric) */
  682. /* > 'R' => matrix postmultiplied by diag( DR ) */
  683. /* > (only if matrix nonsymmetric) */
  684. /* > 'B' => matrix premultiplied by diag( DL ) and */
  685. /* > postmultiplied by diag( DR ) */
  686. /* > (only if matrix nonsymmetric) */
  687. /* > 'H' => matrix premultiplied by diag( DL ) and */
  688. /* > postmultiplied by diag( CONJG(DL) ) */
  689. /* > (only if matrix Hermitian or nonsymmetric) */
  690. /* > 'S' => matrix premultiplied by diag( DL ) and */
  691. /* > postmultiplied by diag( DL ) */
  692. /* > (only if matrix symmetric or nonsymmetric) */
  693. /* > 'E' => matrix premultiplied by diag( DL ) and */
  694. /* > postmultiplied by inv( diag( DL ) ) */
  695. /* > ( 'S' for similarity ) */
  696. /* > (only if matrix nonsymmetric) */
  697. /* > Note: if GRADE='S', then M must equal N. */
  698. /* > Not modified. */
  699. /* > \endverbatim */
  700. /* > */
  701. /* > \param[in,out] DL */
  702. /* > \verbatim */
  703. /* > DL is COMPLEX*16 array, dimension (M) */
  704. /* > If MODEL=0, then on entry this array specifies the diagonal */
  705. /* > entries of a diagonal matrix used as described under GRADE */
  706. /* > above. If MODEL is not zero, then DL will be set according */
  707. /* > to MODEL and CONDL, analogous to the way D is set according */
  708. /* > to MODE and COND (except there is no DMAX parameter for DL). */
  709. /* > If GRADE='E', then DL cannot have zero entries. */
  710. /* > Not referenced if GRADE = 'N' or 'R'. Changed on exit. */
  711. /* > \endverbatim */
  712. /* > */
  713. /* > \param[in] MODEL */
  714. /* > \verbatim */
  715. /* > MODEL is INTEGER */
  716. /* > This specifies how the diagonal array DL is to be computed, */
  717. /* > just as MODE specifies how D is to be computed. */
  718. /* > Not modified. */
  719. /* > \endverbatim */
  720. /* > */
  721. /* > \param[in] CONDL */
  722. /* > \verbatim */
  723. /* > CONDL is DOUBLE PRECISION */
  724. /* > When MODEL is not zero, this specifies the condition number */
  725. /* > of the computed DL. Not modified. */
  726. /* > \endverbatim */
  727. /* > */
  728. /* > \param[in,out] DR */
  729. /* > \verbatim */
  730. /* > DR is COMPLEX*16 array, dimension (N) */
  731. /* > If MODER=0, then on entry this array specifies the diagonal */
  732. /* > entries of a diagonal matrix used as described under GRADE */
  733. /* > above. If MODER is not zero, then DR will be set according */
  734. /* > to MODER and CONDR, analogous to the way D is set according */
  735. /* > to MODE and COND (except there is no DMAX parameter for DR). */
  736. /* > Not referenced if GRADE = 'N', 'L', 'H' or 'S'. */
  737. /* > Changed on exit. */
  738. /* > \endverbatim */
  739. /* > */
  740. /* > \param[in] MODER */
  741. /* > \verbatim */
  742. /* > MODER is INTEGER */
  743. /* > This specifies how the diagonal array DR is to be computed, */
  744. /* > just as MODE specifies how D is to be computed. */
  745. /* > Not modified. */
  746. /* > \endverbatim */
  747. /* > */
  748. /* > \param[in] CONDR */
  749. /* > \verbatim */
  750. /* > CONDR is DOUBLE PRECISION */
  751. /* > When MODER is not zero, this specifies the condition number */
  752. /* > of the computed DR. Not modified. */
  753. /* > \endverbatim */
  754. /* > */
  755. /* > \param[in] PIVTNG */
  756. /* > \verbatim */
  757. /* > PIVTNG is CHARACTER*1 */
  758. /* > On entry specifies pivoting permutations as follows: */
  759. /* > 'N' or ' ' => none. */
  760. /* > 'L' => left or row pivoting (matrix must be nonsymmetric). */
  761. /* > 'R' => right or column pivoting (matrix must be */
  762. /* > nonsymmetric). */
  763. /* > 'B' or 'F' => both or full pivoting, i.e., on both sides. */
  764. /* > In this case, M must equal N */
  765. /* > */
  766. /* > If two calls to ZLATMR both have full bandwidth (KL = M-1 */
  767. /* > and KU = N-1), and differ only in the PIVTNG and PACK */
  768. /* > parameters, then the matrices generated will differ only */
  769. /* > in the order of the rows and/or columns, and otherwise */
  770. /* > contain the same data. This consistency cannot be */
  771. /* > maintained with less than full bandwidth. */
  772. /* > \endverbatim */
  773. /* > */
  774. /* > \param[in] IPIVOT */
  775. /* > \verbatim */
  776. /* > IPIVOT is INTEGER array, dimension (N or M) */
  777. /* > This array specifies the permutation used. After the */
  778. /* > basic matrix is generated, the rows, columns, or both */
  779. /* > are permuted. If, say, row pivoting is selected, ZLATMR */
  780. /* > starts with the *last* row and interchanges the M-th and */
  781. /* > IPIVOT(M)-th rows, then moves to the next-to-last row, */
  782. /* > interchanging the (M-1)-th and the IPIVOT(M-1)-th rows, */
  783. /* > and so on. In terms of "2-cycles", the permutation is */
  784. /* > (1 IPIVOT(1)) (2 IPIVOT(2)) ... (M IPIVOT(M)) */
  785. /* > where the rightmost cycle is applied first. This is the */
  786. /* > *inverse* of the effect of pivoting in LINPACK. The idea */
  787. /* > is that factoring (with pivoting) an identity matrix */
  788. /* > which has been inverse-pivoted in this way should */
  789. /* > result in a pivot vector identical to IPIVOT. */
  790. /* > Not referenced if PIVTNG = 'N'. Not modified. */
  791. /* > \endverbatim */
  792. /* > */
  793. /* > \param[in] KL */
  794. /* > \verbatim */
  795. /* > KL is INTEGER */
  796. /* > On entry specifies the lower bandwidth of the matrix. For */
  797. /* > example, KL=0 implies upper triangular, KL=1 implies upper */
  798. /* > Hessenberg, and KL at least M-1 implies the matrix is not */
  799. /* > banded. Must equal KU if matrix is symmetric or Hermitian. */
  800. /* > Not modified. */
  801. /* > \endverbatim */
  802. /* > */
  803. /* > \param[in] KU */
  804. /* > \verbatim */
  805. /* > KU is INTEGER */
  806. /* > On entry specifies the upper bandwidth of the matrix. For */
  807. /* > example, KU=0 implies lower triangular, KU=1 implies lower */
  808. /* > Hessenberg, and KU at least N-1 implies the matrix is not */
  809. /* > banded. Must equal KL if matrix is symmetric or Hermitian. */
  810. /* > Not modified. */
  811. /* > \endverbatim */
  812. /* > */
  813. /* > \param[in] SPARSE */
  814. /* > \verbatim */
  815. /* > SPARSE is DOUBLE PRECISION */
  816. /* > On entry specifies the sparsity of the matrix if a sparse */
  817. /* > matrix is to be generated. SPARSE should lie between */
  818. /* > 0 and 1. To generate a sparse matrix, for each matrix entry */
  819. /* > a uniform ( 0, 1 ) random number x is generated and */
  820. /* > compared to SPARSE; if x is larger the matrix entry */
  821. /* > is unchanged and if x is smaller the entry is set */
  822. /* > to zero. Thus on the average a fraction SPARSE of the */
  823. /* > entries will be set to zero. */
  824. /* > Not modified. */
  825. /* > \endverbatim */
  826. /* > */
  827. /* > \param[in] ANORM */
  828. /* > \verbatim */
  829. /* > ANORM is DOUBLE PRECISION */
  830. /* > On entry specifies maximum entry of output matrix */
  831. /* > (output matrix will by multiplied by a constant so that */
  832. /* > its largest absolute entry equal ANORM) */
  833. /* > if ANORM is nonnegative. If ANORM is negative no scaling */
  834. /* > is done. Not modified. */
  835. /* > \endverbatim */
  836. /* > */
  837. /* > \param[in] PACK */
  838. /* > \verbatim */
  839. /* > PACK is CHARACTER*1 */
  840. /* > On entry specifies packing of matrix as follows: */
  841. /* > 'N' => no packing */
  842. /* > 'U' => zero out all subdiagonal entries */
  843. /* > (if symmetric or Hermitian) */
  844. /* > 'L' => zero out all superdiagonal entries */
  845. /* > (if symmetric or Hermitian) */
  846. /* > 'C' => store the upper triangle columnwise */
  847. /* > (only if matrix symmetric or Hermitian or */
  848. /* > square upper triangular) */
  849. /* > 'R' => store the lower triangle columnwise */
  850. /* > (only if matrix symmetric or Hermitian or */
  851. /* > square lower triangular) */
  852. /* > (same as upper half rowwise if symmetric) */
  853. /* > (same as conjugate upper half rowwise if Hermitian) */
  854. /* > 'B' => store the lower triangle in band storage scheme */
  855. /* > (only if matrix symmetric or Hermitian) */
  856. /* > 'Q' => store the upper triangle in band storage scheme */
  857. /* > (only if matrix symmetric or Hermitian) */
  858. /* > 'Z' => store the entire matrix in band storage scheme */
  859. /* > (pivoting can be provided for by using this */
  860. /* > option to store A in the trailing rows of */
  861. /* > the allocated storage) */
  862. /* > */
  863. /* > Using these options, the various LAPACK packed and banded */
  864. /* > storage schemes can be obtained: */
  865. /* > GB - use 'Z' */
  866. /* > PB, HB or TB - use 'B' or 'Q' */
  867. /* > PP, HP or TP - use 'C' or 'R' */
  868. /* > */
  869. /* > If two calls to ZLATMR differ only in the PACK parameter, */
  870. /* > they will generate mathematically equivalent matrices. */
  871. /* > Not modified. */
  872. /* > \endverbatim */
  873. /* > */
  874. /* > \param[in,out] A */
  875. /* > \verbatim */
  876. /* > A is COMPLEX*16 array, dimension (LDA,N) */
  877. /* > On exit A is the desired test matrix. Only those */
  878. /* > entries of A which are significant on output */
  879. /* > will be referenced (even if A is in packed or band */
  880. /* > storage format). The 'unoccupied corners' of A in */
  881. /* > band format will be zeroed out. */
  882. /* > \endverbatim */
  883. /* > */
  884. /* > \param[in] LDA */
  885. /* > \verbatim */
  886. /* > LDA is INTEGER */
  887. /* > on entry LDA specifies the first dimension of A as */
  888. /* > declared in the calling program. */
  889. /* > If PACK='N', 'U' or 'L', LDA must be at least f2cmax ( 1, M ). */
  890. /* > If PACK='C' or 'R', LDA must be at least 1. */
  891. /* > If PACK='B', or 'Q', LDA must be MIN ( KU+1, N ) */
  892. /* > If PACK='Z', LDA must be at least KUU+KLL+1, where */
  893. /* > KUU = MIN ( KU, N-1 ) and KLL = MIN ( KL, M-1 ) */
  894. /* > Not modified. */
  895. /* > \endverbatim */
  896. /* > */
  897. /* > \param[out] IWORK */
  898. /* > \verbatim */
  899. /* > IWORK is INTEGER array, dimension (N or M) */
  900. /* > Workspace. Not referenced if PIVTNG = 'N'. Changed on exit. */
  901. /* > \endverbatim */
  902. /* > */
  903. /* > \param[out] INFO */
  904. /* > \verbatim */
  905. /* > INFO is INTEGER */
  906. /* > Error parameter on exit: */
  907. /* > 0 => normal return */
  908. /* > -1 => M negative or unequal to N and SYM='S' or 'H' */
  909. /* > -2 => N negative */
  910. /* > -3 => DIST illegal string */
  911. /* > -5 => SYM illegal string */
  912. /* > -7 => MODE not in range -6 to 6 */
  913. /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
  914. /* > -10 => MODE neither -6, 0 nor 6 and RSIGN illegal string */
  915. /* > -11 => GRADE illegal string, or GRADE='E' and */
  916. /* > M not equal to N, or GRADE='L', 'R', 'B', 'S' or 'E' */
  917. /* > and SYM = 'H', or GRADE='L', 'R', 'B', 'H' or 'E' */
  918. /* > and SYM = 'S' */
  919. /* > -12 => GRADE = 'E' and DL contains zero */
  920. /* > -13 => MODEL not in range -6 to 6 and GRADE= 'L', 'B', 'H', */
  921. /* > 'S' or 'E' */
  922. /* > -14 => CONDL less than 1.0, GRADE='L', 'B', 'H', 'S' or 'E', */
  923. /* > and MODEL neither -6, 0 nor 6 */
  924. /* > -16 => MODER not in range -6 to 6 and GRADE= 'R' or 'B' */
  925. /* > -17 => CONDR less than 1.0, GRADE='R' or 'B', and */
  926. /* > MODER neither -6, 0 nor 6 */
  927. /* > -18 => PIVTNG illegal string, or PIVTNG='B' or 'F' and */
  928. /* > M not equal to N, or PIVTNG='L' or 'R' and SYM='S' */
  929. /* > or 'H' */
  930. /* > -19 => IPIVOT contains out of range number and */
  931. /* > PIVTNG not equal to 'N' */
  932. /* > -20 => KL negative */
  933. /* > -21 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
  934. /* > -22 => SPARSE not in range 0. to 1. */
  935. /* > -24 => PACK illegal string, or PACK='U', 'L', 'B' or 'Q' */
  936. /* > and SYM='N', or PACK='C' and SYM='N' and either KL */
  937. /* > not equal to 0 or N not equal to M, or PACK='R' and */
  938. /* > SYM='N', and either KU not equal to 0 or N not equal */
  939. /* > to M */
  940. /* > -26 => LDA too small */
  941. /* > 1 => Error return from ZLATM1 (computing D) */
  942. /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
  943. /* > 3 => Error return from ZLATM1 (computing DL) */
  944. /* > 4 => Error return from ZLATM1 (computing DR) */
  945. /* > 5 => ANORM is positive, but matrix constructed prior to */
  946. /* > attempting to scale it to have norm ANORM, is zero */
  947. /* > \endverbatim */
  948. /* Authors: */
  949. /* ======== */
  950. /* > \author Univ. of Tennessee */
  951. /* > \author Univ. of California Berkeley */
  952. /* > \author Univ. of Colorado Denver */
  953. /* > \author NAG Ltd. */
  954. /* > \date December 2016 */
  955. /* > \ingroup complex16_matgen */
  956. /* ===================================================================== */
  957. /* Subroutine */ void zlatmr_(integer *m, integer *n, char *dist, integer *
  958. iseed, char *sym, doublecomplex *d__, integer *mode, doublereal *cond,
  959. doublecomplex *dmax__, char *rsign, char *grade, doublecomplex *dl,
  960. integer *model, doublereal *condl, doublecomplex *dr, integer *moder,
  961. doublereal *condr, char *pivtng, integer *ipivot, integer *kl,
  962. integer *ku, doublereal *sparse, doublereal *anorm, char *pack,
  963. doublecomplex *a, integer *lda, integer *iwork, integer *info)
  964. {
  965. /* System generated locals */
  966. integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
  967. doublereal d__1, d__2;
  968. doublecomplex z__1, z__2;
  969. /* Local variables */
  970. integer isub, jsub;
  971. doublereal temp;
  972. integer isym, i__, j, k, ipack;
  973. extern logical lsame_(char *, char *);
  974. doublereal tempa[1];
  975. doublecomplex ctemp;
  976. integer iisub, idist, jjsub, mnmin;
  977. logical dzero;
  978. integer mnsub;
  979. doublereal onorm;
  980. integer mxsub, npvts;
  981. extern /* Subroutine */ void zlatm1_(integer *, doublereal *, integer *,
  982. integer *, integer *, doublecomplex *, integer *, integer *);
  983. extern /* Double Complex */ VOID zlatm2_(doublecomplex *, integer *,
  984. integer *, integer *, integer *, integer *, integer *, integer *,
  985. integer *, doublecomplex *, integer *, doublecomplex *,
  986. doublecomplex *, integer *, integer *, doublereal *), zlatm3_(
  987. doublecomplex *, integer *, integer *, integer *, integer *,
  988. integer *, integer *, integer *, integer *, integer *, integer *,
  989. doublecomplex *, integer *, doublecomplex *, doublecomplex *,
  990. integer *, integer *, doublereal *);
  991. doublecomplex calpha;
  992. integer igrade;
  993. logical fulbnd;
  994. extern doublereal zlangb_(char *, integer *, integer *, integer *,
  995. doublecomplex *, integer *, doublereal *);
  996. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  997. logical badpvt;
  998. extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
  999. integer *, doublereal *);
  1000. extern /* Subroutine */ void zdscal_(integer *, doublereal *,
  1001. doublecomplex *, integer *);
  1002. extern doublereal zlansb_(char *, char *, integer *, integer *,
  1003. doublecomplex *, integer *, doublereal *);
  1004. integer irsign, ipvtng;
  1005. extern doublereal zlansp_(char *, char *, integer *, doublecomplex *,
  1006. doublereal *), zlansy_(char *, char *, integer *,
  1007. doublecomplex *, integer *, doublereal *);
  1008. integer kll, kuu;
  1009. /* -- LAPACK computational routine (version 3.7.0) -- */
  1010. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  1011. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  1012. /* December 2016 */
  1013. /* ===================================================================== */
  1014. /* 1) Decode and Test the input parameters. */
  1015. /* Initialize flags & seed. */
  1016. /* Parameter adjustments */
  1017. --iseed;
  1018. --d__;
  1019. --dl;
  1020. --dr;
  1021. --ipivot;
  1022. a_dim1 = *lda;
  1023. a_offset = 1 + a_dim1 * 1;
  1024. a -= a_offset;
  1025. --iwork;
  1026. /* Function Body */
  1027. *info = 0;
  1028. /* Quick return if possible */
  1029. if (*m == 0 || *n == 0) {
  1030. return;
  1031. }
  1032. /* Decode DIST */
  1033. if (lsame_(dist, "U")) {
  1034. idist = 1;
  1035. } else if (lsame_(dist, "S")) {
  1036. idist = 2;
  1037. } else if (lsame_(dist, "N")) {
  1038. idist = 3;
  1039. } else if (lsame_(dist, "D")) {
  1040. idist = 4;
  1041. } else {
  1042. idist = -1;
  1043. }
  1044. /* Decode SYM */
  1045. if (lsame_(sym, "H")) {
  1046. isym = 0;
  1047. } else if (lsame_(sym, "N")) {
  1048. isym = 1;
  1049. } else if (lsame_(sym, "S")) {
  1050. isym = 2;
  1051. } else {
  1052. isym = -1;
  1053. }
  1054. /* Decode RSIGN */
  1055. if (lsame_(rsign, "F")) {
  1056. irsign = 0;
  1057. } else if (lsame_(rsign, "T")) {
  1058. irsign = 1;
  1059. } else {
  1060. irsign = -1;
  1061. }
  1062. /* Decode PIVTNG */
  1063. if (lsame_(pivtng, "N")) {
  1064. ipvtng = 0;
  1065. } else if (lsame_(pivtng, " ")) {
  1066. ipvtng = 0;
  1067. } else if (lsame_(pivtng, "L")) {
  1068. ipvtng = 1;
  1069. npvts = *m;
  1070. } else if (lsame_(pivtng, "R")) {
  1071. ipvtng = 2;
  1072. npvts = *n;
  1073. } else if (lsame_(pivtng, "B")) {
  1074. ipvtng = 3;
  1075. npvts = f2cmin(*n,*m);
  1076. } else if (lsame_(pivtng, "F")) {
  1077. ipvtng = 3;
  1078. npvts = f2cmin(*n,*m);
  1079. } else {
  1080. ipvtng = -1;
  1081. }
  1082. /* Decode GRADE */
  1083. if (lsame_(grade, "N")) {
  1084. igrade = 0;
  1085. } else if (lsame_(grade, "L")) {
  1086. igrade = 1;
  1087. } else if (lsame_(grade, "R")) {
  1088. igrade = 2;
  1089. } else if (lsame_(grade, "B")) {
  1090. igrade = 3;
  1091. } else if (lsame_(grade, "E")) {
  1092. igrade = 4;
  1093. } else if (lsame_(grade, "H")) {
  1094. igrade = 5;
  1095. } else if (lsame_(grade, "S")) {
  1096. igrade = 6;
  1097. } else {
  1098. igrade = -1;
  1099. }
  1100. /* Decode PACK */
  1101. if (lsame_(pack, "N")) {
  1102. ipack = 0;
  1103. } else if (lsame_(pack, "U")) {
  1104. ipack = 1;
  1105. } else if (lsame_(pack, "L")) {
  1106. ipack = 2;
  1107. } else if (lsame_(pack, "C")) {
  1108. ipack = 3;
  1109. } else if (lsame_(pack, "R")) {
  1110. ipack = 4;
  1111. } else if (lsame_(pack, "B")) {
  1112. ipack = 5;
  1113. } else if (lsame_(pack, "Q")) {
  1114. ipack = 6;
  1115. } else if (lsame_(pack, "Z")) {
  1116. ipack = 7;
  1117. } else {
  1118. ipack = -1;
  1119. }
  1120. /* Set certain internal parameters */
  1121. mnmin = f2cmin(*m,*n);
  1122. /* Computing MIN */
  1123. i__1 = *kl, i__2 = *m - 1;
  1124. kll = f2cmin(i__1,i__2);
  1125. /* Computing MIN */
  1126. i__1 = *ku, i__2 = *n - 1;
  1127. kuu = f2cmin(i__1,i__2);
  1128. /* If inv(DL) is used, check to see if DL has a zero entry. */
  1129. dzero = FALSE_;
  1130. if (igrade == 4 && *model == 0) {
  1131. i__1 = *m;
  1132. for (i__ = 1; i__ <= i__1; ++i__) {
  1133. i__2 = i__;
  1134. if (dl[i__2].r == 0. && dl[i__2].i == 0.) {
  1135. dzero = TRUE_;
  1136. }
  1137. /* L10: */
  1138. }
  1139. }
  1140. /* Check values in IPIVOT */
  1141. badpvt = FALSE_;
  1142. if (ipvtng > 0) {
  1143. i__1 = npvts;
  1144. for (j = 1; j <= i__1; ++j) {
  1145. if (ipivot[j] <= 0 || ipivot[j] > npvts) {
  1146. badpvt = TRUE_;
  1147. }
  1148. /* L20: */
  1149. }
  1150. }
  1151. /* Set INFO if an error */
  1152. if (*m < 0) {
  1153. *info = -1;
  1154. } else if (*m != *n && (isym == 0 || isym == 2)) {
  1155. *info = -1;
  1156. } else if (*n < 0) {
  1157. *info = -2;
  1158. } else if (idist == -1) {
  1159. *info = -3;
  1160. } else if (isym == -1) {
  1161. *info = -5;
  1162. } else if (*mode < -6 || *mode > 6) {
  1163. *info = -7;
  1164. } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.) {
  1165. *info = -8;
  1166. } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
  1167. *info = -10;
  1168. } else if (igrade == -1 || igrade == 4 && *m != *n || (igrade == 1 ||
  1169. igrade == 2 || igrade == 3 || igrade == 4 || igrade == 6) && isym
  1170. == 0 || (igrade == 1 || igrade == 2 || igrade == 3 || igrade == 4
  1171. || igrade == 5) && isym == 2) {
  1172. *info = -11;
  1173. } else if (igrade == 4 && dzero) {
  1174. *info = -12;
  1175. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
  1176. igrade == 6) && (*model < -6 || *model > 6)) {
  1177. *info = -13;
  1178. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
  1179. igrade == 6) && (*model != -6 && *model != 0 && *model != 6) && *
  1180. condl < 1.) {
  1181. *info = -14;
  1182. } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
  1183. *info = -16;
  1184. } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
  1185. *moder != 6) && *condr < 1.) {
  1186. *info = -17;
  1187. } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
  1188. ipvtng == 2) && (isym == 0 || isym == 2)) {
  1189. *info = -18;
  1190. } else if (ipvtng != 0 && badpvt) {
  1191. *info = -19;
  1192. } else if (*kl < 0) {
  1193. *info = -20;
  1194. } else if (*ku < 0 || (isym == 0 || isym == 2) && *kl != *ku) {
  1195. *info = -21;
  1196. } else if (*sparse < 0. || *sparse > 1.) {
  1197. *info = -22;
  1198. } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
  1199. ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
  1200. || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
  1201. {
  1202. *info = -24;
  1203. } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
  1204. (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
  1205. 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
  1206. *info = -26;
  1207. }
  1208. if (*info != 0) {
  1209. i__1 = -(*info);
  1210. xerbla_("ZLATMR", &i__1, 6);
  1211. return;
  1212. }
  1213. /* Decide if we can pivot consistently */
  1214. fulbnd = FALSE_;
  1215. if (kuu == *n - 1 && kll == *m - 1) {
  1216. fulbnd = TRUE_;
  1217. }
  1218. /* Initialize random number generator */
  1219. for (i__ = 1; i__ <= 4; ++i__) {
  1220. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  1221. /* L30: */
  1222. }
  1223. iseed[4] = (iseed[4] / 2 << 1) + 1;
  1224. /* 2) Set up D, DL, and DR, if indicated. */
  1225. /* Compute D according to COND and MODE */
  1226. zlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
  1227. if (*info != 0) {
  1228. *info = 1;
  1229. return;
  1230. }
  1231. if (*mode != 0 && *mode != -6 && *mode != 6) {
  1232. /* Scale by DMAX */
  1233. temp = z_abs(&d__[1]);
  1234. i__1 = mnmin;
  1235. for (i__ = 2; i__ <= i__1; ++i__) {
  1236. /* Computing MAX */
  1237. d__1 = temp, d__2 = z_abs(&d__[i__]);
  1238. temp = f2cmax(d__1,d__2);
  1239. /* L40: */
  1240. }
  1241. if (temp == 0. && (dmax__->r != 0. || dmax__->i != 0.)) {
  1242. *info = 2;
  1243. return;
  1244. }
  1245. if (temp != 0.) {
  1246. z__1.r = dmax__->r / temp, z__1.i = dmax__->i / temp;
  1247. calpha.r = z__1.r, calpha.i = z__1.i;
  1248. } else {
  1249. calpha.r = 1., calpha.i = 0.;
  1250. }
  1251. i__1 = mnmin;
  1252. for (i__ = 1; i__ <= i__1; ++i__) {
  1253. i__2 = i__;
  1254. i__3 = i__;
  1255. z__1.r = calpha.r * d__[i__3].r - calpha.i * d__[i__3].i, z__1.i =
  1256. calpha.r * d__[i__3].i + calpha.i * d__[i__3].r;
  1257. d__[i__2].r = z__1.r, d__[i__2].i = z__1.i;
  1258. /* L50: */
  1259. }
  1260. }
  1261. /* If matrix Hermitian, make D real */
  1262. if (isym == 0) {
  1263. i__1 = mnmin;
  1264. for (i__ = 1; i__ <= i__1; ++i__) {
  1265. i__2 = i__;
  1266. i__3 = i__;
  1267. d__1 = d__[i__3].r;
  1268. d__[i__2].r = d__1, d__[i__2].i = 0.;
  1269. /* L60: */
  1270. }
  1271. }
  1272. /* Compute DL if grading set */
  1273. if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || igrade ==
  1274. 6) {
  1275. zlatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
  1276. if (*info != 0) {
  1277. *info = 3;
  1278. return;
  1279. }
  1280. }
  1281. /* Compute DR if grading set */
  1282. if (igrade == 2 || igrade == 3) {
  1283. zlatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
  1284. if (*info != 0) {
  1285. *info = 4;
  1286. return;
  1287. }
  1288. }
  1289. /* 3) Generate IWORK if pivoting */
  1290. if (ipvtng > 0) {
  1291. i__1 = npvts;
  1292. for (i__ = 1; i__ <= i__1; ++i__) {
  1293. iwork[i__] = i__;
  1294. /* L70: */
  1295. }
  1296. if (fulbnd) {
  1297. i__1 = npvts;
  1298. for (i__ = 1; i__ <= i__1; ++i__) {
  1299. k = ipivot[i__];
  1300. j = iwork[i__];
  1301. iwork[i__] = iwork[k];
  1302. iwork[k] = j;
  1303. /* L80: */
  1304. }
  1305. } else {
  1306. for (i__ = npvts; i__ >= 1; --i__) {
  1307. k = ipivot[i__];
  1308. j = iwork[i__];
  1309. iwork[i__] = iwork[k];
  1310. iwork[k] = j;
  1311. /* L90: */
  1312. }
  1313. }
  1314. }
  1315. /* 4) Generate matrices for each kind of PACKing */
  1316. /* Always sweep matrix columnwise (if symmetric, upper */
  1317. /* half only) so that matrix generated does not depend */
  1318. /* on PACK */
  1319. if (fulbnd) {
  1320. /* Use ZLATM3 so matrices generated with differing PIVOTing only */
  1321. /* differ only in the order of their rows and/or columns. */
  1322. if (ipack == 0) {
  1323. if (isym == 0) {
  1324. i__1 = *n;
  1325. for (j = 1; j <= i__1; ++j) {
  1326. i__2 = j;
  1327. for (i__ = 1; i__ <= i__2; ++i__) {
  1328. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1329. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1330. dr[1], &ipvtng, &iwork[1], sparse);
  1331. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1332. i__3 = isub + jsub * a_dim1;
  1333. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1334. i__3 = jsub + isub * a_dim1;
  1335. d_cnjg(&z__1, &ctemp);
  1336. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1337. /* L100: */
  1338. }
  1339. /* L110: */
  1340. }
  1341. } else if (isym == 1) {
  1342. i__1 = *n;
  1343. for (j = 1; j <= i__1; ++j) {
  1344. i__2 = *m;
  1345. for (i__ = 1; i__ <= i__2; ++i__) {
  1346. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1347. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1348. dr[1], &ipvtng, &iwork[1], sparse);
  1349. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1350. i__3 = isub + jsub * a_dim1;
  1351. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1352. /* L120: */
  1353. }
  1354. /* L130: */
  1355. }
  1356. } else if (isym == 2) {
  1357. i__1 = *n;
  1358. for (j = 1; j <= i__1; ++j) {
  1359. i__2 = j;
  1360. for (i__ = 1; i__ <= i__2; ++i__) {
  1361. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1362. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1363. dr[1], &ipvtng, &iwork[1], sparse);
  1364. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1365. i__3 = isub + jsub * a_dim1;
  1366. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1367. i__3 = jsub + isub * a_dim1;
  1368. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1369. /* L140: */
  1370. }
  1371. /* L150: */
  1372. }
  1373. }
  1374. } else if (ipack == 1) {
  1375. i__1 = *n;
  1376. for (j = 1; j <= i__1; ++j) {
  1377. i__2 = j;
  1378. for (i__ = 1; i__ <= i__2; ++i__) {
  1379. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1380. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1381. , &ipvtng, &iwork[1], sparse);
  1382. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1383. mnsub = f2cmin(isub,jsub);
  1384. mxsub = f2cmax(isub,jsub);
  1385. if (mxsub == isub && isym == 0) {
  1386. i__3 = mnsub + mxsub * a_dim1;
  1387. d_cnjg(&z__1, &ctemp);
  1388. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1389. } else {
  1390. i__3 = mnsub + mxsub * a_dim1;
  1391. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1392. }
  1393. if (mnsub != mxsub) {
  1394. i__3 = mxsub + mnsub * a_dim1;
  1395. a[i__3].r = 0., a[i__3].i = 0.;
  1396. }
  1397. /* L160: */
  1398. }
  1399. /* L170: */
  1400. }
  1401. } else if (ipack == 2) {
  1402. i__1 = *n;
  1403. for (j = 1; j <= i__1; ++j) {
  1404. i__2 = j;
  1405. for (i__ = 1; i__ <= i__2; ++i__) {
  1406. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1407. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1408. , &ipvtng, &iwork[1], sparse);
  1409. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1410. mnsub = f2cmin(isub,jsub);
  1411. mxsub = f2cmax(isub,jsub);
  1412. if (mxsub == jsub && isym == 0) {
  1413. i__3 = mxsub + mnsub * a_dim1;
  1414. d_cnjg(&z__1, &ctemp);
  1415. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1416. } else {
  1417. i__3 = mxsub + mnsub * a_dim1;
  1418. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1419. }
  1420. if (mnsub != mxsub) {
  1421. i__3 = mnsub + mxsub * a_dim1;
  1422. a[i__3].r = 0., a[i__3].i = 0.;
  1423. }
  1424. /* L180: */
  1425. }
  1426. /* L190: */
  1427. }
  1428. } else if (ipack == 3) {
  1429. i__1 = *n;
  1430. for (j = 1; j <= i__1; ++j) {
  1431. i__2 = j;
  1432. for (i__ = 1; i__ <= i__2; ++i__) {
  1433. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1434. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1435. , &ipvtng, &iwork[1], sparse);
  1436. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1437. /* Compute K = location of (ISUB,JSUB) entry in packed */
  1438. /* array */
  1439. mnsub = f2cmin(isub,jsub);
  1440. mxsub = f2cmax(isub,jsub);
  1441. k = mxsub * (mxsub - 1) / 2 + mnsub;
  1442. /* Convert K to (IISUB,JJSUB) location */
  1443. jjsub = (k - 1) / *lda + 1;
  1444. iisub = k - *lda * (jjsub - 1);
  1445. if (mxsub == isub && isym == 0) {
  1446. i__3 = iisub + jjsub * a_dim1;
  1447. d_cnjg(&z__1, &ctemp);
  1448. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1449. } else {
  1450. i__3 = iisub + jjsub * a_dim1;
  1451. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1452. }
  1453. /* L200: */
  1454. }
  1455. /* L210: */
  1456. }
  1457. } else if (ipack == 4) {
  1458. i__1 = *n;
  1459. for (j = 1; j <= i__1; ++j) {
  1460. i__2 = j;
  1461. for (i__ = 1; i__ <= i__2; ++i__) {
  1462. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1463. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1464. , &ipvtng, &iwork[1], sparse);
  1465. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1466. /* Compute K = location of (I,J) entry in packed array */
  1467. mnsub = f2cmin(isub,jsub);
  1468. mxsub = f2cmax(isub,jsub);
  1469. if (mnsub == 1) {
  1470. k = mxsub;
  1471. } else {
  1472. k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
  1473. mnsub + 2) / 2 + mxsub - mnsub + 1;
  1474. }
  1475. /* Convert K to (IISUB,JJSUB) location */
  1476. jjsub = (k - 1) / *lda + 1;
  1477. iisub = k - *lda * (jjsub - 1);
  1478. if (mxsub == jsub && isym == 0) {
  1479. i__3 = iisub + jjsub * a_dim1;
  1480. d_cnjg(&z__1, &ctemp);
  1481. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1482. } else {
  1483. i__3 = iisub + jjsub * a_dim1;
  1484. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1485. }
  1486. /* L220: */
  1487. }
  1488. /* L230: */
  1489. }
  1490. } else if (ipack == 5) {
  1491. i__1 = *n;
  1492. for (j = 1; j <= i__1; ++j) {
  1493. i__2 = j;
  1494. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1495. if (i__ < 1) {
  1496. i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
  1497. a[i__3].r = 0., a[i__3].i = 0.;
  1498. } else {
  1499. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1500. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1501. dr[1], &ipvtng, &iwork[1], sparse);
  1502. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1503. mnsub = f2cmin(isub,jsub);
  1504. mxsub = f2cmax(isub,jsub);
  1505. if (mxsub == jsub && isym == 0) {
  1506. i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
  1507. d_cnjg(&z__1, &ctemp);
  1508. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1509. } else {
  1510. i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
  1511. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1512. }
  1513. }
  1514. /* L240: */
  1515. }
  1516. /* L250: */
  1517. }
  1518. } else if (ipack == 6) {
  1519. i__1 = *n;
  1520. for (j = 1; j <= i__1; ++j) {
  1521. i__2 = j;
  1522. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1523. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1524. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1525. , &ipvtng, &iwork[1], sparse);
  1526. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1527. mnsub = f2cmin(isub,jsub);
  1528. mxsub = f2cmax(isub,jsub);
  1529. if (mxsub == isub && isym == 0) {
  1530. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1531. d_cnjg(&z__1, &ctemp);
  1532. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1533. } else {
  1534. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1535. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1536. }
  1537. /* L260: */
  1538. }
  1539. /* L270: */
  1540. }
  1541. } else if (ipack == 7) {
  1542. if (isym != 1) {
  1543. i__1 = *n;
  1544. for (j = 1; j <= i__1; ++j) {
  1545. i__2 = j;
  1546. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1547. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1548. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1549. dr[1], &ipvtng, &iwork[1], sparse);
  1550. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1551. mnsub = f2cmin(isub,jsub);
  1552. mxsub = f2cmax(isub,jsub);
  1553. if (i__ < 1) {
  1554. i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
  1555. a[i__3].r = 0., a[i__3].i = 0.;
  1556. }
  1557. if (mxsub == isub && isym == 0) {
  1558. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1559. d_cnjg(&z__1, &ctemp);
  1560. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1561. } else {
  1562. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1563. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1564. }
  1565. if (i__ >= 1 && mnsub != mxsub) {
  1566. if (mnsub == isub && isym == 0) {
  1567. i__3 = mxsub - mnsub + 1 + kuu + mnsub *
  1568. a_dim1;
  1569. d_cnjg(&z__1, &ctemp);
  1570. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1571. } else {
  1572. i__3 = mxsub - mnsub + 1 + kuu + mnsub *
  1573. a_dim1;
  1574. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1575. }
  1576. }
  1577. /* L280: */
  1578. }
  1579. /* L290: */
  1580. }
  1581. } else if (isym == 1) {
  1582. i__1 = *n;
  1583. for (j = 1; j <= i__1; ++j) {
  1584. i__2 = j + kll;
  1585. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1586. zlatm3_(&z__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1587. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1588. dr[1], &ipvtng, &iwork[1], sparse);
  1589. ctemp.r = z__1.r, ctemp.i = z__1.i;
  1590. i__3 = isub - jsub + kuu + 1 + jsub * a_dim1;
  1591. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1592. /* L300: */
  1593. }
  1594. /* L310: */
  1595. }
  1596. }
  1597. }
  1598. } else {
  1599. /* Use ZLATM2 */
  1600. if (ipack == 0) {
  1601. if (isym == 0) {
  1602. i__1 = *n;
  1603. for (j = 1; j <= i__1; ++j) {
  1604. i__2 = j;
  1605. for (i__ = 1; i__ <= i__2; ++i__) {
  1606. i__3 = i__ + j * a_dim1;
  1607. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1608. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1609. &iwork[1], sparse);
  1610. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1611. i__3 = j + i__ * a_dim1;
  1612. d_cnjg(&z__1, &a[i__ + j * a_dim1]);
  1613. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1614. /* L320: */
  1615. }
  1616. /* L330: */
  1617. }
  1618. } else if (isym == 1) {
  1619. i__1 = *n;
  1620. for (j = 1; j <= i__1; ++j) {
  1621. i__2 = *m;
  1622. for (i__ = 1; i__ <= i__2; ++i__) {
  1623. i__3 = i__ + j * a_dim1;
  1624. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1625. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1626. &iwork[1], sparse);
  1627. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1628. /* L340: */
  1629. }
  1630. /* L350: */
  1631. }
  1632. } else if (isym == 2) {
  1633. i__1 = *n;
  1634. for (j = 1; j <= i__1; ++j) {
  1635. i__2 = j;
  1636. for (i__ = 1; i__ <= i__2; ++i__) {
  1637. i__3 = i__ + j * a_dim1;
  1638. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1639. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1640. &iwork[1], sparse);
  1641. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1642. i__3 = j + i__ * a_dim1;
  1643. i__4 = i__ + j * a_dim1;
  1644. a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
  1645. /* L360: */
  1646. }
  1647. /* L370: */
  1648. }
  1649. }
  1650. } else if (ipack == 1) {
  1651. i__1 = *n;
  1652. for (j = 1; j <= i__1; ++j) {
  1653. i__2 = j;
  1654. for (i__ = 1; i__ <= i__2; ++i__) {
  1655. i__3 = i__ + j * a_dim1;
  1656. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1657. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1658. 1], sparse);
  1659. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1660. if (i__ != j) {
  1661. i__3 = j + i__ * a_dim1;
  1662. a[i__3].r = 0., a[i__3].i = 0.;
  1663. }
  1664. /* L380: */
  1665. }
  1666. /* L390: */
  1667. }
  1668. } else if (ipack == 2) {
  1669. i__1 = *n;
  1670. for (j = 1; j <= i__1; ++j) {
  1671. i__2 = j;
  1672. for (i__ = 1; i__ <= i__2; ++i__) {
  1673. if (isym == 0) {
  1674. i__3 = j + i__ * a_dim1;
  1675. zlatm2_(&z__2, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1676. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1677. &iwork[1], sparse);
  1678. d_cnjg(&z__1, &z__2);
  1679. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1680. } else {
  1681. i__3 = j + i__ * a_dim1;
  1682. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1683. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1684. &iwork[1], sparse);
  1685. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1686. }
  1687. if (i__ != j) {
  1688. i__3 = i__ + j * a_dim1;
  1689. a[i__3].r = 0., a[i__3].i = 0.;
  1690. }
  1691. /* L400: */
  1692. }
  1693. /* L410: */
  1694. }
  1695. } else if (ipack == 3) {
  1696. isub = 0;
  1697. jsub = 1;
  1698. i__1 = *n;
  1699. for (j = 1; j <= i__1; ++j) {
  1700. i__2 = j;
  1701. for (i__ = 1; i__ <= i__2; ++i__) {
  1702. ++isub;
  1703. if (isub > *lda) {
  1704. isub = 1;
  1705. ++jsub;
  1706. }
  1707. i__3 = isub + jsub * a_dim1;
  1708. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1709. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1710. 1], sparse);
  1711. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1712. /* L420: */
  1713. }
  1714. /* L430: */
  1715. }
  1716. } else if (ipack == 4) {
  1717. if (isym == 0 || isym == 2) {
  1718. i__1 = *n;
  1719. for (j = 1; j <= i__1; ++j) {
  1720. i__2 = j;
  1721. for (i__ = 1; i__ <= i__2; ++i__) {
  1722. /* Compute K = location of (I,J) entry in packed array */
  1723. if (i__ == 1) {
  1724. k = j;
  1725. } else {
  1726. k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
  1727. i__ + 2) / 2 + j - i__ + 1;
  1728. }
  1729. /* Convert K to (ISUB,JSUB) location */
  1730. jsub = (k - 1) / *lda + 1;
  1731. isub = k - *lda * (jsub - 1);
  1732. i__3 = isub + jsub * a_dim1;
  1733. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1734. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1735. &iwork[1], sparse);
  1736. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1737. if (isym == 0) {
  1738. i__3 = isub + jsub * a_dim1;
  1739. d_cnjg(&z__1, &a[isub + jsub * a_dim1]);
  1740. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1741. }
  1742. /* L440: */
  1743. }
  1744. /* L450: */
  1745. }
  1746. } else {
  1747. isub = 0;
  1748. jsub = 1;
  1749. i__1 = *n;
  1750. for (j = 1; j <= i__1; ++j) {
  1751. i__2 = *m;
  1752. for (i__ = j; i__ <= i__2; ++i__) {
  1753. ++isub;
  1754. if (isub > *lda) {
  1755. isub = 1;
  1756. ++jsub;
  1757. }
  1758. i__3 = isub + jsub * a_dim1;
  1759. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1760. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1761. &iwork[1], sparse);
  1762. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1763. /* L460: */
  1764. }
  1765. /* L470: */
  1766. }
  1767. }
  1768. } else if (ipack == 5) {
  1769. i__1 = *n;
  1770. for (j = 1; j <= i__1; ++j) {
  1771. i__2 = j;
  1772. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1773. if (i__ < 1) {
  1774. i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
  1775. a[i__3].r = 0., a[i__3].i = 0.;
  1776. } else {
  1777. if (isym == 0) {
  1778. i__3 = j - i__ + 1 + i__ * a_dim1;
  1779. zlatm2_(&z__2, m, n, &i__, &j, kl, ku, &idist, &
  1780. iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1781. , &ipvtng, &iwork[1], sparse);
  1782. d_cnjg(&z__1, &z__2);
  1783. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1784. } else {
  1785. i__3 = j - i__ + 1 + i__ * a_dim1;
  1786. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &
  1787. iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1788. , &ipvtng, &iwork[1], sparse);
  1789. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1790. }
  1791. }
  1792. /* L480: */
  1793. }
  1794. /* L490: */
  1795. }
  1796. } else if (ipack == 6) {
  1797. i__1 = *n;
  1798. for (j = 1; j <= i__1; ++j) {
  1799. i__2 = j;
  1800. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1801. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1802. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1803. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1804. 1], sparse);
  1805. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1806. /* L500: */
  1807. }
  1808. /* L510: */
  1809. }
  1810. } else if (ipack == 7) {
  1811. if (isym != 1) {
  1812. i__1 = *n;
  1813. for (j = 1; j <= i__1; ++j) {
  1814. i__2 = j;
  1815. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1816. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1817. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1818. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1819. &iwork[1], sparse);
  1820. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1821. if (i__ < 1) {
  1822. i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
  1823. a[i__3].r = 0., a[i__3].i = 0.;
  1824. }
  1825. if (i__ >= 1 && i__ != j) {
  1826. if (isym == 0) {
  1827. i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
  1828. d_cnjg(&z__1, &a[i__ - j + kuu + 1 + j *
  1829. a_dim1]);
  1830. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1831. } else {
  1832. i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
  1833. i__4 = i__ - j + kuu + 1 + j * a_dim1;
  1834. a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
  1835. }
  1836. }
  1837. /* L520: */
  1838. }
  1839. /* L530: */
  1840. }
  1841. } else if (isym == 1) {
  1842. i__1 = *n;
  1843. for (j = 1; j <= i__1; ++j) {
  1844. i__2 = j + kll;
  1845. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1846. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1847. zlatm2_(&z__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1848. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1849. &iwork[1], sparse);
  1850. a[i__3].r = z__1.r, a[i__3].i = z__1.i;
  1851. /* L540: */
  1852. }
  1853. /* L550: */
  1854. }
  1855. }
  1856. }
  1857. }
  1858. /* 5) Scaling the norm */
  1859. if (ipack == 0) {
  1860. onorm = zlange_("M", m, n, &a[a_offset], lda, tempa);
  1861. } else if (ipack == 1) {
  1862. onorm = zlansy_("M", "U", n, &a[a_offset], lda, tempa);
  1863. } else if (ipack == 2) {
  1864. onorm = zlansy_("M", "L", n, &a[a_offset], lda, tempa);
  1865. } else if (ipack == 3) {
  1866. onorm = zlansp_("M", "U", n, &a[a_offset], tempa);
  1867. } else if (ipack == 4) {
  1868. onorm = zlansp_("M", "L", n, &a[a_offset], tempa);
  1869. } else if (ipack == 5) {
  1870. onorm = zlansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
  1871. } else if (ipack == 6) {
  1872. onorm = zlansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
  1873. } else if (ipack == 7) {
  1874. onorm = zlangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
  1875. }
  1876. if (*anorm >= 0.) {
  1877. if (*anorm > 0. && onorm == 0.) {
  1878. /* Desired scaling impossible */
  1879. *info = 5;
  1880. return;
  1881. } else if (*anorm > 1. && onorm < 1. || *anorm < 1. && onorm > 1.) {
  1882. /* Scale carefully to avoid over / underflow */
  1883. if (ipack <= 2) {
  1884. i__1 = *n;
  1885. for (j = 1; j <= i__1; ++j) {
  1886. d__1 = 1. / onorm;
  1887. zdscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
  1888. zdscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
  1889. /* L560: */
  1890. }
  1891. } else if (ipack == 3 || ipack == 4) {
  1892. i__1 = *n * (*n + 1) / 2;
  1893. d__1 = 1. / onorm;
  1894. zdscal_(&i__1, &d__1, &a[a_offset], &c__1);
  1895. i__1 = *n * (*n + 1) / 2;
  1896. zdscal_(&i__1, anorm, &a[a_offset], &c__1);
  1897. } else if (ipack >= 5) {
  1898. i__1 = *n;
  1899. for (j = 1; j <= i__1; ++j) {
  1900. i__2 = kll + kuu + 1;
  1901. d__1 = 1. / onorm;
  1902. zdscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1903. i__2 = kll + kuu + 1;
  1904. zdscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
  1905. /* L570: */
  1906. }
  1907. }
  1908. } else {
  1909. /* Scale straightforwardly */
  1910. if (ipack <= 2) {
  1911. i__1 = *n;
  1912. for (j = 1; j <= i__1; ++j) {
  1913. d__1 = *anorm / onorm;
  1914. zdscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
  1915. /* L580: */
  1916. }
  1917. } else if (ipack == 3 || ipack == 4) {
  1918. i__1 = *n * (*n + 1) / 2;
  1919. d__1 = *anorm / onorm;
  1920. zdscal_(&i__1, &d__1, &a[a_offset], &c__1);
  1921. } else if (ipack >= 5) {
  1922. i__1 = *n;
  1923. for (j = 1; j <= i__1; ++j) {
  1924. i__2 = kll + kuu + 1;
  1925. d__1 = *anorm / onorm;
  1926. zdscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1927. /* L590: */
  1928. }
  1929. }
  1930. }
  1931. }
  1932. /* End of ZLATMR */
  1933. return;
  1934. } /* zlatmr_ */