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.

clatbs.c 48 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758
  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 CLATBS solves a triangular banded system of equations. */
  487. /* =========== DOCUMENTATION =========== */
  488. /* Online html documentation available at */
  489. /* http://www.netlib.org/lapack/explore-html/ */
  490. /* > \htmlonly */
  491. /* > Download CLATBS + dependencies */
  492. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clatbs.
  493. f"> */
  494. /* > [TGZ]</a> */
  495. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clatbs.
  496. f"> */
  497. /* > [ZIP]</a> */
  498. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clatbs.
  499. f"> */
  500. /* > [TXT]</a> */
  501. /* > \endhtmlonly */
  502. /* Definition: */
  503. /* =========== */
  504. /* SUBROUTINE CLATBS( UPLO, TRANS, DIAG, NORMIN, N, KD, AB, LDAB, X, */
  505. /* SCALE, CNORM, INFO ) */
  506. /* CHARACTER DIAG, NORMIN, TRANS, UPLO */
  507. /* INTEGER INFO, KD, LDAB, N */
  508. /* REAL SCALE */
  509. /* REAL CNORM( * ) */
  510. /* COMPLEX AB( LDAB, * ), X( * ) */
  511. /* > \par Purpose: */
  512. /* ============= */
  513. /* > */
  514. /* > \verbatim */
  515. /* > */
  516. /* > CLATBS 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 band matrix. Here A**T denotes the transpose of A, x and b */
  522. /* > are n-element vectors, and s is a scaling factor, usually less than */
  523. /* > or equal to 1, chosen so that the components of x will be less than */
  524. /* > the overflow threshold. If the unscaled problem will not cause */
  525. /* > overflow, the Level 2 BLAS routine CTBSV is called. If the matrix A */
  526. /* > is singular (A(j,j) = 0 for some j), then s is set to 0 and a */
  527. /* > non-trivial solution to A*x = 0 is returned. */
  528. /* > \endverbatim */
  529. /* Arguments: */
  530. /* ========== */
  531. /* > \param[in] UPLO */
  532. /* > \verbatim */
  533. /* > UPLO is CHARACTER*1 */
  534. /* > Specifies whether the matrix A is upper or lower triangular. */
  535. /* > = 'U': Upper triangular */
  536. /* > = 'L': Lower triangular */
  537. /* > \endverbatim */
  538. /* > */
  539. /* > \param[in] TRANS */
  540. /* > \verbatim */
  541. /* > TRANS is CHARACTER*1 */
  542. /* > Specifies the operation applied to A. */
  543. /* > = 'N': Solve A * x = s*b (No transpose) */
  544. /* > = 'T': Solve A**T * x = s*b (Transpose) */
  545. /* > = 'C': Solve A**H * x = s*b (Conjugate transpose) */
  546. /* > \endverbatim */
  547. /* > */
  548. /* > \param[in] DIAG */
  549. /* > \verbatim */
  550. /* > DIAG is CHARACTER*1 */
  551. /* > Specifies whether or not the matrix A is unit triangular. */
  552. /* > = 'N': Non-unit triangular */
  553. /* > = 'U': Unit triangular */
  554. /* > \endverbatim */
  555. /* > */
  556. /* > \param[in] NORMIN */
  557. /* > \verbatim */
  558. /* > NORMIN is CHARACTER*1 */
  559. /* > Specifies whether CNORM has been set or not. */
  560. /* > = 'Y': CNORM contains the column norms on entry */
  561. /* > = 'N': CNORM is not set on entry. On exit, the norms will */
  562. /* > be computed and stored in CNORM. */
  563. /* > \endverbatim */
  564. /* > */
  565. /* > \param[in] N */
  566. /* > \verbatim */
  567. /* > N is INTEGER */
  568. /* > The order of the matrix A. N >= 0. */
  569. /* > \endverbatim */
  570. /* > */
  571. /* > \param[in] KD */
  572. /* > \verbatim */
  573. /* > KD is INTEGER */
  574. /* > The number of subdiagonals or superdiagonals in the */
  575. /* > triangular matrix A. KD >= 0. */
  576. /* > \endverbatim */
  577. /* > */
  578. /* > \param[in] AB */
  579. /* > \verbatim */
  580. /* > AB is COMPLEX array, dimension (LDAB,N) */
  581. /* > The upper or lower triangular band matrix A, stored in the */
  582. /* > first KD+1 rows of the array. The j-th column of A is stored */
  583. /* > in the j-th column of the array AB as follows: */
  584. /* > if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for f2cmax(1,j-kd)<=i<=j; */
  585. /* > if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=f2cmin(n,j+kd). */
  586. /* > \endverbatim */
  587. /* > */
  588. /* > \param[in] LDAB */
  589. /* > \verbatim */
  590. /* > LDAB is INTEGER */
  591. /* > The leading dimension of the array AB. LDAB >= KD+1. */
  592. /* > \endverbatim */
  593. /* > */
  594. /* > \param[in,out] X */
  595. /* > \verbatim */
  596. /* > X is COMPLEX array, dimension (N) */
  597. /* > On entry, the right hand side b of the triangular system. */
  598. /* > On exit, X is overwritten by the solution vector x. */
  599. /* > \endverbatim */
  600. /* > */
  601. /* > \param[out] SCALE */
  602. /* > \verbatim */
  603. /* > SCALE is REAL */
  604. /* > The scaling factor s for the triangular system */
  605. /* > A * x = s*b, A**T * x = s*b, or A**H * x = s*b. */
  606. /* > If SCALE = 0, the matrix A is singular or badly scaled, and */
  607. /* > the vector x is an exact or approximate solution to A*x = 0. */
  608. /* > \endverbatim */
  609. /* > */
  610. /* > \param[in,out] CNORM */
  611. /* > \verbatim */
  612. /* > CNORM is REAL array, dimension (N) */
  613. /* > */
  614. /* > If NORMIN = 'Y', CNORM is an input argument and CNORM(j) */
  615. /* > contains the norm of the off-diagonal part of the j-th column */
  616. /* > of A. If TRANS = 'N', CNORM(j) must be greater than or equal */
  617. /* > to the infinity-norm, and if TRANS = 'T' or 'C', CNORM(j) */
  618. /* > must be greater than or equal to the 1-norm. */
  619. /* > */
  620. /* > If NORMIN = 'N', CNORM is an output argument and CNORM(j) */
  621. /* > returns the 1-norm of the offdiagonal part of the j-th column */
  622. /* > of A. */
  623. /* > \endverbatim */
  624. /* > */
  625. /* > \param[out] INFO */
  626. /* > \verbatim */
  627. /* > INFO is INTEGER */
  628. /* > = 0: successful exit */
  629. /* > < 0: if INFO = -k, the k-th argument had an illegal value */
  630. /* > \endverbatim */
  631. /* Authors: */
  632. /* ======== */
  633. /* > \author Univ. of Tennessee */
  634. /* > \author Univ. of California Berkeley */
  635. /* > \author Univ. of Colorado Denver */
  636. /* > \author NAG Ltd. */
  637. /* > \date December 2016 */
  638. /* > \ingroup complexOTHERauxiliary */
  639. /* > \par Further Details: */
  640. /* ===================== */
  641. /* > */
  642. /* > \verbatim */
  643. /* > */
  644. /* > A rough bound on x is computed; if that is less than overflow, CTBSV */
  645. /* > is called, otherwise, specific code is used which checks for possible */
  646. /* > overflow or divide-by-zero at every operation. */
  647. /* > */
  648. /* > A columnwise scheme is used for solving A*x = b. The basic algorithm */
  649. /* > if A is lower triangular is */
  650. /* > */
  651. /* > x[1:n] := b[1:n] */
  652. /* > for j = 1, ..., n */
  653. /* > x(j) := x(j) / A(j,j) */
  654. /* > x[j+1:n] := x[j+1:n] - x(j) * A[j+1:n,j] */
  655. /* > end */
  656. /* > */
  657. /* > Define bounds on the components of x after j iterations of the loop: */
  658. /* > M(j) = bound on x[1:j] */
  659. /* > G(j) = bound on x[j+1:n] */
  660. /* > Initially, let M(0) = 0 and G(0) = f2cmax{x(i), i=1,...,n}. */
  661. /* > */
  662. /* > Then for iteration j+1 we have */
  663. /* > M(j+1) <= G(j) / | A(j+1,j+1) | */
  664. /* > G(j+1) <= G(j) + M(j+1) * | A[j+2:n,j+1] | */
  665. /* > <= G(j) ( 1 + CNORM(j+1) / | A(j+1,j+1) | ) */
  666. /* > */
  667. /* > where CNORM(j+1) is greater than or equal to the infinity-norm of */
  668. /* > column j+1 of A, not counting the diagonal. Hence */
  669. /* > */
  670. /* > G(j) <= G(0) product ( 1 + CNORM(i) / | A(i,i) | ) */
  671. /* > 1<=i<=j */
  672. /* > and */
  673. /* > */
  674. /* > |x(j)| <= ( G(0) / |A(j,j)| ) product ( 1 + CNORM(i) / |A(i,i)| ) */
  675. /* > 1<=i< j */
  676. /* > */
  677. /* > Since |x(j)| <= M(j), we use the Level 2 BLAS routine CTBSV if the */
  678. /* > reciprocal of the largest M(j), j=1,..,n, is larger than */
  679. /* > f2cmax(underflow, 1/overflow). */
  680. /* > */
  681. /* > The bound on x(j) is also used to determine when a step in the */
  682. /* > columnwise method can be performed without fear of overflow. If */
  683. /* > the computed bound is greater than a large constant, x is scaled to */
  684. /* > prevent overflow, but if the bound overflows, x is set to 0, x(j) to */
  685. /* > 1, and scale to 0, and a non-trivial solution to A*x = 0 is found. */
  686. /* > */
  687. /* > Similarly, a row-wise scheme is used to solve A**T *x = b or */
  688. /* > A**H *x = b. The basic algorithm for A upper triangular is */
  689. /* > */
  690. /* > for j = 1, ..., n */
  691. /* > x(j) := ( b(j) - A[1:j-1,j]' * x[1:j-1] ) / A(j,j) */
  692. /* > end */
  693. /* > */
  694. /* > We simultaneously compute two bounds */
  695. /* > G(j) = bound on ( b(i) - A[1:i-1,i]' * x[1:i-1] ), 1<=i<=j */
  696. /* > M(j) = bound on x(i), 1<=i<=j */
  697. /* > */
  698. /* > The initial values are G(0) = 0, M(0) = f2cmax{b(i), i=1,..,n}, and we */
  699. /* > add the constraint G(j) >= G(j-1) and M(j) >= M(j-1) for j >= 1. */
  700. /* > Then the bound on x(j) is */
  701. /* > */
  702. /* > M(j) <= M(j-1) * ( 1 + CNORM(j) ) / | A(j,j) | */
  703. /* > */
  704. /* > <= M(0) * product ( ( 1 + CNORM(i) ) / |A(i,i)| ) */
  705. /* > 1<=i<=j */
  706. /* > */
  707. /* > and we can safely call CTBSV if 1/M(n) and 1/G(n) are both greater */
  708. /* > than f2cmax(underflow, 1/overflow). */
  709. /* > \endverbatim */
  710. /* > */
  711. /* ===================================================================== */
  712. /* Subroutine */ void clatbs_(char *uplo, char *trans, char *diag, char *
  713. normin, integer *n, integer *kd, complex *ab, integer *ldab, complex *
  714. x, real *scale, real *cnorm, integer *info)
  715. {
  716. /* System generated locals */
  717. integer ab_dim1, ab_offset, i__1, i__2, i__3, i__4, i__5;
  718. real r__1, r__2, r__3, r__4;
  719. complex q__1, q__2, q__3, q__4;
  720. /* Local variables */
  721. integer jinc, jlen;
  722. real xbnd;
  723. integer imax;
  724. real tmax;
  725. complex tjjs;
  726. real xmax, grow;
  727. integer i__, j, maind;
  728. extern /* Complex */ VOID cdotc_(complex *, integer *, complex *, integer
  729. *, complex *, integer *);
  730. extern logical lsame_(char *, char *);
  731. extern /* Subroutine */ void sscal_(integer *, real *, real *, integer *);
  732. real tscal;
  733. complex uscal;
  734. integer jlast;
  735. extern /* Complex */ VOID cdotu_(complex *, integer *, complex *, integer
  736. *, complex *, integer *);
  737. complex csumj;
  738. extern /* Subroutine */ void ctbsv_(char *, char *, char *, integer *,
  739. integer *, complex *, integer *, complex *, integer *), caxpy_(integer *, complex *, complex *, integer *
  740. , complex *, integer *);
  741. logical upper;
  742. extern /* Subroutine */ void slabad_(real *, real *);
  743. real xj;
  744. extern integer icamax_(integer *, complex *, integer *);
  745. extern /* Complex */ VOID cladiv_(complex *, complex *, complex *);
  746. extern real slamch_(char *);
  747. extern /* Subroutine */ void csscal_(integer *, real *, complex *, integer
  748. *);
  749. extern int xerbla_(char *, integer *, ftnlen);
  750. real bignum;
  751. extern integer isamax_(integer *, real *, integer *);
  752. extern real scasum_(integer *, complex *, integer *);
  753. logical notran;
  754. integer jfirst;
  755. real smlnum;
  756. logical nounit;
  757. real rec, tjj;
  758. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  759. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  760. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  761. /* December 2016 */
  762. /* ===================================================================== */
  763. /* Parameter adjustments */
  764. ab_dim1 = *ldab;
  765. ab_offset = 1 + ab_dim1 * 1;
  766. ab -= ab_offset;
  767. --x;
  768. --cnorm;
  769. /* Function Body */
  770. *info = 0;
  771. upper = lsame_(uplo, "U");
  772. notran = lsame_(trans, "N");
  773. nounit = lsame_(diag, "N");
  774. /* Test the input parameters. */
  775. if (! upper && ! lsame_(uplo, "L")) {
  776. *info = -1;
  777. } else if (! notran && ! lsame_(trans, "T") && !
  778. lsame_(trans, "C")) {
  779. *info = -2;
  780. } else if (! nounit && ! lsame_(diag, "U")) {
  781. *info = -3;
  782. } else if (! lsame_(normin, "Y") && ! lsame_(normin,
  783. "N")) {
  784. *info = -4;
  785. } else if (*n < 0) {
  786. *info = -5;
  787. } else if (*kd < 0) {
  788. *info = -6;
  789. } else if (*ldab < *kd + 1) {
  790. *info = -8;
  791. }
  792. if (*info != 0) {
  793. i__1 = -(*info);
  794. xerbla_("CLATBS", &i__1, (ftnlen)6);
  795. return;
  796. }
  797. /* Quick return if possible */
  798. if (*n == 0) {
  799. return;
  800. }
  801. /* Determine machine dependent parameters to control overflow. */
  802. smlnum = slamch_("Safe minimum");
  803. bignum = 1.f / smlnum;
  804. slabad_(&smlnum, &bignum);
  805. smlnum /= slamch_("Precision");
  806. bignum = 1.f / smlnum;
  807. *scale = 1.f;
  808. if (lsame_(normin, "N")) {
  809. /* Compute the 1-norm of each column, not including the diagonal. */
  810. if (upper) {
  811. /* A is upper triangular. */
  812. i__1 = *n;
  813. for (j = 1; j <= i__1; ++j) {
  814. /* Computing MIN */
  815. i__2 = *kd, i__3 = j - 1;
  816. jlen = f2cmin(i__2,i__3);
  817. cnorm[j] = scasum_(&jlen, &ab[*kd + 1 - jlen + j * ab_dim1], &
  818. c__1);
  819. /* L10: */
  820. }
  821. } else {
  822. /* A is lower triangular. */
  823. i__1 = *n;
  824. for (j = 1; j <= i__1; ++j) {
  825. /* Computing MIN */
  826. i__2 = *kd, i__3 = *n - j;
  827. jlen = f2cmin(i__2,i__3);
  828. if (jlen > 0) {
  829. cnorm[j] = scasum_(&jlen, &ab[j * ab_dim1 + 2], &c__1);
  830. } else {
  831. cnorm[j] = 0.f;
  832. }
  833. /* L20: */
  834. }
  835. }
  836. }
  837. /* Scale the column norms by TSCAL if the maximum element in CNORM is */
  838. /* greater than BIGNUM/2. */
  839. imax = isamax_(n, &cnorm[1], &c__1);
  840. tmax = cnorm[imax];
  841. if (tmax <= bignum * .5f) {
  842. tscal = 1.f;
  843. } else {
  844. tscal = .5f / (smlnum * tmax);
  845. sscal_(n, &tscal, &cnorm[1], &c__1);
  846. }
  847. /* Compute a bound on the computed solution vector to see if the */
  848. /* Level 2 BLAS routine CTBSV can be used. */
  849. xmax = 0.f;
  850. i__1 = *n;
  851. for (j = 1; j <= i__1; ++j) {
  852. /* Computing MAX */
  853. i__2 = j;
  854. r__3 = xmax, r__4 = (r__1 = x[i__2].r / 2.f, abs(r__1)) + (r__2 =
  855. r_imag(&x[j]) / 2.f, abs(r__2));
  856. xmax = f2cmax(r__3,r__4);
  857. /* L30: */
  858. }
  859. xbnd = xmax;
  860. if (notran) {
  861. /* Compute the growth in A * x = b. */
  862. if (upper) {
  863. jfirst = *n;
  864. jlast = 1;
  865. jinc = -1;
  866. maind = *kd + 1;
  867. } else {
  868. jfirst = 1;
  869. jlast = *n;
  870. jinc = 1;
  871. maind = 1;
  872. }
  873. if (tscal != 1.f) {
  874. grow = 0.f;
  875. goto L60;
  876. }
  877. if (nounit) {
  878. /* A is non-unit triangular. */
  879. /* Compute GROW = 1/G(j) and XBND = 1/M(j). */
  880. /* Initially, G(0) = f2cmax{x(i), i=1,...,n}. */
  881. grow = .5f / f2cmax(xbnd,smlnum);
  882. xbnd = grow;
  883. i__1 = jlast;
  884. i__2 = jinc;
  885. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  886. /* Exit the loop if the growth factor is too small. */
  887. if (grow <= smlnum) {
  888. goto L60;
  889. }
  890. i__3 = maind + j * ab_dim1;
  891. tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
  892. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
  893. r__2));
  894. if (tjj >= smlnum) {
  895. /* M(j) = G(j-1) / abs(A(j,j)) */
  896. /* Computing MIN */
  897. r__1 = xbnd, r__2 = f2cmin(1.f,tjj) * grow;
  898. xbnd = f2cmin(r__1,r__2);
  899. } else {
  900. /* M(j) could overflow, set XBND to 0. */
  901. xbnd = 0.f;
  902. }
  903. if (tjj + cnorm[j] >= smlnum) {
  904. /* G(j) = G(j-1)*( 1 + CNORM(j) / abs(A(j,j)) ) */
  905. grow *= tjj / (tjj + cnorm[j]);
  906. } else {
  907. /* G(j) could overflow, set GROW to 0. */
  908. grow = 0.f;
  909. }
  910. /* L40: */
  911. }
  912. grow = xbnd;
  913. } else {
  914. /* A is unit triangular. */
  915. /* Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
  916. /* Computing MIN */
  917. r__1 = 1.f, r__2 = .5f / f2cmax(xbnd,smlnum);
  918. grow = f2cmin(r__1,r__2);
  919. i__2 = jlast;
  920. i__1 = jinc;
  921. for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  922. /* Exit the loop if the growth factor is too small. */
  923. if (grow <= smlnum) {
  924. goto L60;
  925. }
  926. /* G(j) = G(j-1)*( 1 + CNORM(j) ) */
  927. grow *= 1.f / (cnorm[j] + 1.f);
  928. /* L50: */
  929. }
  930. }
  931. L60:
  932. ;
  933. } else {
  934. /* Compute the growth in A**T * x = b or A**H * x = b. */
  935. if (upper) {
  936. jfirst = 1;
  937. jlast = *n;
  938. jinc = 1;
  939. maind = *kd + 1;
  940. } else {
  941. jfirst = *n;
  942. jlast = 1;
  943. jinc = -1;
  944. maind = 1;
  945. }
  946. if (tscal != 1.f) {
  947. grow = 0.f;
  948. goto L90;
  949. }
  950. if (nounit) {
  951. /* A is non-unit triangular. */
  952. /* Compute GROW = 1/G(j) and XBND = 1/M(j). */
  953. /* Initially, M(0) = f2cmax{x(i), i=1,...,n}. */
  954. grow = .5f / f2cmax(xbnd,smlnum);
  955. xbnd = grow;
  956. i__1 = jlast;
  957. i__2 = jinc;
  958. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  959. /* Exit the loop if the growth factor is too small. */
  960. if (grow <= smlnum) {
  961. goto L90;
  962. }
  963. /* G(j) = f2cmax( G(j-1), M(j-1)*( 1 + CNORM(j) ) ) */
  964. xj = cnorm[j] + 1.f;
  965. /* Computing MIN */
  966. r__1 = grow, r__2 = xbnd / xj;
  967. grow = f2cmin(r__1,r__2);
  968. i__3 = maind + j * ab_dim1;
  969. tjjs.r = ab[i__3].r, tjjs.i = ab[i__3].i;
  970. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
  971. r__2));
  972. if (tjj >= smlnum) {
  973. /* M(j) = M(j-1)*( 1 + CNORM(j) ) / abs(A(j,j)) */
  974. if (xj > tjj) {
  975. xbnd *= tjj / xj;
  976. }
  977. } else {
  978. /* M(j) could overflow, set XBND to 0. */
  979. xbnd = 0.f;
  980. }
  981. /* L70: */
  982. }
  983. grow = f2cmin(grow,xbnd);
  984. } else {
  985. /* A is unit triangular. */
  986. /* Compute GROW = 1/G(j), where G(0) = f2cmax{x(i), i=1,...,n}. */
  987. /* Computing MIN */
  988. r__1 = 1.f, r__2 = .5f / f2cmax(xbnd,smlnum);
  989. grow = f2cmin(r__1,r__2);
  990. i__2 = jlast;
  991. i__1 = jinc;
  992. for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  993. /* Exit the loop if the growth factor is too small. */
  994. if (grow <= smlnum) {
  995. goto L90;
  996. }
  997. /* G(j) = ( 1 + CNORM(j) )*G(j-1) */
  998. xj = cnorm[j] + 1.f;
  999. grow /= xj;
  1000. /* L80: */
  1001. }
  1002. }
  1003. L90:
  1004. ;
  1005. }
  1006. if (grow * tscal > smlnum) {
  1007. /* Use the Level 2 BLAS solve if the reciprocal of the bound on */
  1008. /* elements of X is not too small. */
  1009. ctbsv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &x[1], &c__1);
  1010. } else {
  1011. /* Use a Level 1 BLAS solve, scaling intermediate results. */
  1012. if (xmax > bignum * .5f) {
  1013. /* Scale X so that its components are less than or equal to */
  1014. /* BIGNUM in absolute value. */
  1015. *scale = bignum * .5f / xmax;
  1016. csscal_(n, scale, &x[1], &c__1);
  1017. xmax = bignum;
  1018. } else {
  1019. xmax *= 2.f;
  1020. }
  1021. if (notran) {
  1022. /* Solve A * x = b */
  1023. i__1 = jlast;
  1024. i__2 = jinc;
  1025. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  1026. /* Compute x(j) = b(j) / A(j,j), scaling x if necessary. */
  1027. i__3 = j;
  1028. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
  1029. abs(r__2));
  1030. if (nounit) {
  1031. i__3 = maind + j * ab_dim1;
  1032. q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3].i;
  1033. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1034. } else {
  1035. tjjs.r = tscal, tjjs.i = 0.f;
  1036. if (tscal == 1.f) {
  1037. goto L105;
  1038. }
  1039. }
  1040. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs), abs(
  1041. r__2));
  1042. if (tjj > smlnum) {
  1043. /* abs(A(j,j)) > SMLNUM: */
  1044. if (tjj < 1.f) {
  1045. if (xj > tjj * bignum) {
  1046. /* Scale x by 1/b(j). */
  1047. rec = 1.f / xj;
  1048. csscal_(n, &rec, &x[1], &c__1);
  1049. *scale *= rec;
  1050. xmax *= rec;
  1051. }
  1052. }
  1053. i__3 = j;
  1054. cladiv_(&q__1, &x[j], &tjjs);
  1055. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1056. i__3 = j;
  1057. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1058. , abs(r__2));
  1059. } else if (tjj > 0.f) {
  1060. /* 0 < abs(A(j,j)) <= SMLNUM: */
  1061. if (xj > tjj * bignum) {
  1062. /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM */
  1063. /* to avoid overflow when dividing by A(j,j). */
  1064. rec = tjj * bignum / xj;
  1065. if (cnorm[j] > 1.f) {
  1066. /* Scale by 1/CNORM(j) to avoid overflow when */
  1067. /* multiplying x(j) times column j. */
  1068. rec /= cnorm[j];
  1069. }
  1070. csscal_(n, &rec, &x[1], &c__1);
  1071. *scale *= rec;
  1072. xmax *= rec;
  1073. }
  1074. i__3 = j;
  1075. cladiv_(&q__1, &x[j], &tjjs);
  1076. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1077. i__3 = j;
  1078. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1079. , abs(r__2));
  1080. } else {
  1081. /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
  1082. /* scale = 0, and compute a solution to A*x = 0. */
  1083. i__3 = *n;
  1084. for (i__ = 1; i__ <= i__3; ++i__) {
  1085. i__4 = i__;
  1086. x[i__4].r = 0.f, x[i__4].i = 0.f;
  1087. /* L100: */
  1088. }
  1089. i__3 = j;
  1090. x[i__3].r = 1.f, x[i__3].i = 0.f;
  1091. xj = 1.f;
  1092. *scale = 0.f;
  1093. xmax = 0.f;
  1094. }
  1095. L105:
  1096. /* Scale x if necessary to avoid overflow when adding a */
  1097. /* multiple of column j of A. */
  1098. if (xj > 1.f) {
  1099. rec = 1.f / xj;
  1100. if (cnorm[j] > (bignum - xmax) * rec) {
  1101. /* Scale x by 1/(2*abs(x(j))). */
  1102. rec *= .5f;
  1103. csscal_(n, &rec, &x[1], &c__1);
  1104. *scale *= rec;
  1105. }
  1106. } else if (xj * cnorm[j] > bignum - xmax) {
  1107. /* Scale x by 1/2. */
  1108. csscal_(n, &c_b36, &x[1], &c__1);
  1109. *scale *= .5f;
  1110. }
  1111. if (upper) {
  1112. if (j > 1) {
  1113. /* Compute the update */
  1114. /* x(f2cmax(1,j-kd):j-1) := x(f2cmax(1,j-kd):j-1) - */
  1115. /* x(j)* A(f2cmax(1,j-kd):j-1,j) */
  1116. /* Computing MIN */
  1117. i__3 = *kd, i__4 = j - 1;
  1118. jlen = f2cmin(i__3,i__4);
  1119. i__3 = j;
  1120. q__2.r = -x[i__3].r, q__2.i = -x[i__3].i;
  1121. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1122. caxpy_(&jlen, &q__1, &ab[*kd + 1 - jlen + j * ab_dim1]
  1123. , &c__1, &x[j - jlen], &c__1);
  1124. i__3 = j - 1;
  1125. i__ = icamax_(&i__3, &x[1], &c__1);
  1126. i__3 = i__;
  1127. xmax = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(
  1128. &x[i__]), abs(r__2));
  1129. }
  1130. } else if (j < *n) {
  1131. /* Compute the update */
  1132. /* x(j+1:f2cmin(j+kd,n)) := x(j+1:f2cmin(j+kd,n)) - */
  1133. /* x(j) * A(j+1:f2cmin(j+kd,n),j) */
  1134. /* Computing MIN */
  1135. i__3 = *kd, i__4 = *n - j;
  1136. jlen = f2cmin(i__3,i__4);
  1137. if (jlen > 0) {
  1138. i__3 = j;
  1139. q__2.r = -x[i__3].r, q__2.i = -x[i__3].i;
  1140. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1141. caxpy_(&jlen, &q__1, &ab[j * ab_dim1 + 2], &c__1, &x[
  1142. j + 1], &c__1);
  1143. }
  1144. i__3 = *n - j;
  1145. i__ = j + icamax_(&i__3, &x[j + 1], &c__1);
  1146. i__3 = i__;
  1147. xmax = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[
  1148. i__]), abs(r__2));
  1149. }
  1150. /* L110: */
  1151. }
  1152. } else if (lsame_(trans, "T")) {
  1153. /* Solve A**T * x = b */
  1154. i__2 = jlast;
  1155. i__1 = jinc;
  1156. for (j = jfirst; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  1157. /* Compute x(j) = b(j) - sum A(k,j)*x(k). */
  1158. /* k<>j */
  1159. i__3 = j;
  1160. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
  1161. abs(r__2));
  1162. uscal.r = tscal, uscal.i = 0.f;
  1163. rec = 1.f / f2cmax(xmax,1.f);
  1164. if (cnorm[j] > (bignum - xj) * rec) {
  1165. /* If x(j) could overflow, scale x by 1/(2*XMAX). */
  1166. rec *= .5f;
  1167. if (nounit) {
  1168. i__3 = maind + j * ab_dim1;
  1169. q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3]
  1170. .i;
  1171. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1172. } else {
  1173. tjjs.r = tscal, tjjs.i = 0.f;
  1174. }
  1175. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1176. abs(r__2));
  1177. if (tjj > 1.f) {
  1178. /* Divide by A(j,j) when scaling x if A(j,j) > 1. */
  1179. /* Computing MIN */
  1180. r__1 = 1.f, r__2 = rec * tjj;
  1181. rec = f2cmin(r__1,r__2);
  1182. cladiv_(&q__1, &uscal, &tjjs);
  1183. uscal.r = q__1.r, uscal.i = q__1.i;
  1184. }
  1185. if (rec < 1.f) {
  1186. csscal_(n, &rec, &x[1], &c__1);
  1187. *scale *= rec;
  1188. xmax *= rec;
  1189. }
  1190. }
  1191. csumj.r = 0.f, csumj.i = 0.f;
  1192. if (uscal.r == 1.f && uscal.i == 0.f) {
  1193. /* If the scaling needed for A in the dot product is 1, */
  1194. /* call CDOTU to perform the dot product. */
  1195. if (upper) {
  1196. /* Computing MIN */
  1197. i__3 = *kd, i__4 = j - 1;
  1198. jlen = f2cmin(i__3,i__4);
  1199. cdotu_(&q__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
  1200. , &c__1, &x[j - jlen], &c__1);
  1201. csumj.r = q__1.r, csumj.i = q__1.i;
  1202. } else {
  1203. /* Computing MIN */
  1204. i__3 = *kd, i__4 = *n - j;
  1205. jlen = f2cmin(i__3,i__4);
  1206. if (jlen > 1) {
  1207. cdotu_(&q__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
  1208. &x[j + 1], &c__1);
  1209. csumj.r = q__1.r, csumj.i = q__1.i;
  1210. }
  1211. }
  1212. } else {
  1213. /* Otherwise, use in-line code for the dot product. */
  1214. if (upper) {
  1215. /* Computing MIN */
  1216. i__3 = *kd, i__4 = j - 1;
  1217. jlen = f2cmin(i__3,i__4);
  1218. i__3 = jlen;
  1219. for (i__ = 1; i__ <= i__3; ++i__) {
  1220. i__4 = *kd + i__ - jlen + j * ab_dim1;
  1221. q__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
  1222. uscal.i, q__3.i = ab[i__4].r * uscal.i +
  1223. ab[i__4].i * uscal.r;
  1224. i__5 = j - jlen - 1 + i__;
  1225. q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
  1226. q__2.i = q__3.r * x[i__5].i + q__3.i * x[
  1227. i__5].r;
  1228. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1229. q__2.i;
  1230. csumj.r = q__1.r, csumj.i = q__1.i;
  1231. /* L120: */
  1232. }
  1233. } else {
  1234. /* Computing MIN */
  1235. i__3 = *kd, i__4 = *n - j;
  1236. jlen = f2cmin(i__3,i__4);
  1237. i__3 = jlen;
  1238. for (i__ = 1; i__ <= i__3; ++i__) {
  1239. i__4 = i__ + 1 + j * ab_dim1;
  1240. q__3.r = ab[i__4].r * uscal.r - ab[i__4].i *
  1241. uscal.i, q__3.i = ab[i__4].r * uscal.i +
  1242. ab[i__4].i * uscal.r;
  1243. i__5 = j + i__;
  1244. q__2.r = q__3.r * x[i__5].r - q__3.i * x[i__5].i,
  1245. q__2.i = q__3.r * x[i__5].i + q__3.i * x[
  1246. i__5].r;
  1247. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1248. q__2.i;
  1249. csumj.r = q__1.r, csumj.i = q__1.i;
  1250. /* L130: */
  1251. }
  1252. }
  1253. }
  1254. q__1.r = tscal, q__1.i = 0.f;
  1255. if (uscal.r == q__1.r && uscal.i == q__1.i) {
  1256. /* Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
  1257. /* was not used to scale the dotproduct. */
  1258. i__3 = j;
  1259. i__4 = j;
  1260. q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
  1261. csumj.i;
  1262. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1263. i__3 = j;
  1264. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1265. , abs(r__2));
  1266. if (nounit) {
  1267. /* Compute x(j) = x(j) / A(j,j), scaling if necessary. */
  1268. i__3 = maind + j * ab_dim1;
  1269. q__1.r = tscal * ab[i__3].r, q__1.i = tscal * ab[i__3]
  1270. .i;
  1271. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1272. } else {
  1273. tjjs.r = tscal, tjjs.i = 0.f;
  1274. if (tscal == 1.f) {
  1275. goto L145;
  1276. }
  1277. }
  1278. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1279. abs(r__2));
  1280. if (tjj > smlnum) {
  1281. /* abs(A(j,j)) > SMLNUM: */
  1282. if (tjj < 1.f) {
  1283. if (xj > tjj * bignum) {
  1284. /* Scale X by 1/abs(x(j)). */
  1285. rec = 1.f / xj;
  1286. csscal_(n, &rec, &x[1], &c__1);
  1287. *scale *= rec;
  1288. xmax *= rec;
  1289. }
  1290. }
  1291. i__3 = j;
  1292. cladiv_(&q__1, &x[j], &tjjs);
  1293. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1294. } else if (tjj > 0.f) {
  1295. /* 0 < abs(A(j,j)) <= SMLNUM: */
  1296. if (xj > tjj * bignum) {
  1297. /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
  1298. rec = tjj * bignum / xj;
  1299. csscal_(n, &rec, &x[1], &c__1);
  1300. *scale *= rec;
  1301. xmax *= rec;
  1302. }
  1303. i__3 = j;
  1304. cladiv_(&q__1, &x[j], &tjjs);
  1305. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1306. } else {
  1307. /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
  1308. /* scale = 0 and compute a solution to A**T *x = 0. */
  1309. i__3 = *n;
  1310. for (i__ = 1; i__ <= i__3; ++i__) {
  1311. i__4 = i__;
  1312. x[i__4].r = 0.f, x[i__4].i = 0.f;
  1313. /* L140: */
  1314. }
  1315. i__3 = j;
  1316. x[i__3].r = 1.f, x[i__3].i = 0.f;
  1317. *scale = 0.f;
  1318. xmax = 0.f;
  1319. }
  1320. L145:
  1321. ;
  1322. } else {
  1323. /* Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
  1324. /* product has already been divided by 1/A(j,j). */
  1325. i__3 = j;
  1326. cladiv_(&q__2, &x[j], &tjjs);
  1327. q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
  1328. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1329. }
  1330. /* Computing MAX */
  1331. i__3 = j;
  1332. r__3 = xmax, r__4 = (r__1 = x[i__3].r, abs(r__1)) + (r__2 =
  1333. r_imag(&x[j]), abs(r__2));
  1334. xmax = f2cmax(r__3,r__4);
  1335. /* L150: */
  1336. }
  1337. } else {
  1338. /* Solve A**H * x = b */
  1339. i__1 = jlast;
  1340. i__2 = jinc;
  1341. for (j = jfirst; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  1342. /* Compute x(j) = b(j) - sum A(k,j)*x(k). */
  1343. /* k<>j */
  1344. i__3 = j;
  1345. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j]),
  1346. abs(r__2));
  1347. uscal.r = tscal, uscal.i = 0.f;
  1348. rec = 1.f / f2cmax(xmax,1.f);
  1349. if (cnorm[j] > (bignum - xj) * rec) {
  1350. /* If x(j) could overflow, scale x by 1/(2*XMAX). */
  1351. rec *= .5f;
  1352. if (nounit) {
  1353. r_cnjg(&q__2, &ab[maind + j * ab_dim1]);
  1354. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1355. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1356. } else {
  1357. tjjs.r = tscal, tjjs.i = 0.f;
  1358. }
  1359. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1360. abs(r__2));
  1361. if (tjj > 1.f) {
  1362. /* Divide by A(j,j) when scaling x if A(j,j) > 1. */
  1363. /* Computing MIN */
  1364. r__1 = 1.f, r__2 = rec * tjj;
  1365. rec = f2cmin(r__1,r__2);
  1366. cladiv_(&q__1, &uscal, &tjjs);
  1367. uscal.r = q__1.r, uscal.i = q__1.i;
  1368. }
  1369. if (rec < 1.f) {
  1370. csscal_(n, &rec, &x[1], &c__1);
  1371. *scale *= rec;
  1372. xmax *= rec;
  1373. }
  1374. }
  1375. csumj.r = 0.f, csumj.i = 0.f;
  1376. if (uscal.r == 1.f && uscal.i == 0.f) {
  1377. /* If the scaling needed for A in the dot product is 1, */
  1378. /* call CDOTC to perform the dot product. */
  1379. if (upper) {
  1380. /* Computing MIN */
  1381. i__3 = *kd, i__4 = j - 1;
  1382. jlen = f2cmin(i__3,i__4);
  1383. cdotc_(&q__1, &jlen, &ab[*kd + 1 - jlen + j * ab_dim1]
  1384. , &c__1, &x[j - jlen], &c__1);
  1385. csumj.r = q__1.r, csumj.i = q__1.i;
  1386. } else {
  1387. /* Computing MIN */
  1388. i__3 = *kd, i__4 = *n - j;
  1389. jlen = f2cmin(i__3,i__4);
  1390. if (jlen > 1) {
  1391. cdotc_(&q__1, &jlen, &ab[j * ab_dim1 + 2], &c__1,
  1392. &x[j + 1], &c__1);
  1393. csumj.r = q__1.r, csumj.i = q__1.i;
  1394. }
  1395. }
  1396. } else {
  1397. /* Otherwise, use in-line code for the dot product. */
  1398. if (upper) {
  1399. /* Computing MIN */
  1400. i__3 = *kd, i__4 = j - 1;
  1401. jlen = f2cmin(i__3,i__4);
  1402. i__3 = jlen;
  1403. for (i__ = 1; i__ <= i__3; ++i__) {
  1404. r_cnjg(&q__4, &ab[*kd + i__ - jlen + j * ab_dim1])
  1405. ;
  1406. q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
  1407. q__3.i = q__4.r * uscal.i + q__4.i *
  1408. uscal.r;
  1409. i__4 = j - jlen - 1 + i__;
  1410. q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
  1411. q__2.i = q__3.r * x[i__4].i + q__3.i * x[
  1412. i__4].r;
  1413. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1414. q__2.i;
  1415. csumj.r = q__1.r, csumj.i = q__1.i;
  1416. /* L160: */
  1417. }
  1418. } else {
  1419. /* Computing MIN */
  1420. i__3 = *kd, i__4 = *n - j;
  1421. jlen = f2cmin(i__3,i__4);
  1422. i__3 = jlen;
  1423. for (i__ = 1; i__ <= i__3; ++i__) {
  1424. r_cnjg(&q__4, &ab[i__ + 1 + j * ab_dim1]);
  1425. q__3.r = q__4.r * uscal.r - q__4.i * uscal.i,
  1426. q__3.i = q__4.r * uscal.i + q__4.i *
  1427. uscal.r;
  1428. i__4 = j + i__;
  1429. q__2.r = q__3.r * x[i__4].r - q__3.i * x[i__4].i,
  1430. q__2.i = q__3.r * x[i__4].i + q__3.i * x[
  1431. i__4].r;
  1432. q__1.r = csumj.r + q__2.r, q__1.i = csumj.i +
  1433. q__2.i;
  1434. csumj.r = q__1.r, csumj.i = q__1.i;
  1435. /* L170: */
  1436. }
  1437. }
  1438. }
  1439. q__1.r = tscal, q__1.i = 0.f;
  1440. if (uscal.r == q__1.r && uscal.i == q__1.i) {
  1441. /* Compute x(j) := ( x(j) - CSUMJ ) / A(j,j) if 1/A(j,j) */
  1442. /* was not used to scale the dotproduct. */
  1443. i__3 = j;
  1444. i__4 = j;
  1445. q__1.r = x[i__4].r - csumj.r, q__1.i = x[i__4].i -
  1446. csumj.i;
  1447. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1448. i__3 = j;
  1449. xj = (r__1 = x[i__3].r, abs(r__1)) + (r__2 = r_imag(&x[j])
  1450. , abs(r__2));
  1451. if (nounit) {
  1452. /* Compute x(j) = x(j) / A(j,j), scaling if necessary. */
  1453. r_cnjg(&q__2, &ab[maind + j * ab_dim1]);
  1454. q__1.r = tscal * q__2.r, q__1.i = tscal * q__2.i;
  1455. tjjs.r = q__1.r, tjjs.i = q__1.i;
  1456. } else {
  1457. tjjs.r = tscal, tjjs.i = 0.f;
  1458. if (tscal == 1.f) {
  1459. goto L185;
  1460. }
  1461. }
  1462. tjj = (r__1 = tjjs.r, abs(r__1)) + (r__2 = r_imag(&tjjs),
  1463. abs(r__2));
  1464. if (tjj > smlnum) {
  1465. /* abs(A(j,j)) > SMLNUM: */
  1466. if (tjj < 1.f) {
  1467. if (xj > tjj * bignum) {
  1468. /* Scale X by 1/abs(x(j)). */
  1469. rec = 1.f / xj;
  1470. csscal_(n, &rec, &x[1], &c__1);
  1471. *scale *= rec;
  1472. xmax *= rec;
  1473. }
  1474. }
  1475. i__3 = j;
  1476. cladiv_(&q__1, &x[j], &tjjs);
  1477. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1478. } else if (tjj > 0.f) {
  1479. /* 0 < abs(A(j,j)) <= SMLNUM: */
  1480. if (xj > tjj * bignum) {
  1481. /* Scale x by (1/abs(x(j)))*abs(A(j,j))*BIGNUM. */
  1482. rec = tjj * bignum / xj;
  1483. csscal_(n, &rec, &x[1], &c__1);
  1484. *scale *= rec;
  1485. xmax *= rec;
  1486. }
  1487. i__3 = j;
  1488. cladiv_(&q__1, &x[j], &tjjs);
  1489. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1490. } else {
  1491. /* A(j,j) = 0: Set x(1:n) = 0, x(j) = 1, and */
  1492. /* scale = 0 and compute a solution to A**H *x = 0. */
  1493. i__3 = *n;
  1494. for (i__ = 1; i__ <= i__3; ++i__) {
  1495. i__4 = i__;
  1496. x[i__4].r = 0.f, x[i__4].i = 0.f;
  1497. /* L180: */
  1498. }
  1499. i__3 = j;
  1500. x[i__3].r = 1.f, x[i__3].i = 0.f;
  1501. *scale = 0.f;
  1502. xmax = 0.f;
  1503. }
  1504. L185:
  1505. ;
  1506. } else {
  1507. /* Compute x(j) := x(j) / A(j,j) - CSUMJ if the dot */
  1508. /* product has already been divided by 1/A(j,j). */
  1509. i__3 = j;
  1510. cladiv_(&q__2, &x[j], &tjjs);
  1511. q__1.r = q__2.r - csumj.r, q__1.i = q__2.i - csumj.i;
  1512. x[i__3].r = q__1.r, x[i__3].i = q__1.i;
  1513. }
  1514. /* Computing MAX */
  1515. i__3 = j;
  1516. r__3 = xmax, r__4 = (r__1 = x[i__3].r, abs(r__1)) + (r__2 =
  1517. r_imag(&x[j]), abs(r__2));
  1518. xmax = f2cmax(r__3,r__4);
  1519. /* L190: */
  1520. }
  1521. }
  1522. *scale /= tscal;
  1523. }
  1524. /* Scale the column norms by 1/TSCAL for return. */
  1525. if (tscal != 1.f) {
  1526. r__1 = 1.f / tscal;
  1527. sscal_(n, &r__1, &cnorm[1], &c__1);
  1528. }
  1529. return;
  1530. /* End of CLATBS */
  1531. } /* clatbs_ */