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

clatmr.c 65 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104
  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 CLATMR */
  489. /* =========== DOCUMENTATION =========== */
  490. /* Online html documentation available at */
  491. /* http://www.netlib.org/lapack/explore-html/ */
  492. /* Definition: */
  493. /* =========== */
  494. /* SUBROUTINE CLATMR( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
  495. /* RSIGN, GRADE, DL, MODEL, CONDL, DR, MODER, */
  496. /* CONDR, PIVTNG, IPIVOT, KL, KU, SPARSE, ANORM, */
  497. /* PACK, A, LDA, IWORK, INFO ) */
  498. /* CHARACTER DIST, GRADE, PACK, PIVTNG, RSIGN, SYM */
  499. /* INTEGER INFO, KL, KU, LDA, M, MODE, MODEL, MODER, N */
  500. /* REAL ANORM, COND, CONDL, CONDR, SPARSE */
  501. /* COMPLEX DMAX */
  502. /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
  503. /* COMPLEX A( LDA, * ), D( * ), DL( * ), DR( * ) */
  504. /* > \par Purpose: */
  505. /* ============= */
  506. /* > */
  507. /* > \verbatim */
  508. /* > */
  509. /* > CLATMR generates random matrices of various types for testing */
  510. /* > LAPACK programs. */
  511. /* > */
  512. /* > CLATMR 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 CLATMR differ only in the PACK parameter, */
  556. /* > they will generate mathematically equivalent matrices. */
  557. /* > */
  558. /* > If two calls to CLATMR 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 CLATMR */
  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 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 REAL */
  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 */
  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 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 REAL */
  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 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 REAL */
  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 CLATMR 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, CLATMR */
  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 REAL */
  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 REAL */
  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 CLATMR 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 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 CLATM1 (computing D) */
  942. /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
  943. /* > 3 => Error return from CLATM1 (computing DL) */
  944. /* > 4 => Error return from CLATM1 (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 complex_matgen */
  956. /* ===================================================================== */
  957. /* Subroutine */ int clatmr_(integer *m, integer *n, char *dist, integer *
  958. iseed, char *sym, complex *d__, integer *mode, real *cond, complex *
  959. dmax__, char *rsign, char *grade, complex *dl, integer *model, real *
  960. condl, complex *dr, integer *moder, real *condr, char *pivtng,
  961. integer *ipivot, integer *kl, integer *ku, real *sparse, real *anorm,
  962. char *pack, complex *a, integer *lda, integer *iwork, integer *info)
  963. {
  964. /* System generated locals */
  965. integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
  966. real r__1, r__2;
  967. complex q__1, q__2;
  968. /* Local variables */
  969. integer isub, jsub;
  970. real temp;
  971. integer isym, i__, j, k, ipack;
  972. extern logical lsame_(char *, char *);
  973. real tempa[1];
  974. complex ctemp;
  975. integer iisub, idist, jjsub, mnmin;
  976. logical dzero;
  977. integer mnsub;
  978. real onorm;
  979. integer mxsub, npvts;
  980. extern /* Subroutine */ int clatm1_(integer *, real *, integer *, integer
  981. *, integer *, complex *, integer *, integer *);
  982. extern /* Complex */ VOID clatm2_(complex *, integer *, integer *,
  983. integer *, integer *, integer *, integer *, integer *, integer *,
  984. complex *, integer *, complex *, complex *, integer *, integer *,
  985. real *), clatm3_(complex *, integer *, integer *, integer *,
  986. integer *, integer *, integer *, integer *, integer *, integer *,
  987. integer *, complex *, integer *, complex *, complex *, integer *,
  988. integer *, real *);
  989. complex calpha;
  990. extern real clangb_(char *, integer *, integer *, integer *, complex *,
  991. integer *, real *), clange_(char *, integer *, integer *,
  992. complex *, integer *, real *);
  993. integer igrade;
  994. extern real clansb_(char *, char *, integer *, integer *, complex *,
  995. integer *, real *);
  996. extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer
  997. *);
  998. logical fulbnd;
  999. extern /* Subroutine */ int xerbla_(char *, integer *);
  1000. logical badpvt;
  1001. extern real clansp_(char *, char *, integer *, complex *, real *), clansy_(char *, char *, integer *, complex *, integer *,
  1002. real *);
  1003. integer irsign, ipvtng, kll, kuu;
  1004. /* -- LAPACK computational routine (version 3.7.0) -- */
  1005. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  1006. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  1007. /* December 2016 */
  1008. /* ===================================================================== */
  1009. /* 1) Decode and Test the input parameters. */
  1010. /* Initialize flags & seed. */
  1011. /* Parameter adjustments */
  1012. --iseed;
  1013. --d__;
  1014. --dl;
  1015. --dr;
  1016. --ipivot;
  1017. a_dim1 = *lda;
  1018. a_offset = 1 + a_dim1 * 1;
  1019. a -= a_offset;
  1020. --iwork;
  1021. /* Function Body */
  1022. *info = 0;
  1023. /* Quick return if possible */
  1024. if (*m == 0 || *n == 0) {
  1025. return 0;
  1026. }
  1027. /* Decode DIST */
  1028. if (lsame_(dist, "U")) {
  1029. idist = 1;
  1030. } else if (lsame_(dist, "S")) {
  1031. idist = 2;
  1032. } else if (lsame_(dist, "N")) {
  1033. idist = 3;
  1034. } else if (lsame_(dist, "D")) {
  1035. idist = 4;
  1036. } else {
  1037. idist = -1;
  1038. }
  1039. /* Decode SYM */
  1040. if (lsame_(sym, "H")) {
  1041. isym = 0;
  1042. } else if (lsame_(sym, "N")) {
  1043. isym = 1;
  1044. } else if (lsame_(sym, "S")) {
  1045. isym = 2;
  1046. } else {
  1047. isym = -1;
  1048. }
  1049. /* Decode RSIGN */
  1050. if (lsame_(rsign, "F")) {
  1051. irsign = 0;
  1052. } else if (lsame_(rsign, "T")) {
  1053. irsign = 1;
  1054. } else {
  1055. irsign = -1;
  1056. }
  1057. /* Decode PIVTNG */
  1058. if (lsame_(pivtng, "N")) {
  1059. ipvtng = 0;
  1060. } else if (lsame_(pivtng, " ")) {
  1061. ipvtng = 0;
  1062. } else if (lsame_(pivtng, "L")) {
  1063. ipvtng = 1;
  1064. npvts = *m;
  1065. } else if (lsame_(pivtng, "R")) {
  1066. ipvtng = 2;
  1067. npvts = *n;
  1068. } else if (lsame_(pivtng, "B")) {
  1069. ipvtng = 3;
  1070. npvts = f2cmin(*n,*m);
  1071. } else if (lsame_(pivtng, "F")) {
  1072. ipvtng = 3;
  1073. npvts = f2cmin(*n,*m);
  1074. } else {
  1075. ipvtng = -1;
  1076. }
  1077. /* Decode GRADE */
  1078. if (lsame_(grade, "N")) {
  1079. igrade = 0;
  1080. } else if (lsame_(grade, "L")) {
  1081. igrade = 1;
  1082. } else if (lsame_(grade, "R")) {
  1083. igrade = 2;
  1084. } else if (lsame_(grade, "B")) {
  1085. igrade = 3;
  1086. } else if (lsame_(grade, "E")) {
  1087. igrade = 4;
  1088. } else if (lsame_(grade, "H")) {
  1089. igrade = 5;
  1090. } else if (lsame_(grade, "S")) {
  1091. igrade = 6;
  1092. } else {
  1093. igrade = -1;
  1094. }
  1095. /* Decode PACK */
  1096. if (lsame_(pack, "N")) {
  1097. ipack = 0;
  1098. } else if (lsame_(pack, "U")) {
  1099. ipack = 1;
  1100. } else if (lsame_(pack, "L")) {
  1101. ipack = 2;
  1102. } else if (lsame_(pack, "C")) {
  1103. ipack = 3;
  1104. } else if (lsame_(pack, "R")) {
  1105. ipack = 4;
  1106. } else if (lsame_(pack, "B")) {
  1107. ipack = 5;
  1108. } else if (lsame_(pack, "Q")) {
  1109. ipack = 6;
  1110. } else if (lsame_(pack, "Z")) {
  1111. ipack = 7;
  1112. } else {
  1113. ipack = -1;
  1114. }
  1115. /* Set certain internal parameters */
  1116. mnmin = f2cmin(*m,*n);
  1117. /* Computing MIN */
  1118. i__1 = *kl, i__2 = *m - 1;
  1119. kll = f2cmin(i__1,i__2);
  1120. /* Computing MIN */
  1121. i__1 = *ku, i__2 = *n - 1;
  1122. kuu = f2cmin(i__1,i__2);
  1123. /* If inv(DL) is used, check to see if DL has a zero entry. */
  1124. dzero = FALSE_;
  1125. if (igrade == 4 && *model == 0) {
  1126. i__1 = *m;
  1127. for (i__ = 1; i__ <= i__1; ++i__) {
  1128. i__2 = i__;
  1129. if (dl[i__2].r == 0.f && dl[i__2].i == 0.f) {
  1130. dzero = TRUE_;
  1131. }
  1132. /* L10: */
  1133. }
  1134. }
  1135. /* Check values in IPIVOT */
  1136. badpvt = FALSE_;
  1137. if (ipvtng > 0) {
  1138. i__1 = npvts;
  1139. for (j = 1; j <= i__1; ++j) {
  1140. if (ipivot[j] <= 0 || ipivot[j] > npvts) {
  1141. badpvt = TRUE_;
  1142. }
  1143. /* L20: */
  1144. }
  1145. }
  1146. /* Set INFO if an error */
  1147. if (*m < 0) {
  1148. *info = -1;
  1149. } else if (*m != *n && (isym == 0 || isym == 2)) {
  1150. *info = -1;
  1151. } else if (*n < 0) {
  1152. *info = -2;
  1153. } else if (idist == -1) {
  1154. *info = -3;
  1155. } else if (isym == -1) {
  1156. *info = -5;
  1157. } else if (*mode < -6 || *mode > 6) {
  1158. *info = -7;
  1159. } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.f) {
  1160. *info = -8;
  1161. } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
  1162. *info = -10;
  1163. } else if (igrade == -1 || igrade == 4 && *m != *n || (igrade == 1 ||
  1164. igrade == 2 || igrade == 3 || igrade == 4 || igrade == 6) && isym
  1165. == 0 || (igrade == 1 || igrade == 2 || igrade == 3 || igrade == 4
  1166. || igrade == 5) && isym == 2) {
  1167. *info = -11;
  1168. } else if (igrade == 4 && dzero) {
  1169. *info = -12;
  1170. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
  1171. igrade == 6) && (*model < -6 || *model > 6)) {
  1172. *info = -13;
  1173. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 ||
  1174. igrade == 6) && (*model != -6 && *model != 0 && *model != 6) && *
  1175. condl < 1.f) {
  1176. *info = -14;
  1177. } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
  1178. *info = -16;
  1179. } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
  1180. *moder != 6) && *condr < 1.f) {
  1181. *info = -17;
  1182. } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
  1183. ipvtng == 2) && (isym == 0 || isym == 2)) {
  1184. *info = -18;
  1185. } else if (ipvtng != 0 && badpvt) {
  1186. *info = -19;
  1187. } else if (*kl < 0) {
  1188. *info = -20;
  1189. } else if (*ku < 0 || (isym == 0 || isym == 2) && *kl != *ku) {
  1190. *info = -21;
  1191. } else if (*sparse < 0.f || *sparse > 1.f) {
  1192. *info = -22;
  1193. } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
  1194. ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
  1195. || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
  1196. {
  1197. *info = -24;
  1198. } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
  1199. (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
  1200. 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
  1201. *info = -26;
  1202. }
  1203. if (*info != 0) {
  1204. i__1 = -(*info);
  1205. xerbla_("CLATMR", &i__1);
  1206. return 0;
  1207. }
  1208. /* Decide if we can pivot consistently */
  1209. fulbnd = FALSE_;
  1210. if (kuu == *n - 1 && kll == *m - 1) {
  1211. fulbnd = TRUE_;
  1212. }
  1213. /* Initialize random number generator */
  1214. for (i__ = 1; i__ <= 4; ++i__) {
  1215. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  1216. /* L30: */
  1217. }
  1218. iseed[4] = (iseed[4] / 2 << 1) + 1;
  1219. /* 2) Set up D, DL, and DR, if indicated. */
  1220. /* Compute D according to COND and MODE */
  1221. clatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
  1222. if (*info != 0) {
  1223. *info = 1;
  1224. return 0;
  1225. }
  1226. if (*mode != 0 && *mode != -6 && *mode != 6) {
  1227. /* Scale by DMAX */
  1228. temp = c_abs(&d__[1]);
  1229. i__1 = mnmin;
  1230. for (i__ = 2; i__ <= i__1; ++i__) {
  1231. /* Computing MAX */
  1232. r__1 = temp, r__2 = c_abs(&d__[i__]);
  1233. temp = f2cmax(r__1,r__2);
  1234. /* L40: */
  1235. }
  1236. if (temp == 0.f && (dmax__->r != 0.f || dmax__->i != 0.f)) {
  1237. *info = 2;
  1238. return 0;
  1239. }
  1240. if (temp != 0.f) {
  1241. q__1.r = dmax__->r / temp, q__1.i = dmax__->i / temp;
  1242. calpha.r = q__1.r, calpha.i = q__1.i;
  1243. } else {
  1244. calpha.r = 1.f, calpha.i = 0.f;
  1245. }
  1246. i__1 = mnmin;
  1247. for (i__ = 1; i__ <= i__1; ++i__) {
  1248. i__2 = i__;
  1249. i__3 = i__;
  1250. q__1.r = calpha.r * d__[i__3].r - calpha.i * d__[i__3].i, q__1.i =
  1251. calpha.r * d__[i__3].i + calpha.i * d__[i__3].r;
  1252. d__[i__2].r = q__1.r, d__[i__2].i = q__1.i;
  1253. /* L50: */
  1254. }
  1255. }
  1256. /* If matrix Hermitian, make D real */
  1257. if (isym == 0) {
  1258. i__1 = mnmin;
  1259. for (i__ = 1; i__ <= i__1; ++i__) {
  1260. i__2 = i__;
  1261. i__3 = i__;
  1262. r__1 = d__[i__3].r;
  1263. d__[i__2].r = r__1, d__[i__2].i = 0.f;
  1264. /* L60: */
  1265. }
  1266. }
  1267. /* Compute DL if grading set */
  1268. if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5 || igrade ==
  1269. 6) {
  1270. clatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
  1271. if (*info != 0) {
  1272. *info = 3;
  1273. return 0;
  1274. }
  1275. }
  1276. /* Compute DR if grading set */
  1277. if (igrade == 2 || igrade == 3) {
  1278. clatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
  1279. if (*info != 0) {
  1280. *info = 4;
  1281. return 0;
  1282. }
  1283. }
  1284. /* 3) Generate IWORK if pivoting */
  1285. if (ipvtng > 0) {
  1286. i__1 = npvts;
  1287. for (i__ = 1; i__ <= i__1; ++i__) {
  1288. iwork[i__] = i__;
  1289. /* L70: */
  1290. }
  1291. if (fulbnd) {
  1292. i__1 = npvts;
  1293. for (i__ = 1; i__ <= i__1; ++i__) {
  1294. k = ipivot[i__];
  1295. j = iwork[i__];
  1296. iwork[i__] = iwork[k];
  1297. iwork[k] = j;
  1298. /* L80: */
  1299. }
  1300. } else {
  1301. for (i__ = npvts; i__ >= 1; --i__) {
  1302. k = ipivot[i__];
  1303. j = iwork[i__];
  1304. iwork[i__] = iwork[k];
  1305. iwork[k] = j;
  1306. /* L90: */
  1307. }
  1308. }
  1309. }
  1310. /* 4) Generate matrices for each kind of PACKing */
  1311. /* Always sweep matrix columnwise (if symmetric, upper */
  1312. /* half only) so that matrix generated does not depend */
  1313. /* on PACK */
  1314. if (fulbnd) {
  1315. /* Use CLATM3 so matrices generated with differing PIVOTing only */
  1316. /* differ only in the order of their rows and/or columns. */
  1317. if (ipack == 0) {
  1318. if (isym == 0) {
  1319. i__1 = *n;
  1320. for (j = 1; j <= i__1; ++j) {
  1321. i__2 = j;
  1322. for (i__ = 1; i__ <= i__2; ++i__) {
  1323. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1324. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1325. dr[1], &ipvtng, &iwork[1], sparse);
  1326. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1327. i__3 = isub + jsub * a_dim1;
  1328. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1329. i__3 = jsub + isub * a_dim1;
  1330. r_cnjg(&q__1, &ctemp);
  1331. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1332. /* L100: */
  1333. }
  1334. /* L110: */
  1335. }
  1336. } else if (isym == 1) {
  1337. i__1 = *n;
  1338. for (j = 1; j <= i__1; ++j) {
  1339. i__2 = *m;
  1340. for (i__ = 1; i__ <= i__2; ++i__) {
  1341. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1342. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1343. dr[1], &ipvtng, &iwork[1], sparse);
  1344. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1345. i__3 = isub + jsub * a_dim1;
  1346. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1347. /* L120: */
  1348. }
  1349. /* L130: */
  1350. }
  1351. } else if (isym == 2) {
  1352. i__1 = *n;
  1353. for (j = 1; j <= i__1; ++j) {
  1354. i__2 = j;
  1355. for (i__ = 1; i__ <= i__2; ++i__) {
  1356. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1357. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1358. dr[1], &ipvtng, &iwork[1], sparse);
  1359. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1360. i__3 = isub + jsub * a_dim1;
  1361. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1362. i__3 = jsub + isub * a_dim1;
  1363. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1364. /* L140: */
  1365. }
  1366. /* L150: */
  1367. }
  1368. }
  1369. } else if (ipack == 1) {
  1370. i__1 = *n;
  1371. for (j = 1; j <= i__1; ++j) {
  1372. i__2 = j;
  1373. for (i__ = 1; i__ <= i__2; ++i__) {
  1374. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1375. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1376. , &ipvtng, &iwork[1], sparse);
  1377. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1378. mnsub = f2cmin(isub,jsub);
  1379. mxsub = f2cmax(isub,jsub);
  1380. if (mxsub == isub && isym == 0) {
  1381. i__3 = mnsub + mxsub * a_dim1;
  1382. r_cnjg(&q__1, &ctemp);
  1383. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1384. } else {
  1385. i__3 = mnsub + mxsub * a_dim1;
  1386. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1387. }
  1388. if (mnsub != mxsub) {
  1389. i__3 = mxsub + mnsub * a_dim1;
  1390. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1391. }
  1392. /* L160: */
  1393. }
  1394. /* L170: */
  1395. }
  1396. } else if (ipack == 2) {
  1397. i__1 = *n;
  1398. for (j = 1; j <= i__1; ++j) {
  1399. i__2 = j;
  1400. for (i__ = 1; i__ <= i__2; ++i__) {
  1401. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1402. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1403. , &ipvtng, &iwork[1], sparse);
  1404. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1405. mnsub = f2cmin(isub,jsub);
  1406. mxsub = f2cmax(isub,jsub);
  1407. if (mxsub == jsub && isym == 0) {
  1408. i__3 = mxsub + mnsub * a_dim1;
  1409. r_cnjg(&q__1, &ctemp);
  1410. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1411. } else {
  1412. i__3 = mxsub + mnsub * a_dim1;
  1413. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1414. }
  1415. if (mnsub != mxsub) {
  1416. i__3 = mnsub + mxsub * a_dim1;
  1417. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1418. }
  1419. /* L180: */
  1420. }
  1421. /* L190: */
  1422. }
  1423. } else if (ipack == 3) {
  1424. i__1 = *n;
  1425. for (j = 1; j <= i__1; ++j) {
  1426. i__2 = j;
  1427. for (i__ = 1; i__ <= i__2; ++i__) {
  1428. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1429. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1430. , &ipvtng, &iwork[1], sparse);
  1431. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1432. /* Compute K = location of (ISUB,JSUB) entry in packed */
  1433. /* array */
  1434. mnsub = f2cmin(isub,jsub);
  1435. mxsub = f2cmax(isub,jsub);
  1436. k = mxsub * (mxsub - 1) / 2 + mnsub;
  1437. /* Convert K to (IISUB,JJSUB) location */
  1438. jjsub = (k - 1) / *lda + 1;
  1439. iisub = k - *lda * (jjsub - 1);
  1440. if (mxsub == isub && isym == 0) {
  1441. i__3 = iisub + jjsub * a_dim1;
  1442. r_cnjg(&q__1, &ctemp);
  1443. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1444. } else {
  1445. i__3 = iisub + jjsub * a_dim1;
  1446. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1447. }
  1448. /* L200: */
  1449. }
  1450. /* L210: */
  1451. }
  1452. } else if (ipack == 4) {
  1453. i__1 = *n;
  1454. for (j = 1; j <= i__1; ++j) {
  1455. i__2 = j;
  1456. for (i__ = 1; i__ <= i__2; ++i__) {
  1457. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1458. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1459. , &ipvtng, &iwork[1], sparse);
  1460. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1461. /* Compute K = location of (I,J) entry in packed array */
  1462. mnsub = f2cmin(isub,jsub);
  1463. mxsub = f2cmax(isub,jsub);
  1464. if (mnsub == 1) {
  1465. k = mxsub;
  1466. } else {
  1467. k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
  1468. mnsub + 2) / 2 + mxsub - mnsub + 1;
  1469. }
  1470. /* Convert K to (IISUB,JJSUB) location */
  1471. jjsub = (k - 1) / *lda + 1;
  1472. iisub = k - *lda * (jjsub - 1);
  1473. if (mxsub == jsub && isym == 0) {
  1474. i__3 = iisub + jjsub * a_dim1;
  1475. r_cnjg(&q__1, &ctemp);
  1476. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1477. } else {
  1478. i__3 = iisub + jjsub * a_dim1;
  1479. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1480. }
  1481. /* L220: */
  1482. }
  1483. /* L230: */
  1484. }
  1485. } else if (ipack == 5) {
  1486. i__1 = *n;
  1487. for (j = 1; j <= i__1; ++j) {
  1488. i__2 = j;
  1489. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1490. if (i__ < 1) {
  1491. i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
  1492. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1493. } else {
  1494. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1495. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1496. dr[1], &ipvtng, &iwork[1], sparse);
  1497. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1498. mnsub = f2cmin(isub,jsub);
  1499. mxsub = f2cmax(isub,jsub);
  1500. if (mxsub == jsub && isym == 0) {
  1501. i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
  1502. r_cnjg(&q__1, &ctemp);
  1503. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1504. } else {
  1505. i__3 = mxsub - mnsub + 1 + mnsub * a_dim1;
  1506. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1507. }
  1508. }
  1509. /* L240: */
  1510. }
  1511. /* L250: */
  1512. }
  1513. } else if (ipack == 6) {
  1514. i__1 = *n;
  1515. for (j = 1; j <= i__1; ++j) {
  1516. i__2 = j;
  1517. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1518. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1519. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1520. , &ipvtng, &iwork[1], sparse);
  1521. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1522. mnsub = f2cmin(isub,jsub);
  1523. mxsub = f2cmax(isub,jsub);
  1524. if (mxsub == isub && isym == 0) {
  1525. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1526. r_cnjg(&q__1, &ctemp);
  1527. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1528. } else {
  1529. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1530. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1531. }
  1532. /* L260: */
  1533. }
  1534. /* L270: */
  1535. }
  1536. } else if (ipack == 7) {
  1537. if (isym != 1) {
  1538. i__1 = *n;
  1539. for (j = 1; j <= i__1; ++j) {
  1540. i__2 = j;
  1541. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1542. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1543. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1544. dr[1], &ipvtng, &iwork[1], sparse);
  1545. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1546. mnsub = f2cmin(isub,jsub);
  1547. mxsub = f2cmax(isub,jsub);
  1548. if (i__ < 1) {
  1549. i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
  1550. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1551. }
  1552. if (mxsub == isub && isym == 0) {
  1553. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1554. r_cnjg(&q__1, &ctemp);
  1555. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1556. } else {
  1557. i__3 = mnsub - mxsub + kuu + 1 + mxsub * a_dim1;
  1558. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1559. }
  1560. if (i__ >= 1 && mnsub != mxsub) {
  1561. if (mnsub == isub && isym == 0) {
  1562. i__3 = mxsub - mnsub + 1 + kuu + mnsub *
  1563. a_dim1;
  1564. r_cnjg(&q__1, &ctemp);
  1565. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1566. } else {
  1567. i__3 = mxsub - mnsub + 1 + kuu + mnsub *
  1568. a_dim1;
  1569. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1570. }
  1571. }
  1572. /* L280: */
  1573. }
  1574. /* L290: */
  1575. }
  1576. } else if (isym == 1) {
  1577. i__1 = *n;
  1578. for (j = 1; j <= i__1; ++j) {
  1579. i__2 = j + kll;
  1580. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1581. clatm3_(&q__1, m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1582. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1583. dr[1], &ipvtng, &iwork[1], sparse);
  1584. ctemp.r = q__1.r, ctemp.i = q__1.i;
  1585. i__3 = isub - jsub + kuu + 1 + jsub * a_dim1;
  1586. a[i__3].r = ctemp.r, a[i__3].i = ctemp.i;
  1587. /* L300: */
  1588. }
  1589. /* L310: */
  1590. }
  1591. }
  1592. }
  1593. } else {
  1594. /* Use CLATM2 */
  1595. if (ipack == 0) {
  1596. if (isym == 0) {
  1597. i__1 = *n;
  1598. for (j = 1; j <= i__1; ++j) {
  1599. i__2 = j;
  1600. for (i__ = 1; i__ <= i__2; ++i__) {
  1601. i__3 = i__ + j * a_dim1;
  1602. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1603. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1604. &iwork[1], sparse);
  1605. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1606. i__3 = j + i__ * a_dim1;
  1607. r_cnjg(&q__1, &a[i__ + j * a_dim1]);
  1608. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1609. /* L320: */
  1610. }
  1611. /* L330: */
  1612. }
  1613. } else if (isym == 1) {
  1614. i__1 = *n;
  1615. for (j = 1; j <= i__1; ++j) {
  1616. i__2 = *m;
  1617. for (i__ = 1; i__ <= i__2; ++i__) {
  1618. i__3 = i__ + j * a_dim1;
  1619. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1620. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1621. &iwork[1], sparse);
  1622. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1623. /* L340: */
  1624. }
  1625. /* L350: */
  1626. }
  1627. } else if (isym == 2) {
  1628. i__1 = *n;
  1629. for (j = 1; j <= i__1; ++j) {
  1630. i__2 = j;
  1631. for (i__ = 1; i__ <= i__2; ++i__) {
  1632. i__3 = i__ + j * a_dim1;
  1633. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1634. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1635. &iwork[1], sparse);
  1636. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1637. i__3 = j + i__ * a_dim1;
  1638. i__4 = i__ + j * a_dim1;
  1639. a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
  1640. /* L360: */
  1641. }
  1642. /* L370: */
  1643. }
  1644. }
  1645. } else if (ipack == 1) {
  1646. i__1 = *n;
  1647. for (j = 1; j <= i__1; ++j) {
  1648. i__2 = j;
  1649. for (i__ = 1; i__ <= i__2; ++i__) {
  1650. i__3 = i__ + j * a_dim1;
  1651. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1652. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1653. 1], sparse);
  1654. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1655. if (i__ != j) {
  1656. i__3 = j + i__ * a_dim1;
  1657. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1658. }
  1659. /* L380: */
  1660. }
  1661. /* L390: */
  1662. }
  1663. } else if (ipack == 2) {
  1664. i__1 = *n;
  1665. for (j = 1; j <= i__1; ++j) {
  1666. i__2 = j;
  1667. for (i__ = 1; i__ <= i__2; ++i__) {
  1668. if (isym == 0) {
  1669. i__3 = j + i__ * a_dim1;
  1670. clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1671. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1672. &iwork[1], sparse);
  1673. r_cnjg(&q__1, &q__2);
  1674. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1675. } else {
  1676. i__3 = j + i__ * a_dim1;
  1677. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1678. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1679. &iwork[1], sparse);
  1680. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1681. }
  1682. if (i__ != j) {
  1683. i__3 = i__ + j * a_dim1;
  1684. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1685. }
  1686. /* L400: */
  1687. }
  1688. /* L410: */
  1689. }
  1690. } else if (ipack == 3) {
  1691. isub = 0;
  1692. jsub = 1;
  1693. i__1 = *n;
  1694. for (j = 1; j <= i__1; ++j) {
  1695. i__2 = j;
  1696. for (i__ = 1; i__ <= i__2; ++i__) {
  1697. ++isub;
  1698. if (isub > *lda) {
  1699. isub = 1;
  1700. ++jsub;
  1701. }
  1702. i__3 = isub + jsub * a_dim1;
  1703. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1704. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1705. 1], sparse);
  1706. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1707. /* L420: */
  1708. }
  1709. /* L430: */
  1710. }
  1711. } else if (ipack == 4) {
  1712. if (isym == 0 || isym == 2) {
  1713. i__1 = *n;
  1714. for (j = 1; j <= i__1; ++j) {
  1715. i__2 = j;
  1716. for (i__ = 1; i__ <= i__2; ++i__) {
  1717. /* Compute K = location of (I,J) entry in packed array */
  1718. if (i__ == 1) {
  1719. k = j;
  1720. } else {
  1721. k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
  1722. i__ + 2) / 2 + j - i__ + 1;
  1723. }
  1724. /* Convert K to (ISUB,JSUB) location */
  1725. jsub = (k - 1) / *lda + 1;
  1726. isub = k - *lda * (jsub - 1);
  1727. i__3 = isub + jsub * a_dim1;
  1728. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1729. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1730. &iwork[1], sparse);
  1731. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1732. if (isym == 0) {
  1733. i__3 = isub + jsub * a_dim1;
  1734. r_cnjg(&q__1, &a[isub + jsub * a_dim1]);
  1735. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1736. }
  1737. /* L440: */
  1738. }
  1739. /* L450: */
  1740. }
  1741. } else {
  1742. isub = 0;
  1743. jsub = 1;
  1744. i__1 = *n;
  1745. for (j = 1; j <= i__1; ++j) {
  1746. i__2 = *m;
  1747. for (i__ = j; i__ <= i__2; ++i__) {
  1748. ++isub;
  1749. if (isub > *lda) {
  1750. isub = 1;
  1751. ++jsub;
  1752. }
  1753. i__3 = isub + jsub * a_dim1;
  1754. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1755. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1756. &iwork[1], sparse);
  1757. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1758. /* L460: */
  1759. }
  1760. /* L470: */
  1761. }
  1762. }
  1763. } else if (ipack == 5) {
  1764. i__1 = *n;
  1765. for (j = 1; j <= i__1; ++j) {
  1766. i__2 = j;
  1767. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1768. if (i__ < 1) {
  1769. i__3 = j - i__ + 1 + (i__ + *n) * a_dim1;
  1770. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1771. } else {
  1772. if (isym == 0) {
  1773. i__3 = j - i__ + 1 + i__ * a_dim1;
  1774. clatm2_(&q__2, m, n, &i__, &j, kl, ku, &idist, &
  1775. iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1776. , &ipvtng, &iwork[1], sparse);
  1777. r_cnjg(&q__1, &q__2);
  1778. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1779. } else {
  1780. i__3 = j - i__ + 1 + i__ * a_dim1;
  1781. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &
  1782. iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1783. , &ipvtng, &iwork[1], sparse);
  1784. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1785. }
  1786. }
  1787. /* L480: */
  1788. }
  1789. /* L490: */
  1790. }
  1791. } else if (ipack == 6) {
  1792. i__1 = *n;
  1793. for (j = 1; j <= i__1; ++j) {
  1794. i__2 = j;
  1795. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1796. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1797. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[1],
  1798. &d__[1], &igrade, &dl[1], &dr[1], &ipvtng, &iwork[
  1799. 1], sparse);
  1800. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1801. /* L500: */
  1802. }
  1803. /* L510: */
  1804. }
  1805. } else if (ipack == 7) {
  1806. if (isym != 1) {
  1807. i__1 = *n;
  1808. for (j = 1; j <= i__1; ++j) {
  1809. i__2 = j;
  1810. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1811. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1812. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1813. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1814. &iwork[1], sparse);
  1815. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1816. if (i__ < 1) {
  1817. i__3 = j - i__ + 1 + kuu + (i__ + *n) * a_dim1;
  1818. a[i__3].r = 0.f, a[i__3].i = 0.f;
  1819. }
  1820. if (i__ >= 1 && i__ != j) {
  1821. if (isym == 0) {
  1822. i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
  1823. r_cnjg(&q__1, &a[i__ - j + kuu + 1 + j *
  1824. a_dim1]);
  1825. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1826. } else {
  1827. i__3 = j - i__ + 1 + kuu + i__ * a_dim1;
  1828. i__4 = i__ - j + kuu + 1 + j * a_dim1;
  1829. a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i;
  1830. }
  1831. }
  1832. /* L520: */
  1833. }
  1834. /* L530: */
  1835. }
  1836. } else if (isym == 1) {
  1837. i__1 = *n;
  1838. for (j = 1; j <= i__1; ++j) {
  1839. i__2 = j + kll;
  1840. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1841. i__3 = i__ - j + kuu + 1 + j * a_dim1;
  1842. clatm2_(&q__1, m, n, &i__, &j, kl, ku, &idist, &iseed[
  1843. 1], &d__[1], &igrade, &dl[1], &dr[1], &ipvtng,
  1844. &iwork[1], sparse);
  1845. a[i__3].r = q__1.r, a[i__3].i = q__1.i;
  1846. /* L540: */
  1847. }
  1848. /* L550: */
  1849. }
  1850. }
  1851. }
  1852. }
  1853. /* 5) Scaling the norm */
  1854. if (ipack == 0) {
  1855. onorm = clange_("M", m, n, &a[a_offset], lda, tempa);
  1856. } else if (ipack == 1) {
  1857. onorm = clansy_("M", "U", n, &a[a_offset], lda, tempa);
  1858. } else if (ipack == 2) {
  1859. onorm = clansy_("M", "L", n, &a[a_offset], lda, tempa);
  1860. } else if (ipack == 3) {
  1861. onorm = clansp_("M", "U", n, &a[a_offset], tempa);
  1862. } else if (ipack == 4) {
  1863. onorm = clansp_("M", "L", n, &a[a_offset], tempa);
  1864. } else if (ipack == 5) {
  1865. onorm = clansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
  1866. } else if (ipack == 6) {
  1867. onorm = clansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
  1868. } else if (ipack == 7) {
  1869. onorm = clangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
  1870. }
  1871. if (*anorm >= 0.f) {
  1872. if (*anorm > 0.f && onorm == 0.f) {
  1873. /* Desired scaling impossible */
  1874. *info = 5;
  1875. return 0;
  1876. } else if (*anorm > 1.f && onorm < 1.f || *anorm < 1.f && onorm > 1.f)
  1877. {
  1878. /* Scale carefully to avoid over / underflow */
  1879. if (ipack <= 2) {
  1880. i__1 = *n;
  1881. for (j = 1; j <= i__1; ++j) {
  1882. r__1 = 1.f / onorm;
  1883. csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
  1884. csscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
  1885. /* L560: */
  1886. }
  1887. } else if (ipack == 3 || ipack == 4) {
  1888. i__1 = *n * (*n + 1) / 2;
  1889. r__1 = 1.f / onorm;
  1890. csscal_(&i__1, &r__1, &a[a_offset], &c__1);
  1891. i__1 = *n * (*n + 1) / 2;
  1892. csscal_(&i__1, anorm, &a[a_offset], &c__1);
  1893. } else if (ipack >= 5) {
  1894. i__1 = *n;
  1895. for (j = 1; j <= i__1; ++j) {
  1896. i__2 = kll + kuu + 1;
  1897. r__1 = 1.f / onorm;
  1898. csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
  1899. i__2 = kll + kuu + 1;
  1900. csscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
  1901. /* L570: */
  1902. }
  1903. }
  1904. } else {
  1905. /* Scale straightforwardly */
  1906. if (ipack <= 2) {
  1907. i__1 = *n;
  1908. for (j = 1; j <= i__1; ++j) {
  1909. r__1 = *anorm / onorm;
  1910. csscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
  1911. /* L580: */
  1912. }
  1913. } else if (ipack == 3 || ipack == 4) {
  1914. i__1 = *n * (*n + 1) / 2;
  1915. r__1 = *anorm / onorm;
  1916. csscal_(&i__1, &r__1, &a[a_offset], &c__1);
  1917. } else if (ipack >= 5) {
  1918. i__1 = *n;
  1919. for (j = 1; j <= i__1; ++j) {
  1920. i__2 = kll + kuu + 1;
  1921. r__1 = *anorm / onorm;
  1922. csscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
  1923. /* L590: */
  1924. }
  1925. }
  1926. }
  1927. }
  1928. /* End of CLATMR */
  1929. return 0;
  1930. } /* clatmr_ */