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.

clatps.c 47 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722
  1. #include <math.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <complex.h>
  6. #ifdef complex
  7. #undef complex
  8. #endif
  9. #ifdef I
  10. #undef I
  11. #endif
  12. #if defined(_WIN64)
  13. typedef long long BLASLONG;
  14. typedef unsigned long long BLASULONG;
  15. #else
  16. typedef long BLASLONG;
  17. typedef unsigned long BLASULONG;
  18. #endif
  19. #ifdef LAPACK_ILP64
  20. typedef BLASLONG blasint;
  21. #if defined(_WIN64)
  22. #define blasabs(x) llabs(x)
  23. #else
  24. #define blasabs(x) labs(x)
  25. #endif
  26. #else
  27. typedef int blasint;
  28. #define blasabs(x) abs(x)
  29. #endif
  30. typedef blasint integer;
  31. typedef unsigned int uinteger;
  32. typedef char *address;
  33. typedef short int shortint;
  34. typedef float real;
  35. typedef double doublereal;
  36. typedef struct { real r, i; } complex;
  37. typedef struct { doublereal r, i; } doublecomplex;
  38. #ifdef _MSC_VER
  39. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  40. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  41. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  42. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  43. #else
  44. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  46. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  47. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  48. #endif
  49. #define pCf(z) (*_pCf(z))
  50. #define pCd(z) (*_pCd(z))
  51. typedef blasint logical;
  52. typedef char logical1;
  53. typedef char integer1;
  54. #define TRUE_ (1)
  55. #define FALSE_ (0)
  56. /* Extern is for use with -E */
  57. #ifndef Extern
  58. #define Extern extern
  59. #endif
  60. /* I/O stuff */
  61. typedef int flag;
  62. typedef int ftnlen;
  63. typedef int ftnint;
  64. /*external read, write*/
  65. typedef struct
  66. { flag cierr;
  67. ftnint ciunit;
  68. flag ciend;
  69. char *cifmt;
  70. ftnint cirec;
  71. } cilist;
  72. /*internal read, write*/
  73. typedef struct
  74. { flag icierr;
  75. char *iciunit;
  76. flag iciend;
  77. char *icifmt;
  78. ftnint icirlen;
  79. ftnint icirnum;
  80. } icilist;
  81. /*open*/
  82. typedef struct
  83. { flag oerr;
  84. ftnint ounit;
  85. char *ofnm;
  86. ftnlen ofnmlen;
  87. char *osta;
  88. char *oacc;
  89. char *ofm;
  90. ftnint orl;
  91. char *oblnk;
  92. } olist;
  93. /*close*/
  94. typedef struct
  95. { flag cerr;
  96. ftnint cunit;
  97. char *csta;
  98. } cllist;
  99. /*rewind, backspace, endfile*/
  100. typedef struct
  101. { flag aerr;
  102. ftnint aunit;
  103. } alist;
  104. /* inquire */
  105. typedef struct
  106. { flag inerr;
  107. ftnint inunit;
  108. char *infile;
  109. ftnlen infilen;
  110. ftnint *inex; /*parameters in standard's order*/
  111. ftnint *inopen;
  112. ftnint *innum;
  113. ftnint *innamed;
  114. char *inname;
  115. ftnlen innamlen;
  116. char *inacc;
  117. ftnlen inacclen;
  118. char *inseq;
  119. ftnlen inseqlen;
  120. char *indir;
  121. ftnlen indirlen;
  122. char *infmt;
  123. ftnlen infmtlen;
  124. char *inform;
  125. ftnint informlen;
  126. char *inunf;
  127. ftnlen inunflen;
  128. ftnint *inrecl;
  129. ftnint *innrec;
  130. char *inblank;
  131. ftnlen inblanklen;
  132. } inlist;
  133. #define VOID void
  134. union Multitype { /* for multiple entry points */
  135. integer1 g;
  136. shortint h;
  137. integer i;
  138. /* longint j; */
  139. real r;
  140. doublereal d;
  141. complex c;
  142. doublecomplex z;
  143. };
  144. typedef union Multitype Multitype;
  145. struct Vardesc { /* for Namelist */
  146. char *name;
  147. char *addr;
  148. ftnlen *dims;
  149. int type;
  150. };
  151. typedef struct Vardesc Vardesc;
  152. struct Namelist {
  153. char *name;
  154. Vardesc **vars;
  155. int nvars;
  156. };
  157. typedef struct Namelist Namelist;
  158. #define abs(x) ((x) >= 0 ? (x) : -(x))
  159. #define dabs(x) (fabs(x))
  160. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  161. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  162. #define dmin(a,b) (f2cmin(a,b))
  163. #define dmax(a,b) (f2cmax(a,b))
  164. #define bit_test(a,b) ((a) >> (b) & 1)
  165. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  166. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  167. #define abort_() { sig_die("Fortran abort routine called", 1); }
  168. #define c_abs(z) (cabsf(Cf(z)))
  169. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  170. #ifdef _MSC_VER
  171. #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
  172. #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
  173. #else
  174. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  175. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  176. #endif
  177. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  178. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  179. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  180. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  181. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  182. #define d_abs(x) (fabs(*(x)))
  183. #define d_acos(x) (acos(*(x)))
  184. #define d_asin(x) (asin(*(x)))
  185. #define d_atan(x) (atan(*(x)))
  186. #define d_atn2(x, y) (atan2(*(x),*(y)))
  187. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  188. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  189. #define d_cos(x) (cos(*(x)))
  190. #define d_cosh(x) (cosh(*(x)))
  191. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  192. #define d_exp(x) (exp(*(x)))
  193. #define d_imag(z) (cimag(Cd(z)))
  194. #define r_imag(z) (cimagf(Cf(z)))
  195. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  196. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  198. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define d_log(x) (log(*(x)))
  200. #define d_mod(x, y) (fmod(*(x), *(y)))
  201. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  202. #define d_nint(x) u_nint(*(x))
  203. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  204. #define d_sign(a,b) u_sign(*(a),*(b))
  205. #define r_sign(a,b) u_sign(*(a),*(b))
  206. #define d_sin(x) (sin(*(x)))
  207. #define d_sinh(x) (sinh(*(x)))
  208. #define d_sqrt(x) (sqrt(*(x)))
  209. #define d_tan(x) (tan(*(x)))
  210. #define d_tanh(x) (tanh(*(x)))
  211. #define i_abs(x) abs(*(x))
  212. #define i_dnnt(x) ((integer)u_nint(*(x)))
  213. #define i_len(s, n) (n)
  214. #define i_nint(x) ((integer)u_nint(*(x)))
  215. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  216. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  217. #define pow_si(B,E) spow_ui(*(B),*(E))
  218. #define pow_ri(B,E) spow_ui(*(B),*(E))
  219. #define pow_di(B,E) dpow_ui(*(B),*(E))
  220. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  221. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  222. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  223. #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
  224. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  225. #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
  226. #define sig_die(s, kill) { exit(1); }
  227. #define s_stop(s, n) {exit(0);}
  228. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  229. #define z_abs(z) (cabs(Cd(z)))
  230. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  231. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  232. #define myexit_() break;
  233. #define mycycle() continue;
  234. #define myceiling(w) {ceil(w)}
  235. #define myhuge(w) {HUGE_VAL}
  236. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  237. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  238. /* procedure parameter types for -A and -C++ */
  239. #ifdef __cplusplus
  240. typedef logical (*L_fp)(...);
  241. #else
  242. typedef logical (*L_fp)();
  243. #endif
  244. static float spow_ui(float x, integer n) {
  245. float pow=1.0; unsigned long int u;
  246. if(n != 0) {
  247. if(n < 0) n = -n, x = 1/x;
  248. for(u = n; ; ) {
  249. if(u & 01) pow *= x;
  250. if(u >>= 1) x *= x;
  251. else break;
  252. }
  253. }
  254. return pow;
  255. }
  256. static double dpow_ui(double x, integer n) {
  257. double pow=1.0; unsigned long int u;
  258. if(n != 0) {
  259. if(n < 0) n = -n, x = 1/x;
  260. for(u = n; ; ) {
  261. if(u & 01) pow *= x;
  262. if(u >>= 1) x *= x;
  263. else break;
  264. }
  265. }
  266. return pow;
  267. }
  268. #ifdef _MSC_VER
  269. static _Fcomplex cpow_ui(complex x, integer n) {
  270. complex pow={1.0,0.0}; unsigned long int u;
  271. if(n != 0) {
  272. if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
  273. for(u = n; ; ) {
  274. if(u & 01) pow.r *= x.r, pow.i *= x.i;
  275. if(u >>= 1) x.r *= x.r, x.i *= x.i;
  276. else break;
  277. }
  278. }
  279. _Fcomplex p={pow.r, pow.i};
  280. return p;
  281. }
  282. #else
  283. static _Complex float cpow_ui(_Complex float x, integer n) {
  284. _Complex float pow=1.0; unsigned long int u;
  285. if(n != 0) {
  286. if(n < 0) n = -n, x = 1/x;
  287. for(u = n; ; ) {
  288. if(u & 01) pow *= x;
  289. if(u >>= 1) x *= x;
  290. else break;
  291. }
  292. }
  293. return pow;
  294. }
  295. #endif
  296. #ifdef _MSC_VER
  297. static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
  298. _Dcomplex pow={1.0,0.0}; unsigned long int u;
  299. if(n != 0) {
  300. if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
  301. for(u = n; ; ) {
  302. if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
  303. if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
  304. else break;
  305. }
  306. }
  307. _Dcomplex p = {pow._Val[0], pow._Val[1]};
  308. return p;
  309. }
  310. #else
  311. static _Complex double zpow_ui(_Complex double x, integer n) {
  312. _Complex double pow=1.0; unsigned long int u;
  313. if(n != 0) {
  314. if(n < 0) n = -n, x = 1/x;
  315. for(u = n; ; ) {
  316. if(u & 01) pow *= x;
  317. if(u >>= 1) x *= x;
  318. else break;
  319. }
  320. }
  321. return pow;
  322. }
  323. #endif
  324. static integer pow_ii(integer x, integer n) {
  325. integer pow; unsigned long int u;
  326. if (n <= 0) {
  327. if (n == 0 || x == 1) pow = 1;
  328. else if (x != -1) pow = x == 0 ? 1/x : 0;
  329. else n = -n;
  330. }
  331. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  332. u = n;
  333. for(pow = 1; ; ) {
  334. if(u & 01) pow *= x;
  335. if(u >>= 1) x *= x;
  336. else break;
  337. }
  338. }
  339. return pow;
  340. }
  341. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  342. {
  343. double m; integer i, mi;
  344. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  345. if (w[i-1]>m) mi=i ,m=w[i-1];
  346. return mi-s+1;
  347. }
  348. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  349. {
  350. float m; integer i, mi;
  351. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  352. if (w[i-1]>m) mi=i ,m=w[i-1];
  353. return mi-s+1;
  354. }
  355. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  356. integer n = *n_, incx = *incx_, incy = *incy_, i;
  357. #ifdef _MSC_VER
  358. _Fcomplex zdotc = {0.0, 0.0};
  359. if (incx == 1 && incy == 1) {
  360. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  361. zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
  362. zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
  363. }
  364. } else {
  365. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  366. zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
  367. zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
  368. }
  369. }
  370. pCf(z) = zdotc;
  371. }
  372. #else
  373. _Complex float zdotc = 0.0;
  374. if (incx == 1 && incy == 1) {
  375. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  376. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  377. }
  378. } else {
  379. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  380. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  381. }
  382. }
  383. pCf(z) = zdotc;
  384. }
  385. #endif
  386. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  387. integer n = *n_, incx = *incx_, incy = *incy_, i;
  388. #ifdef _MSC_VER
  389. _Dcomplex zdotc = {0.0, 0.0};
  390. if (incx == 1 && incy == 1) {
  391. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  392. zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
  393. zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
  394. }
  395. } else {
  396. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  397. zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
  398. zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
  399. }
  400. }
  401. pCd(z) = zdotc;
  402. }
  403. #else
  404. _Complex double zdotc = 0.0;
  405. if (incx == 1 && incy == 1) {
  406. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  407. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  408. }
  409. } else {
  410. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  411. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  412. }
  413. }
  414. pCd(z) = zdotc;
  415. }
  416. #endif
  417. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  418. integer n = *n_, incx = *incx_, incy = *incy_, i;
  419. #ifdef _MSC_VER
  420. _Fcomplex zdotc = {0.0, 0.0};
  421. if (incx == 1 && incy == 1) {
  422. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  423. zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
  424. zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
  425. }
  426. } else {
  427. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  428. zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
  429. zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
  430. }
  431. }
  432. pCf(z) = zdotc;
  433. }
  434. #else
  435. _Complex float zdotc = 0.0;
  436. if (incx == 1 && incy == 1) {
  437. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  438. zdotc += Cf(&x[i]) * Cf(&y[i]);
  439. }
  440. } else {
  441. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  442. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  443. }
  444. }
  445. pCf(z) = zdotc;
  446. }
  447. #endif
  448. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  449. integer n = *n_, incx = *incx_, incy = *incy_, i;
  450. #ifdef _MSC_VER
  451. _Dcomplex zdotc = {0.0, 0.0};
  452. if (incx == 1 && incy == 1) {
  453. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  454. zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
  455. zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
  456. }
  457. } else {
  458. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  459. zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
  460. zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
  461. }
  462. }
  463. pCd(z) = zdotc;
  464. }
  465. #else
  466. _Complex double zdotc = 0.0;
  467. if (incx == 1 && incy == 1) {
  468. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  469. zdotc += Cd(&x[i]) * Cd(&y[i]);
  470. }
  471. } else {
  472. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  473. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  474. }
  475. }
  476. pCd(z) = zdotc;
  477. }
  478. #endif
  479. /* -- translated by f2c (version 20000121).
  480. You must link the resulting object file with the libraries:
  481. -lf2c -lm (in that order)
  482. */
  483. /* Table of constant values */
  484. static integer c__1 = 1;
  485. static real c_b36 = .5f;
  486. /* > \brief \b CLATPS solves a triangular system of equations with the matrix held in packed storage. */
  487. /* =========== DOCUMENTATION =========== */
  488. /* Online html documentation available at */
  489. /* http://www.netlib.org/lapack/explore-html/ */
  490. /* > \htmlonly */
  491. /* > Download CLATPS + dependencies */
  492. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clatps.
  493. f"> */
  494. /* > [TGZ]</a> */
  495. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clatps.
  496. f"> */
  497. /* > [ZIP]</a> */
  498. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clatps.
  499. f"> */
  500. /* > [TXT]</a> */
  501. /* > \endhtmlonly */
  502. /* Definition: */
  503. /* =========== */
  504. /* SUBROUTINE CLATPS( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE, */
  505. /* CNORM, INFO ) */
  506. /* CHARACTER DIAG, NORMIN, TRANS, UPLO */
  507. /* INTEGER INFO, N */
  508. /* REAL SCALE */
  509. /* REAL CNORM( * ) */
  510. /* COMPLEX AP( * ), X( * ) */
  511. /* > \par Purpose: */
  512. /* ============= */
  513. /* > */
  514. /* > \verbatim */
  515. /* > */
  516. /* > CLATPS solves one of the triangular systems */
  517. /* > */
  518. /* > A * x = s*b, A**T * x = s*b, or A**H * x = s*b, */
  519. /* > */
  520. /* > with scaling to prevent overflow, where A is an upper or lower */
  521. /* > triangular matrix stored in packed form. Here A**T denotes the */
  522. /* > transpose of A, A**H denotes the conjugate transpose of A, x and b */
  523. /* > are n-element vectors, and s is a scaling factor, usually less than */
  524. /* > or equal to 1, chosen so that the components of x will be less than */
  525. /* > the overflow threshold. If the unscaled problem will not cause */
  526. /* > overflow, the Level 2 BLAS routine CTPSV is called. If the matrix A */
  527. /* > is singular (A(j,j) = 0 for some j), then s is set to 0 and a */
  528. /* > non-trivial solution to A*x = 0 is returned. */
  529. /* > \endverbatim */
  530. /* Arguments: */
  531. /* ========== */
  532. /* > \param[in] UPLO */
  533. /* > \verbatim */
  534. /* > UPLO is CHARACTER*1 */
  535. /* > Specifies whether the matrix A is upper or lower triangular. */
  536. /* > = 'U': Upper triangular */
  537. /* > = 'L': Lower triangular */
  538. /* > \endverbatim */
  539. /* > */
  540. /* > \param[in] TRANS */
  541. /* > \verbatim */
  542. /* > TRANS is CHARACTER*1 */
  543. /* > Specifies the operation applied to A. */
  544. /* > = 'N': Solve A * x = s*b (No transpose) */
  545. /* > = 'T': Solve A**T * x = s*b (Transpose) */
  546. /* > = 'C': Solve A**H * x = s*b (Conjugate transpose) */
  547. /* > \endverbatim */
  548. /* > */
  549. /* > \param[in] DIAG */
  550. /* > \verbatim */
  551. /* > DIAG is CHARACTER*1 */
  552. /* > Specifies whether or not the matrix A is unit triangular. */
  553. /* > = 'N': Non-unit triangular */
  554. /* > = 'U': Unit triangular */
  555. /* > \endverbatim */
  556. /* > */
  557. /* > \param[in] NORMIN */
  558. /* > \verbatim */
  559. /* > NORMIN is CHARACTER*1 */
  560. /* > Specifies whether CNORM has been set or not. */
  561. /* > = 'Y': CNORM contains the column norms on entry */
  562. /* > = 'N': CNORM is not set on entry. On exit, the norms will */
  563. /* > be computed and stored in CNORM. */
  564. /* > \endverbatim */
  565. /* > */
  566. /* > \param[in] N */
  567. /* > \verbatim */
  568. /* > N is INTEGER */
  569. /* > The order of the matrix A. N >= 0. */
  570. /* > \endverbatim */
  571. /* > */
  572. /* > \param[in] AP */
  573. /* > \verbatim */
  574. /* > AP is COMPLEX array, dimension (N*(N+1)/2) */
  575. /* > The upper or lower triangular matrix A, packed columnwise in */
  576. /* > a linear array. The j-th column of A is stored in the array */
  577. /* > AP as follows: */
  578. /* > if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
  579. /* > if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
  580. /* > \endverbatim */
  581. /* > */
  582. /* > \param[in,out] X */
  583. /* > \verbatim */
  584. /* > X is COMPLEX array, dimension (N) */
  585. /* > On entry, the right hand side b of the triangular system. */
  586. /* > On exit, X is overwritten by the solution vector x. */
  587. /* > \endverbatim */
  588. /* > */
  589. /* > \param[out] SCALE */
  590. /* > \verbatim */
  591. /* > SCALE is REAL */
  592. /* > The scaling factor s for the triangular system */
  593. /* > A * x = s*b, A**T * x = s*b, or A**H * x = s*b. */
  594. /* > If SCALE = 0, the matrix A is singular or badly scaled, and */
  595. /* > the vector x is an exact or approximate solution to A*x = 0. */
  596. /* > \endverbatim */
  597. /* > */
  598. /* > \param[in,out] CNORM */
  599. /* > \verbatim */
  600. /* > CNORM is REAL array, dimension (N) */
  601. /* > */
  602. /* > If NORMIN = 'Y', CNORM is an input argument and CNORM(j) */
  603. /* > contains the norm of the off-diagonal part of the j-th column */
  604. /* > of A. If TRANS = 'N', CNORM(j) must be greater than or equal */
  605. /* > to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j) */
  606. /* > must be greater than or equal to the 1-norm. */
  607. /* > */
  608. /* > If NORMIN = 'N', CNORM is an output argument and CNORM(j) */
  609. /* > returns the 1-norm of the offdiagonal part of the j-th column */
  610. /* > of A. */
  611. /* > \endverbatim */
  612. /* > */
  613. /* > \param[out] INFO */
  614. /* > \verbatim */
  615. /* > INFO is INTEGER */
  616. /* > = 0: successful exit */
  617. /* > < 0: if INFO = -k, the k-th argument had an illegal value */
  618. /* > \endverbatim */
  619. /* Authors: */
  620. /* ======== */
  621. /* > \author Univ. of Tennessee */
  622. /* > \author Univ. of California Berkeley */
  623. /* > \author Univ. of Colorado Denver */
  624. /* > \author NAG Ltd. */
  625. /* > \date December 2016 */
  626. /* > \ingroup complexOTHERauxiliary */
  627. /* > \par Further Details: */
  628. /* ===================== */
  629. /* > */
  630. /* > \verbatim */
  631. /* > */
  632. /* > A rough bound on x is computed; if that is less than overflow, CTPSV */
  633. /* > is called, otherwise, specific code is used which checks for possible */
  634. /* > overflow or divide-by-zero at every operation. */
  635. /* > */
  636. /* > A columnwise scheme is used for solving A*x = b. The basic algorithm */
  637. /* > if A is lower triangular is */
  638. /* > */
  639. /* > x[1:n] := b[1:n] */
  640. /* > for j = 1, ..., n */
  641. /* > x(j) := x(j) / A(j,j) */
  642. /* > x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j] */
  643. /* > end */
  644. /* > */
  645. /* > Define bounds on the components of x after j iterations of the loop: */
  646. /* > M(j) = bound on x[1:j] */
  647. /* > G(j) = bound on x[j+1:n] */
  648. /* > Initially, let M(0) = 0 and G(0) = f2cmax{x(i), i=1,...,n}. */
  649. /* > */
  650. /* > Then for iteration j+1 we have */
  651. /* > M(j+1) <= G(j) / | A(j+1,j+1) | */
  652. /* > G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] | */
  653. /* > <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | ) */
  654. /* > */
  655. /* > where CNORM(j+1) is greater than or equal to the infinity-norm of */
  656. /* > column j+1 of A, not counting the diagonal. Hence */
  657. /* > */
  658. /* > G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | ) */
  659. /* > 1<=i<=j */
  660. /* > and */
  661. /* > */
  662. /* > |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| ) */
  663. /* > 1<=i< j */
  664. /* > */
  665. /* > Since |x(j)| <= M(j), we use the Level 2 BLAS routine CTPSV if the */
  666. /* > reciprocal of the largest M(j), j=1,..,n, is larger than */
  667. /* > f2cmax(underflow, 1/overflow). */
  668. /* > */
  669. /* > The bound on x(j) is also used to determine when a step in the */
  670. /* > columnwise method can be performed without fear of overflow. If */
  671. /* > the computed bound is greater than a large constant, x is scaled to */
  672. /* > prevent overflow, but if the bound overflows, x is set to 0, x(j) to */
  673. /* > 1, and scale to 0, and a non-trivial solution to A*x = 0 is found. */
  674. /* > */
  675. /* > Similarly, a row-wise scheme is used to solve A**T *x = b or */
  676. /* > A**H *x = b. The basic algorithm for A upper triangular is */
  677. /* > */
  678. /* > for j = 1, ..., n */
  679. /* > x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j) */
  680. /* > end */
  681. /* > */
  682. /* > We simultaneously compute two bounds */
  683. /* > G(j) = bound on ( b(i) - A[1:i-1,i]' * x[1:i-1] ), 1<=i<=j */
  684. /* > M(j) = bound on x(i), 1<=i<=j */
  685. /* > */
  686. /* > The initial values are G(0) = 0, M(0) = f2cmax{b(i), i=1,..,n}, and we */
  687. /* > add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1. */
  688. /* > Then the bound on x(j) is */
  689. /* > */
  690. /* > M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) | */
  691. /* > */
  692. /* > <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| ) */
  693. /* > 1<=i<=j */
  694. /* > */
  695. /* > and we can safely call CTPSV if 1/M(n) and 1/G(n) are both greater */
  696. /* > than f2cmax(underflow, 1/overflow). */
  697. /* > \endverbatim */
  698. /* > */
  699. /* ===================================================================== */
  700. /* Subroutine */ void clatps_(char *uplo, char *trans, char *diag, char *
  701. normin, integer *n, complex *ap, complex *x, real *scale, real *cnorm,
  702. integer *info)
  703. {
  704. /* System generated locals */
  705. integer i__1, i__2, i__3, i__4, i__5;
  706. real r__1, r__2, r__3, r__4;
  707. complex q__1, q__2, q__3, q__4;
  708. /* Local variables */
  709. integer jinc, jlen;
  710. real xbnd;
  711. integer imax;
  712. real tmax;
  713. complex tjjs;
  714. real xmax, grow;
  715. integer i__, j;
  716. extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer
  717. *, complex *, integer *);
  718. extern logical lsame_(char *, char *);
  719. extern /* Subroutine */ void sscal_(integer *, real *, real *, integer *);
  720. real tscal;
  721. complex uscal;
  722. integer jlast;
  723. extern /* Complex */ VOID cdotu_(complex *, integer *, complex *, integer
  724. *, complex *, integer *);
  725. complex csumj;
  726. extern /* Subroutine */ void caxpy_(integer *, complex *, complex *,
  727. integer *, complex *, integer *);
  728. logical upper;
  729. extern /* Subroutine */ void ctpsv_(char *, char *, char *, integer *,
  730. complex *, complex *, integer *), slabad_(
  731. real *, real *);
  732. integer ip;
  733. real xj;
  734. extern integer icamax_(integer *, complex *, integer *);
  735. extern /* Complex */ VOID cladiv_(complex *, complex *, complex *);
  736. extern real slamch_(char *);
  737. extern /* Subroutine */ void csscal_(integer *, real *, complex *, integer
  738. *);
  739. extern int xerbla_(char *, integer *, ftnlen);
  740. real bignum;
  741. extern integer isamax_(integer *, real *, integer *);
  742. extern real scasum_(integer *, complex *, integer *);
  743. logical notran;
  744. integer jfirst;
  745. real smlnum;
  746. logical nounit;
  747. real rec, tjj;
  748. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  749. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  750. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  751. /* December 2016 */
  752. /* ===================================================================== */
  753. /* Parameter adjustments */
  754. --cnorm;
  755. --x;
  756. --ap;
  757. /* Function Body */
  758. *info = 0;
  759. upper = lsame_(uplo, "U");
  760. notran = lsame_(trans, "N");
  761. nounit = lsame_(diag, "N");
  762. /* Test the input parameters. */
  763. if (! upper && ! lsame_(uplo, "L")) {
  764. *info = -1;
  765. } else if (! notran && ! lsame_(trans, "T") && !
  766. lsame_(trans, "C")) {
  767. *info = -2;
  768. } else if (! nounit && ! lsame_(diag, "U")) {
  769. *info = -3;
  770. } else if (! lsame_(normin, "Y") && ! lsame_(normin,
  771. "N")) {
  772. *info = -4;
  773. } else if (*n < 0) {
  774. *info = -5;
  775. }
  776. if (*info != 0) {
  777. i__1 = -(*info);
  778. xerbla_("CLATPS", &i__1, (ftnlen)6);
  779. return;
  780. }
  781. /* Quick return if possible */
  782. if (*n == 0) {
  783. return;
  784. }
  785. /* Determine machine dependent parameters to control overflow. */
  786. smlnum = slamch_("Safe minimum");
  787. bignum = 1.f / smlnum;
  788. slabad_(&smlnum, &bignum);
  789. smlnum /= slamch_("Precision");
  790. bignum = 1.f / smlnum;
  791. *scale = 1.f;
  792. if (lsame_(normin, "N")) {
  793. /* Compute the 1-norm of each column, not including the diagonal. */
  794. if (upper) {
  795. /* A is upper triangular. */
  796. ip = 1;
  797. i__1 = *n;
  798. for (j = 1; j <= i__1; ++j) {
  799. i__2 = j - 1;
  800. cnorm[j] = scasum_(&i__2, &ap[ip], &c__1);
  801. ip += j;
  802. /* L10: */
  803. }
  804. } else {
  805. /* A is lower triangular. */
  806. ip = 1;
  807. i__1 = *n - 1;
  808. for (j = 1; j <= i__1; ++j) {
  809. i__2 = *n - j;
  810. cnorm[j] = scasum_(&i__2, &ap[ip + 1], &c__1);
  811. ip = ip + *n - j + 1;
  812. /* L20: */
  813. }
  814. cnorm[*n] = 0.f;
  815. }
  816. }
  817. /* Scale the column norms by TSCAL if the maximum element in CNORM is */
  818. /* greater than BIGNUM/2. */
  819. imax = isamax_(n, &cnorm[1], &c__1);
  820. tmax = cnorm[imax];
  821. if (tmax <= bignum * .5f) {
  822. tscal = 1.f;
  823. } else {
  824. tscal = .5f / (smlnum * tmax);
  825. sscal_(n, &tscal, &cnorm[1], &c__1);
  826. }
  827. /* Compute a bound on the computed solution vector to see if the */
  828. /* Level 2 BLAS routine CTPSV can be used. */
  829. xmax = 0.f;
  830. i__1 = *n;
  831. for (j = 1; j <= i__1; ++j) {
  832. /* Computing MAX */
  833. i__2 = j;
  834. r__3 = xmax, r__4 = (r__1 = x[i__2].r / 2.f, abs(r__1)) + (r__2 =
  835. r_imag(&x[j]) / 2.f, abs(r__2));
  836. xmax = f2cmax(r__3,r__4);
  837. /* L30: */
  838. }
  839. xbnd = xmax;
  840. if (notran) {
  841. /* Compute the growth in A * x = b. */
  842. if (upper) {
  843. jfirst = *n;
  844. jlast = 1;
  845. jinc = -1;
  846. } else {
  847. jfirst = 1;
  848. jlast = *n;
  849. jinc = 1;
  850. }
  851. if (tscal != 1.f) {
  852. grow = 0.f;
  853. goto L60;
  854. }
  855. if (nounit) {
  856. /* A is non-unit triangular. */
  857. /* Compute GROW = 1/G(j) and XBND = 1/M(j). */
  858. /* Initially, G(0) = f2cmax{x(i), i=1,...,n}. */
  859. grow = .5f / f2cmax(xbnd,smlnum);
  860. xbnd = grow;
  861. ip = jfirst * (jfirst + 1) / 2;
  862. jlen = *n;
  863. i__1 = jlast;
  864. i__2 = jinc;
  865. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  866. /* Exit the loop if the growth factor is too small. */
  867. if (grow <= smlnum) {
  868. goto L60;
  869. }
  870. i__3 = ip;
  871. tjjs.r = ap[i__3].r, tjjs.i = ap[i__3].i;
  872. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
  873. r__2));
  874. if (tjj >= smlnum) {
  875. /* M(j) = G(j-1) / abs(A(j,j)) */
  876. /* Computing MIN */
  877. r__1 = xbnd, r__2 = f2cmin(1.f,tjj) * grow;
  878. xbnd = f2cmin(r__1,r__2);
  879. } else {
  880. /* M(j) could overflow, set XBND to 0. */
  881. xbnd = 0.f;
  882. }
  883. if (tjj + cnorm[j] >= smlnum) {
  884. /* G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) ) */
  885. grow *= tjj / (tjj + cnorm[j]);
  886. } else {
  887. /* G(j) could overflow, set GROW to 0. */
  888. grow = 0.f;
  889. }
  890. ip += jinc * jlen;
  891. --jlen;
  892. /* L40: */
  893. }
  894. grow = xbnd;
  895. } else {
  896. /* A is unit triangular. */
  897. /* Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
  898. /* Computing MIN */
  899. r__1 = 1.f, r__2 = .5f / f2cmax(xbnd,smlnum);
  900. grow = f2cmin(r__1,r__2);
  901. i__2 = jlast;
  902. i__1 = jinc;
  903. for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  904. /* Exit the loop if the growth factor is too small. */
  905. if (grow <= smlnum) {
  906. goto L60;
  907. }
  908. /* G(j) = G(j-1)*( 1 + CNORM(j) ) */
  909. grow *= 1.f / (cnorm[j] + 1.f);
  910. /* L50: */
  911. }
  912. }
  913. L60:
  914. ;
  915. } else {
  916. /* Compute the growth in A**T * x = b or A**H * x = b. */
  917. if (upper) {
  918. jfirst = 1;
  919. jlast = *n;
  920. jinc = 1;
  921. } else {
  922. jfirst = *n;
  923. jlast = 1;
  924. jinc = -1;
  925. }
  926. if (tscal != 1.f) {
  927. grow = 0.f;
  928. goto L90;
  929. }
  930. if (nounit) {
  931. /* A is non-unit triangular. */
  932. /* Compute GROW = 1/G(j) and XBND = 1/M(j). */
  933. /* Initially, M(0) = f2cmax{x(i), i=1,...,n}. */
  934. grow = .5f / f2cmax(xbnd,smlnum);
  935. xbnd = grow;
  936. ip = jfirst * (jfirst + 1) / 2;
  937. jlen = 1;
  938. i__1 = jlast;
  939. i__2 = jinc;
  940. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  941. /* Exit the loop if the growth factor is too small. */
  942. if (grow <= smlnum) {
  943. goto L90;
  944. }
  945. /* G(j) = f2cmax( G(j-1), M(j-1)*( 1 + CNORM(j) ) ) */
  946. xj = cnorm[j] + 1.f;
  947. /* Computing MIN */
  948. r__1 = grow, r__2 = xbnd / xj;
  949. grow = f2cmin(r__1,r__2);
  950. i__3 = ip;
  951. tjjs.r = ap[i__3].r, tjjs.i = ap[i__3].i;
  952. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
  953. r__2));
  954. if (tjj >= smlnum) {
  955. /* M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j)) */
  956. if (xj > tjj) {
  957. xbnd *= tjj / xj;
  958. }
  959. } else {
  960. /* M(j) could overflow, set XBND to 0. */
  961. xbnd = 0.f;
  962. }
  963. ++jlen;
  964. ip += jinc * jlen;
  965. /* L70: */
  966. }
  967. grow = f2cmin(grow,xbnd);
  968. } else {
  969. /* A is unit triangular. */
  970. /* Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
  971. /* Computing MIN */
  972. r__1 = 1.f, r__2 = .5f / f2cmax(xbnd,smlnum);
  973. grow = f2cmin(r__1,r__2);
  974. i__2 = jlast;
  975. i__1 = jinc;
  976. for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  977. /* Exit the loop if the growth factor is too small. */
  978. if (grow <= smlnum) {
  979. goto L90;
  980. }
  981. /* G(j) = ( 1 + CNORM(j) )*G(j-1) */
  982. xj = cnorm[j] + 1.f;
  983. grow /= xj;
  984. /* L80: */
  985. }
  986. }
  987. L90:
  988. ;
  989. }
  990. if (grow * tscal > smlnum) {
  991. /* Use the Level 2 BLAS solve if the reciprocal of the bound on */
  992. /* elements of X is not too small. */
  993. ctpsv_(uplo, trans, diag, n, &ap[1], &x[1], &c__1);
  994. } else {
  995. /* Use a Level 1 BLAS solve, scaling intermediate results. */
  996. if (xmax > bignum * .5f) {
  997. /* Scale X so that its components are less than or equal to */
  998. /* BIGNUM in absolute value. */
  999. *scale = bignum * .5f / xmax;
  1000. csscal_(n, scale, &x[1], &c__1);
  1001. xmax = bignum;
  1002. } else {
  1003. xmax *= 2.f;
  1004. }
  1005. if (notran) {
  1006. /* Solve A * x = b */
  1007. ip = jfirst * (jfirst + 1) / 2;
  1008. i__1 = jlast;
  1009. i__2 = jinc;
  1010. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  1011. /* Compute x(j) = b(j) / A(j,j), scaling x if necessary. */
  1012. i__3 = j;
  1013. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
  1014. abs(r__2));
  1015. if (nounit) {
  1016. i__3 = ip;
  1017. q__1.r = tscal * ap[i__3].r, q__1.i = tscal * ap[i__3].i;
  1018. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1019. } else {
  1020. tjjs.r = tscal, tjjs.i = 0.f;
  1021. if (tscal == 1.f) {
  1022. goto L105;
  1023. }
  1024. }
  1025. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
  1026. r__2));
  1027. if (tjj > smlnum) {
  1028. /* abs(A(j,j)) > SMLNUM: */
  1029. if (tjj < 1.f) {
  1030. if (xj > tjj * bignum) {
  1031. /* Scale x by 1/b(j). */
  1032. rec = 1.f / xj;
  1033. csscal_(n, &rec, &x[1], &c__1);
  1034. *scale *= rec;
  1035. xmax *= rec;
  1036. }
  1037. }
  1038. i__3 = j;
  1039. cladiv_(&q__1, &x[j], &tjjs);
  1040. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1041. i__3 = j;
  1042. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1043. , abs(r__2));
  1044. } else if (tjj > 0.f) {
  1045. /* 0 < abs(A(j,j)) <= SMLNUM: */
  1046. if (xj > tjj * bignum) {
  1047. /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM */
  1048. /* to avoid overflow when dividing by A(j,j). */
  1049. rec = tjj * bignum / xj;
  1050. if (cnorm[j] > 1.f) {
  1051. /* Scale by 1/CNORM(j) to avoid overflow when */
  1052. /* multiplying x(j) times column j. */
  1053. rec /= cnorm[j];
  1054. }
  1055. csscal_(n, &rec, &x[1], &c__1);
  1056. *scale *= rec;
  1057. xmax *= rec;
  1058. }
  1059. i__3 = j;
  1060. cladiv_(&q__1, &x[j], &tjjs);
  1061. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1062. i__3 = j;
  1063. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1064. , abs(r__2));
  1065. } else {
  1066. /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
  1067. /* scale = 0, and compute a solution to A*x = 0. */
  1068. i__3 = *n;
  1069. for (i__ = 1; i__ <= i__3; ++i__) {
  1070. i__4 = i__;
  1071. x[i__4].r = 0.f, x[i__4].i = 0.f;
  1072. /* L100: */
  1073. }
  1074. i__3 = j;
  1075. x[i__3].r = 1.f, x[i__3].i = 0.f;
  1076. xj = 1.f;
  1077. *scale = 0.f;
  1078. xmax = 0.f;
  1079. }
  1080. L105:
  1081. /* Scale x if necessary to avoid overflow when adding a */
  1082. /* multiple of column j of A. */
  1083. if (xj > 1.f) {
  1084. rec = 1.f / xj;
  1085. if (cnorm[j] > (bignum - xmax) * rec) {
  1086. /* Scale x by 1/(2*abs(x(j))). */
  1087. rec *= .5f;
  1088. csscal_(n, &rec, &x[1], &c__1);
  1089. *scale *= rec;
  1090. }
  1091. } else if (xj * cnorm[j] > bignum - xmax) {
  1092. /* Scale x by 1/2. */
  1093. csscal_(n, &c_b36, &x[1], &c__1);
  1094. *scale *= .5f;
  1095. }
  1096. if (upper) {
  1097. if (j > 1) {
  1098. /* Compute the update */
  1099. /* x(1:j-1) := x(1:j-1) - x(j) * A(1:j-1,j) */
  1100. i__3 = j - 1;
  1101. i__4 = j;
  1102. q__2.r = -x[i__4].r, q__2.i = -x[i__4].i;
  1103. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1104. caxpy_(&i__3, &q__1, &ap[ip - j + 1], &c__1, &x[1], &
  1105. c__1);
  1106. i__3 = j - 1;
  1107. i__ = icamax_(&i__3, &x[1], &c__1);
  1108. i__3 = i__;
  1109. xmax = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(
  1110. &x[i__]), abs(r__2));
  1111. }
  1112. ip -= j;
  1113. } else {
  1114. if (j < *n) {
  1115. /* Compute the update */
  1116. /* x(j+1:n) := x(j+1:n) - x(j) * A(j+1:n,j) */
  1117. i__3 = *n - j;
  1118. i__4 = j;
  1119. q__2.r = -x[i__4].r, q__2.i = -x[i__4].i;
  1120. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1121. caxpy_(&i__3, &q__1, &ap[ip + 1], &c__1, &x[j + 1], &
  1122. c__1);
  1123. i__3 = *n - j;
  1124. i__ = j + icamax_(&i__3, &x[j + 1], &c__1);
  1125. i__3 = i__;
  1126. xmax = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(
  1127. &x[i__]), abs(r__2));
  1128. }
  1129. ip = ip + *n - j + 1;
  1130. }
  1131. /* L110: */
  1132. }
  1133. } else if (lsame_(trans, "T")) {
  1134. /* Solve A**T * x = b */
  1135. ip = jfirst * (jfirst + 1) / 2;
  1136. jlen = 1;
  1137. i__2 = jlast;
  1138. i__1 = jinc;
  1139. for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  1140. /* Compute x(j) = b(j) - sum A(k,j)*x(k). */
  1141. /* k<>j */
  1142. i__3 = j;
  1143. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
  1144. abs(r__2));
  1145. uscal.r = tscal, uscal.i = 0.f;
  1146. rec = 1.f / f2cmax(xmax,1.f);
  1147. if (cnorm[j] > (bignum - xj) * rec) {
  1148. /* If x(j) could overflow, scale x by 1/(2*XMAX). */
  1149. rec *= .5f;
  1150. if (nounit) {
  1151. i__3 = ip;
  1152. q__1.r = tscal * ap[i__3].r, q__1.i = tscal * ap[i__3]
  1153. .i;
  1154. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1155. } else {
  1156. tjjs.r = tscal, tjjs.i = 0.f;
  1157. }
  1158. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1159. abs(r__2));
  1160. if (tjj > 1.f) {
  1161. /* Divide by A(j,j) when scaling x if A(j,j) > 1. */
  1162. /* Computing MIN */
  1163. r__1 = 1.f, r__2 = rec * tjj;
  1164. rec = f2cmin(r__1,r__2);
  1165. cladiv_(&q__1, &uscal, &tjjs);
  1166. uscal.r = q__1.r, uscal.i = q__1.i;
  1167. }
  1168. if (rec < 1.f) {
  1169. csscal_(n, &rec, &x[1], &c__1);
  1170. *scale *= rec;
  1171. xmax *= rec;
  1172. }
  1173. }
  1174. csumj.r = 0.f, csumj.i = 0.f;
  1175. if (uscal.r == 1.f && uscal.i == 0.f) {
  1176. /* If the scaling needed for A in the dot product is 1, */
  1177. /* call CDOTU to perform the dot product. */
  1178. if (upper) {
  1179. i__3 = j - 1;
  1180. cdotu_(&q__1, &i__3, &ap[ip - j + 1], &c__1, &x[1], &
  1181. c__1);
  1182. csumj.r = q__1.r, csumj.i = q__1.i;
  1183. } else if (j < *n) {
  1184. i__3 = *n - j;
  1185. cdotu_(&q__1, &i__3, &ap[ip + 1], &c__1, &x[j + 1], &
  1186. c__1);
  1187. csumj.r = q__1.r, csumj.i = q__1.i;
  1188. }
  1189. } else {
  1190. /* Otherwise, use in-line code for the dot product. */
  1191. if (upper) {
  1192. i__3 = j - 1;
  1193. for (i__ = 1; i__ <= i__3; ++i__) {
  1194. i__4 = ip - j + i__;
  1195. q__3.r = ap[i__4].r * uscal.r - ap[i__4].i *
  1196. uscal.i, q__3.i = ap[i__4].r * uscal.i +
  1197. ap[i__4].i * uscal.r;
  1198. i__5 = i__;
  1199. q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
  1200. q__2.i = q__3.r * x[i__5].i + q__3.i * x[
  1201. i__5].r;
  1202. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1203. q__2.i;
  1204. csumj.r = q__1.r, csumj.i = q__1.i;
  1205. /* L120: */
  1206. }
  1207. } else if (j < *n) {
  1208. i__3 = *n - j;
  1209. for (i__ = 1; i__ <= i__3; ++i__) {
  1210. i__4 = ip + i__;
  1211. q__3.r = ap[i__4].r * uscal.r - ap[i__4].i *
  1212. uscal.i, q__3.i = ap[i__4].r * uscal.i +
  1213. ap[i__4].i * uscal.r;
  1214. i__5 = j + i__;
  1215. q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
  1216. q__2.i = q__3.r * x[i__5].i + q__3.i * x[
  1217. i__5].r;
  1218. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1219. q__2.i;
  1220. csumj.r = q__1.r, csumj.i = q__1.i;
  1221. /* L130: */
  1222. }
  1223. }
  1224. }
  1225. q__1.r = tscal, q__1.i = 0.f;
  1226. if (uscal.r == q__1.r && uscal.i == q__1.i) {
  1227. /* Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
  1228. /* was not used to scale the dotproduct. */
  1229. i__3 = j;
  1230. i__4 = j;
  1231. q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
  1232. csumj.i;
  1233. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1234. i__3 = j;
  1235. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1236. , abs(r__2));
  1237. if (nounit) {
  1238. /* Compute x(j) = x(j) / A(j,j), scaling if necessary. */
  1239. i__3 = ip;
  1240. q__1.r = tscal * ap[i__3].r, q__1.i = tscal * ap[i__3]
  1241. .i;
  1242. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1243. } else {
  1244. tjjs.r = tscal, tjjs.i = 0.f;
  1245. if (tscal == 1.f) {
  1246. goto L145;
  1247. }
  1248. }
  1249. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1250. abs(r__2));
  1251. if (tjj > smlnum) {
  1252. /* abs(A(j,j)) > SMLNUM: */
  1253. if (tjj < 1.f) {
  1254. if (xj > tjj * bignum) {
  1255. /* Scale X by 1/abs(x(j)). */
  1256. rec = 1.f / xj;
  1257. csscal_(n, &rec, &x[1], &c__1);
  1258. *scale *= rec;
  1259. xmax *= rec;
  1260. }
  1261. }
  1262. i__3 = j;
  1263. cladiv_(&q__1, &x[j], &tjjs);
  1264. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1265. } else if (tjj > 0.f) {
  1266. /* 0 < abs(A(j,j)) <= SMLNUM: */
  1267. if (xj > tjj * bignum) {
  1268. /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
  1269. rec = tjj * bignum / xj;
  1270. csscal_(n, &rec, &x[1], &c__1);
  1271. *scale *= rec;
  1272. xmax *= rec;
  1273. }
  1274. i__3 = j;
  1275. cladiv_(&q__1, &x[j], &tjjs);
  1276. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1277. } else {
  1278. /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
  1279. /* scale = 0 and compute a solution to A**T *x = 0. */
  1280. i__3 = *n;
  1281. for (i__ = 1; i__ <= i__3; ++i__) {
  1282. i__4 = i__;
  1283. x[i__4].r = 0.f, x[i__4].i = 0.f;
  1284. /* L140: */
  1285. }
  1286. i__3 = j;
  1287. x[i__3].r = 1.f, x[i__3].i = 0.f;
  1288. *scale = 0.f;
  1289. xmax = 0.f;
  1290. }
  1291. L145:
  1292. ;
  1293. } else {
  1294. /* Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
  1295. /* product has already been divided by 1/A(j,j). */
  1296. i__3 = j;
  1297. cladiv_(&q__2, &x[j], &tjjs);
  1298. q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
  1299. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1300. }
  1301. /* Computing MAX */
  1302. i__3 = j;
  1303. r__3 = xmax, r__4 = (r__1 = x[i__3].r, abs(r__1)) + (r__2 =
  1304. r_imag(&x[j]), abs(r__2));
  1305. xmax = f2cmax(r__3,r__4);
  1306. ++jlen;
  1307. ip += jinc * jlen;
  1308. /* L150: */
  1309. }
  1310. } else {
  1311. /* Solve A**H * x = b */
  1312. ip = jfirst * (jfirst + 1) / 2;
  1313. jlen = 1;
  1314. i__1 = jlast;
  1315. i__2 = jinc;
  1316. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  1317. /* Compute x(j) = b(j) - sum A(k,j)*x(k). */
  1318. /* k<>j */
  1319. i__3 = j;
  1320. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
  1321. abs(r__2));
  1322. uscal.r = tscal, uscal.i = 0.f;
  1323. rec = 1.f / f2cmax(xmax,1.f);
  1324. if (cnorm[j] > (bignum - xj) * rec) {
  1325. /* If x(j) could overflow, scale x by 1/(2*XMAX). */
  1326. rec *= .5f;
  1327. if (nounit) {
  1328. r_cnjg(&q__2, &ap[ip]);
  1329. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1330. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1331. } else {
  1332. tjjs.r = tscal, tjjs.i = 0.f;
  1333. }
  1334. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1335. abs(r__2));
  1336. if (tjj > 1.f) {
  1337. /* Divide by A(j,j) when scaling x if A(j,j) > 1. */
  1338. /* Computing MIN */
  1339. r__1 = 1.f, r__2 = rec * tjj;
  1340. rec = f2cmin(r__1,r__2);
  1341. cladiv_(&q__1, &uscal, &tjjs);
  1342. uscal.r = q__1.r, uscal.i = q__1.i;
  1343. }
  1344. if (rec < 1.f) {
  1345. csscal_(n, &rec, &x[1], &c__1);
  1346. *scale *= rec;
  1347. xmax *= rec;
  1348. }
  1349. }
  1350. csumj.r = 0.f, csumj.i = 0.f;
  1351. if (uscal.r == 1.f && uscal.i == 0.f) {
  1352. /* If the scaling needed for A in the dot product is 1, */
  1353. /* call CDOTC to perform the dot product. */
  1354. if (upper) {
  1355. i__3 = j - 1;
  1356. cdotc_(&q__1, &i__3, &ap[ip - j + 1], &c__1, &x[1], &
  1357. c__1);
  1358. csumj.r = q__1.r, csumj.i = q__1.i;
  1359. } else if (j < *n) {
  1360. i__3 = *n - j;
  1361. cdotc_(&q__1, &i__3, &ap[ip + 1], &c__1, &x[j + 1], &
  1362. c__1);
  1363. csumj.r = q__1.r, csumj.i = q__1.i;
  1364. }
  1365. } else {
  1366. /* Otherwise, use in-line code for the dot product. */
  1367. if (upper) {
  1368. i__3 = j - 1;
  1369. for (i__ = 1; i__ <= i__3; ++i__) {
  1370. r_cnjg(&q__4, &ap[ip - j + i__]);
  1371. q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
  1372. q__3.i = q__4.r * uscal.i + q__4.i *
  1373. uscal.r;
  1374. i__4 = i__;
  1375. q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
  1376. q__2.i = q__3.r * x[i__4].i + q__3.i * x[
  1377. i__4].r;
  1378. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1379. q__2.i;
  1380. csumj.r = q__1.r, csumj.i = q__1.i;
  1381. /* L160: */
  1382. }
  1383. } else if (j < *n) {
  1384. i__3 = *n - j;
  1385. for (i__ = 1; i__ <= i__3; ++i__) {
  1386. r_cnjg(&q__4, &ap[ip + i__]);
  1387. q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
  1388. q__3.i = q__4.r * uscal.i + q__4.i *
  1389. uscal.r;
  1390. i__4 = j + i__;
  1391. q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
  1392. q__2.i = q__3.r * x[i__4].i + q__3.i * x[
  1393. i__4].r;
  1394. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1395. q__2.i;
  1396. csumj.r = q__1.r, csumj.i = q__1.i;
  1397. /* L170: */
  1398. }
  1399. }
  1400. }
  1401. q__1.r = tscal, q__1.i = 0.f;
  1402. if (uscal.r == q__1.r && uscal.i == q__1.i) {
  1403. /* Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
  1404. /* was not used to scale the dotproduct. */
  1405. i__3 = j;
  1406. i__4 = j;
  1407. q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
  1408. csumj.i;
  1409. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1410. i__3 = j;
  1411. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1412. , abs(r__2));
  1413. if (nounit) {
  1414. /* Compute x(j) = x(j) / A(j,j), scaling if necessary. */
  1415. r_cnjg(&q__2, &ap[ip]);
  1416. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1417. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1418. } else {
  1419. tjjs.r = tscal, tjjs.i = 0.f;
  1420. if (tscal == 1.f) {
  1421. goto L185;
  1422. }
  1423. }
  1424. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1425. abs(r__2));
  1426. if (tjj > smlnum) {
  1427. /* abs(A(j,j)) > SMLNUM: */
  1428. if (tjj < 1.f) {
  1429. if (xj > tjj * bignum) {
  1430. /* Scale X by 1/abs(x(j)). */
  1431. rec = 1.f / xj;
  1432. csscal_(n, &rec, &x[1], &c__1);
  1433. *scale *= rec;
  1434. xmax *= rec;
  1435. }
  1436. }
  1437. i__3 = j;
  1438. cladiv_(&q__1, &x[j], &tjjs);
  1439. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1440. } else if (tjj > 0.f) {
  1441. /* 0 < abs(A(j,j)) <= SMLNUM: */
  1442. if (xj > tjj * bignum) {
  1443. /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
  1444. rec = tjj * bignum / xj;
  1445. csscal_(n, &rec, &x[1], &c__1);
  1446. *scale *= rec;
  1447. xmax *= rec;
  1448. }
  1449. i__3 = j;
  1450. cladiv_(&q__1, &x[j], &tjjs);
  1451. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1452. } else {
  1453. /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
  1454. /* scale = 0 and compute a solution to A**H *x = 0. */
  1455. i__3 = *n;
  1456. for (i__ = 1; i__ <= i__3; ++i__) {
  1457. i__4 = i__;
  1458. x[i__4].r = 0.f, x[i__4].i = 0.f;
  1459. /* L180: */
  1460. }
  1461. i__3 = j;
  1462. x[i__3].r = 1.f, x[i__3].i = 0.f;
  1463. *scale = 0.f;
  1464. xmax = 0.f;
  1465. }
  1466. L185:
  1467. ;
  1468. } else {
  1469. /* Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
  1470. /* product has already been divided by 1/A(j,j). */
  1471. i__3 = j;
  1472. cladiv_(&q__2, &x[j], &tjjs);
  1473. q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
  1474. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1475. }
  1476. /* Computing MAX */
  1477. i__3 = j;
  1478. r__3 = xmax, r__4 = (r__1 = x[i__3].r, abs(r__1)) + (r__2 =
  1479. r_imag(&x[j]), abs(r__2));
  1480. xmax = f2cmax(r__3,r__4);
  1481. ++jlen;
  1482. ip += jinc * jlen;
  1483. /* L190: */
  1484. }
  1485. }
  1486. *scale /= tscal;
  1487. }
  1488. /* Scale the column norms by 1/TSCAL for return. */
  1489. if (tscal != 1.f) {
  1490. r__1 = 1.f / tscal;
  1491. sscal_(n, &r__1, &cnorm[1], &c__1);
  1492. }
  1493. return;
  1494. /* End of CLATPS */
  1495. } /* clatps_ */