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.

ctfsm.c 42 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. #if defined(_WIN64)
  18. typedef long long BLASLONG;
  19. typedef unsigned long long BLASULONG;
  20. #else
  21. typedef long BLASLONG;
  22. typedef unsigned long BLASULONG;
  23. #endif
  24. #ifdef LAPACK_ILP64
  25. typedef BLASLONG blasint;
  26. #if defined(_WIN64)
  27. #define blasabs(x) llabs(x)
  28. #else
  29. #define blasabs(x) labs(x)
  30. #endif
  31. #else
  32. typedef int blasint;
  33. #define blasabs(x) abs(x)
  34. #endif
  35. typedef blasint integer;
  36. typedef unsigned int uinteger;
  37. typedef char *address;
  38. typedef short int shortint;
  39. typedef float real;
  40. typedef double doublereal;
  41. typedef struct { real r, i; } complex;
  42. typedef struct { doublereal r, i; } doublecomplex;
  43. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  44. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  46. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  47. #define pCf(z) (*_pCf(z))
  48. #define pCd(z) (*_pCd(z))
  49. typedef int logical;
  50. typedef short int shortlogical;
  51. typedef char logical1;
  52. typedef char integer1;
  53. #define TRUE_ (1)
  54. #define FALSE_ (0)
  55. /* Extern is for use with -E */
  56. #ifndef Extern
  57. #define Extern extern
  58. #endif
  59. /* I/O stuff */
  60. typedef int flag;
  61. typedef int ftnlen;
  62. typedef int ftnint;
  63. /*external read, write*/
  64. typedef struct
  65. { flag cierr;
  66. ftnint ciunit;
  67. flag ciend;
  68. char *cifmt;
  69. ftnint cirec;
  70. } cilist;
  71. /*internal read, write*/
  72. typedef struct
  73. { flag icierr;
  74. char *iciunit;
  75. flag iciend;
  76. char *icifmt;
  77. ftnint icirlen;
  78. ftnint icirnum;
  79. } icilist;
  80. /*open*/
  81. typedef struct
  82. { flag oerr;
  83. ftnint ounit;
  84. char *ofnm;
  85. ftnlen ofnmlen;
  86. char *osta;
  87. char *oacc;
  88. char *ofm;
  89. ftnint orl;
  90. char *oblnk;
  91. } olist;
  92. /*close*/
  93. typedef struct
  94. { flag cerr;
  95. ftnint cunit;
  96. char *csta;
  97. } cllist;
  98. /*rewind, backspace, endfile*/
  99. typedef struct
  100. { flag aerr;
  101. ftnint aunit;
  102. } alist;
  103. /* inquire */
  104. typedef struct
  105. { flag inerr;
  106. ftnint inunit;
  107. char *infile;
  108. ftnlen infilen;
  109. ftnint *inex; /*parameters in standard's order*/
  110. ftnint *inopen;
  111. ftnint *innum;
  112. ftnint *innamed;
  113. char *inname;
  114. ftnlen innamlen;
  115. char *inacc;
  116. ftnlen inacclen;
  117. char *inseq;
  118. ftnlen inseqlen;
  119. char *indir;
  120. ftnlen indirlen;
  121. char *infmt;
  122. ftnlen infmtlen;
  123. char *inform;
  124. ftnint informlen;
  125. char *inunf;
  126. ftnlen inunflen;
  127. ftnint *inrecl;
  128. ftnint *innrec;
  129. char *inblank;
  130. ftnlen inblanklen;
  131. } inlist;
  132. #define VOID void
  133. union Multitype { /* for multiple entry points */
  134. integer1 g;
  135. shortint h;
  136. integer i;
  137. /* longint j; */
  138. real r;
  139. doublereal d;
  140. complex c;
  141. doublecomplex z;
  142. };
  143. typedef union Multitype Multitype;
  144. struct Vardesc { /* for Namelist */
  145. char *name;
  146. char *addr;
  147. ftnlen *dims;
  148. int type;
  149. };
  150. typedef struct Vardesc Vardesc;
  151. struct Namelist {
  152. char *name;
  153. Vardesc **vars;
  154. int nvars;
  155. };
  156. typedef struct Namelist Namelist;
  157. #define abs(x) ((x) >= 0 ? (x) : -(x))
  158. #define dabs(x) (fabs(x))
  159. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  160. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  161. #define dmin(a,b) (f2cmin(a,b))
  162. #define dmax(a,b) (f2cmax(a,b))
  163. #define bit_test(a,b) ((a) >> (b) & 1)
  164. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  165. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  166. #define abort_() { sig_die("Fortran abort routine called", 1); }
  167. #define c_abs(z) (cabsf(Cf(z)))
  168. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  169. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  170. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  171. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  172. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  173. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  174. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  175. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  176. #define d_abs(x) (fabs(*(x)))
  177. #define d_acos(x) (acos(*(x)))
  178. #define d_asin(x) (asin(*(x)))
  179. #define d_atan(x) (atan(*(x)))
  180. #define d_atn2(x, y) (atan2(*(x),*(y)))
  181. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  182. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  183. #define d_cos(x) (cos(*(x)))
  184. #define d_cosh(x) (cosh(*(x)))
  185. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  186. #define d_exp(x) (exp(*(x)))
  187. #define d_imag(z) (cimag(Cd(z)))
  188. #define r_imag(z) (cimag(Cf(z)))
  189. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  190. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  191. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  192. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  193. #define d_log(x) (log(*(x)))
  194. #define d_mod(x, y) (fmod(*(x), *(y)))
  195. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  196. #define d_nint(x) u_nint(*(x))
  197. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  198. #define d_sign(a,b) u_sign(*(a),*(b))
  199. #define r_sign(a,b) u_sign(*(a),*(b))
  200. #define d_sin(x) (sin(*(x)))
  201. #define d_sinh(x) (sinh(*(x)))
  202. #define d_sqrt(x) (sqrt(*(x)))
  203. #define d_tan(x) (tan(*(x)))
  204. #define d_tanh(x) (tanh(*(x)))
  205. #define i_abs(x) abs(*(x))
  206. #define i_dnnt(x) ((integer)u_nint(*(x)))
  207. #define i_len(s, n) (n)
  208. #define i_nint(x) ((integer)u_nint(*(x)))
  209. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  210. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  211. #define pow_si(B,E) spow_ui(*(B),*(E))
  212. #define pow_ri(B,E) spow_ui(*(B),*(E))
  213. #define pow_di(B,E) dpow_ui(*(B),*(E))
  214. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  215. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  216. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  217. #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++ = ' '; }
  218. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  219. #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]; }
  220. #define sig_die(s, kill) { exit(1); }
  221. #define s_stop(s, n) {exit(0);}
  222. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  223. #define z_abs(z) (cabs(Cd(z)))
  224. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  225. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  226. #define myexit_() break;
  227. #define mycycle() continue;
  228. #define myceiling(w) {ceil(w)}
  229. #define myhuge(w) {HUGE_VAL}
  230. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  231. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  232. /* procedure parameter types for -A and -C++ */
  233. #define F2C_proc_par_types 1
  234. #ifdef __cplusplus
  235. typedef logical (*L_fp)(...);
  236. #else
  237. typedef logical (*L_fp)();
  238. #endif
  239. static float spow_ui(float x, integer n) {
  240. float pow=1.0; unsigned long int u;
  241. if(n != 0) {
  242. if(n < 0) n = -n, x = 1/x;
  243. for(u = n; ; ) {
  244. if(u & 01) pow *= x;
  245. if(u >>= 1) x *= x;
  246. else break;
  247. }
  248. }
  249. return pow;
  250. }
  251. static double dpow_ui(double x, integer n) {
  252. double pow=1.0; unsigned long int u;
  253. if(n != 0) {
  254. if(n < 0) n = -n, x = 1/x;
  255. for(u = n; ; ) {
  256. if(u & 01) pow *= x;
  257. if(u >>= 1) x *= x;
  258. else break;
  259. }
  260. }
  261. return pow;
  262. }
  263. static _Complex float cpow_ui(_Complex float x, integer n) {
  264. _Complex float pow=1.0; unsigned long int u;
  265. if(n != 0) {
  266. if(n < 0) n = -n, x = 1/x;
  267. for(u = n; ; ) {
  268. if(u & 01) pow *= x;
  269. if(u >>= 1) x *= x;
  270. else break;
  271. }
  272. }
  273. return pow;
  274. }
  275. static _Complex double zpow_ui(_Complex double x, integer n) {
  276. _Complex double pow=1.0; unsigned long int u;
  277. if(n != 0) {
  278. if(n < 0) n = -n, x = 1/x;
  279. for(u = n; ; ) {
  280. if(u & 01) pow *= x;
  281. if(u >>= 1) x *= x;
  282. else break;
  283. }
  284. }
  285. return pow;
  286. }
  287. static integer pow_ii(integer x, integer n) {
  288. integer pow; unsigned long int u;
  289. if (n <= 0) {
  290. if (n == 0 || x == 1) pow = 1;
  291. else if (x != -1) pow = x == 0 ? 1/x : 0;
  292. else n = -n;
  293. }
  294. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  295. u = n;
  296. for(pow = 1; ; ) {
  297. if(u & 01) pow *= x;
  298. if(u >>= 1) x *= x;
  299. else break;
  300. }
  301. }
  302. return pow;
  303. }
  304. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  305. {
  306. double m; integer i, mi;
  307. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  308. if (w[i-1]>m) mi=i ,m=w[i-1];
  309. return mi-s+1;
  310. }
  311. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  312. {
  313. float m; integer i, mi;
  314. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  315. if (w[i-1]>m) mi=i ,m=w[i-1];
  316. return mi-s+1;
  317. }
  318. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  319. integer n = *n_, incx = *incx_, incy = *incy_, i;
  320. _Complex float zdotc = 0.0;
  321. if (incx == 1 && incy == 1) {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  324. }
  325. } else {
  326. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  327. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  328. }
  329. }
  330. pCf(z) = zdotc;
  331. }
  332. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  333. integer n = *n_, incx = *incx_, incy = *incy_, i;
  334. _Complex double zdotc = 0.0;
  335. if (incx == 1 && incy == 1) {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  338. }
  339. } else {
  340. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  341. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  342. }
  343. }
  344. pCd(z) = zdotc;
  345. }
  346. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  347. integer n = *n_, incx = *incx_, incy = *incy_, i;
  348. _Complex float zdotc = 0.0;
  349. if (incx == 1 && incy == 1) {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cf(&x[i]) * Cf(&y[i]);
  352. }
  353. } else {
  354. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  355. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  356. }
  357. }
  358. pCf(z) = zdotc;
  359. }
  360. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  361. integer n = *n_, incx = *incx_, incy = *incy_, i;
  362. _Complex double zdotc = 0.0;
  363. if (incx == 1 && incy == 1) {
  364. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  365. zdotc += Cd(&x[i]) * Cd(&y[i]);
  366. }
  367. } else {
  368. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  369. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  370. }
  371. }
  372. pCd(z) = zdotc;
  373. }
  374. #endif
  375. /* -- translated by f2c (version 20000121).
  376. You must link the resulting object file with the libraries:
  377. -lf2c -lm (in that order)
  378. */
  379. /* Table of constant values */
  380. static complex c_b1 = {1.f,0.f};
  381. /* > \brief \b CTFSM solves a matrix equation (one operand is a triangular matrix in RFP format). */
  382. /* =========== DOCUMENTATION =========== */
  383. /* Online html documentation available at */
  384. /* http://www.netlib.org/lapack/explore-html/ */
  385. /* > \htmlonly */
  386. /* > Download CTFSM + dependencies */
  387. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctfsm.f
  388. "> */
  389. /* > [TGZ]</a> */
  390. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctfsm.f
  391. "> */
  392. /* > [ZIP]</a> */
  393. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctfsm.f
  394. "> */
  395. /* > [TXT]</a> */
  396. /* > \endhtmlonly */
  397. /* Definition: */
  398. /* =========== */
  399. /* SUBROUTINE CTFSM( TRANSR, SIDE, UPLO, TRANS, DIAG, M, N, ALPHA, A, */
  400. /* B, LDB ) */
  401. /* CHARACTER TRANSR, DIAG, SIDE, TRANS, UPLO */
  402. /* INTEGER LDB, M, N */
  403. /* COMPLEX ALPHA */
  404. /* COMPLEX A( 0: * ), B( 0: LDB-1, 0: * ) */
  405. /* > \par Purpose: */
  406. /* ============= */
  407. /* > */
  408. /* > \verbatim */
  409. /* > */
  410. /* > Level 3 BLAS like routine for A in RFP Format. */
  411. /* > */
  412. /* > CTFSM solves the matrix equation */
  413. /* > */
  414. /* > op( A )*X = alpha*B or X*op( A ) = alpha*B */
  415. /* > */
  416. /* > where alpha is a scalar, X and B are m by n matrices, A is a unit, or */
  417. /* > non-unit, upper or lower triangular matrix and op( A ) is one of */
  418. /* > */
  419. /* > op( A ) = A or op( A ) = A**H. */
  420. /* > */
  421. /* > A is in Rectangular Full Packed (RFP) Format. */
  422. /* > */
  423. /* > The matrix X is overwritten on B. */
  424. /* > \endverbatim */
  425. /* Arguments: */
  426. /* ========== */
  427. /* > \param[in] TRANSR */
  428. /* > \verbatim */
  429. /* > TRANSR is CHARACTER*1 */
  430. /* > = 'N': The Normal Form of RFP A is stored; */
  431. /* > = 'C': The Conjugate-transpose Form of RFP A is stored. */
  432. /* > \endverbatim */
  433. /* > */
  434. /* > \param[in] SIDE */
  435. /* > \verbatim */
  436. /* > SIDE is CHARACTER*1 */
  437. /* > On entry, SIDE specifies whether op( A ) appears on the left */
  438. /* > or right of X as follows: */
  439. /* > */
  440. /* > SIDE = 'L' or 'l' op( A )*X = alpha*B. */
  441. /* > */
  442. /* > SIDE = 'R' or 'r' X*op( A ) = alpha*B. */
  443. /* > */
  444. /* > Unchanged on exit. */
  445. /* > \endverbatim */
  446. /* > */
  447. /* > \param[in] UPLO */
  448. /* > \verbatim */
  449. /* > UPLO is CHARACTER*1 */
  450. /* > On entry, UPLO specifies whether the RFP matrix A came from */
  451. /* > an upper or lower triangular matrix as follows: */
  452. /* > UPLO = 'U' or 'u' RFP A came from an upper triangular matrix */
  453. /* > UPLO = 'L' or 'l' RFP A came from a lower triangular matrix */
  454. /* > */
  455. /* > Unchanged on exit. */
  456. /* > \endverbatim */
  457. /* > */
  458. /* > \param[in] TRANS */
  459. /* > \verbatim */
  460. /* > TRANS is CHARACTER*1 */
  461. /* > On entry, TRANS specifies the form of op( A ) to be used */
  462. /* > in the matrix multiplication as follows: */
  463. /* > */
  464. /* > TRANS = 'N' or 'n' op( A ) = A. */
  465. /* > */
  466. /* > TRANS = 'C' or 'c' op( A ) = conjg( A' ). */
  467. /* > */
  468. /* > Unchanged on exit. */
  469. /* > \endverbatim */
  470. /* > */
  471. /* > \param[in] DIAG */
  472. /* > \verbatim */
  473. /* > DIAG is CHARACTER*1 */
  474. /* > On entry, DIAG specifies whether or not RFP A is unit */
  475. /* > triangular as follows: */
  476. /* > */
  477. /* > DIAG = 'U' or 'u' A is assumed to be unit triangular. */
  478. /* > */
  479. /* > DIAG = 'N' or 'n' A is not assumed to be unit */
  480. /* > triangular. */
  481. /* > */
  482. /* > Unchanged on exit. */
  483. /* > \endverbatim */
  484. /* > */
  485. /* > \param[in] M */
  486. /* > \verbatim */
  487. /* > M is INTEGER */
  488. /* > On entry, M specifies the number of rows of B. M must be at */
  489. /* > least zero. */
  490. /* > Unchanged on exit. */
  491. /* > \endverbatim */
  492. /* > */
  493. /* > \param[in] N */
  494. /* > \verbatim */
  495. /* > N is INTEGER */
  496. /* > On entry, N specifies the number of columns of B. N must be */
  497. /* > at least zero. */
  498. /* > Unchanged on exit. */
  499. /* > \endverbatim */
  500. /* > */
  501. /* > \param[in] ALPHA */
  502. /* > \verbatim */
  503. /* > ALPHA is COMPLEX */
  504. /* > On entry, ALPHA specifies the scalar alpha. When alpha is */
  505. /* > zero then A is not referenced and B need not be set before */
  506. /* > entry. */
  507. /* > Unchanged on exit. */
  508. /* > \endverbatim */
  509. /* > */
  510. /* > \param[in] A */
  511. /* > \verbatim */
  512. /* > A is COMPLEX array, dimension (N*(N+1)/2) */
  513. /* > NT = N*(N+1)/2. On entry, the matrix A in RFP Format. */
  514. /* > RFP Format is described by TRANSR, UPLO and N as follows: */
  515. /* > If TRANSR='N' then RFP A is (0:N,0:K-1) when N is even; */
  516. /* > K=N/2. RFP A is (0:N-1,0:K) when N is odd; K=N/2. If */
  517. /* > TRANSR = 'C' then RFP is the Conjugate-transpose of RFP A as */
  518. /* > defined when TRANSR = 'N'. The contents of RFP A are defined */
  519. /* > by UPLO as follows: If UPLO = 'U' the RFP A contains the NT */
  520. /* > elements of upper packed A either in normal or */
  521. /* > conjugate-transpose Format. If UPLO = 'L' the RFP A contains */
  522. /* > the NT elements of lower packed A either in normal or */
  523. /* > conjugate-transpose Format. The LDA of RFP A is (N+1)/2 when */
  524. /* > TRANSR = 'C'. When TRANSR is 'N' the LDA is N+1 when N is */
  525. /* > even and is N when is odd. */
  526. /* > See the Note below for more details. Unchanged on exit. */
  527. /* > \endverbatim */
  528. /* > */
  529. /* > \param[in,out] B */
  530. /* > \verbatim */
  531. /* > B is COMPLEX array, dimension (LDB,N) */
  532. /* > Before entry, the leading m by n part of the array B must */
  533. /* > contain the right-hand side matrix B, and on exit is */
  534. /* > overwritten by the solution matrix X. */
  535. /* > \endverbatim */
  536. /* > */
  537. /* > \param[in] LDB */
  538. /* > \verbatim */
  539. /* > LDB is INTEGER */
  540. /* > On entry, LDB specifies the first dimension of B as declared */
  541. /* > in the calling (sub) program. LDB must be at least */
  542. /* > f2cmax( 1, m ). */
  543. /* > Unchanged on exit. */
  544. /* > \endverbatim */
  545. /* Authors: */
  546. /* ======== */
  547. /* > \author Univ. of Tennessee */
  548. /* > \author Univ. of California Berkeley */
  549. /* > \author Univ. of Colorado Denver */
  550. /* > \author NAG Ltd. */
  551. /* > \date December 2016 */
  552. /* > \ingroup complexOTHERcomputational */
  553. /* > \par Further Details: */
  554. /* ===================== */
  555. /* > */
  556. /* > \verbatim */
  557. /* > */
  558. /* > We first consider Standard Packed Format when N is even. */
  559. /* > We give an example where N = 6. */
  560. /* > */
  561. /* > AP is Upper AP is Lower */
  562. /* > */
  563. /* > 00 01 02 03 04 05 00 */
  564. /* > 11 12 13 14 15 10 11 */
  565. /* > 22 23 24 25 20 21 22 */
  566. /* > 33 34 35 30 31 32 33 */
  567. /* > 44 45 40 41 42 43 44 */
  568. /* > 55 50 51 52 53 54 55 */
  569. /* > */
  570. /* > */
  571. /* > Let TRANSR = 'N'. RFP holds AP as follows: */
  572. /* > For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
  573. /* > three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
  574. /* > conjugate-transpose of the first three columns of AP upper. */
  575. /* > For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
  576. /* > three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
  577. /* > conjugate-transpose of the last three columns of AP lower. */
  578. /* > To denote conjugate we place -- above the element. This covers the */
  579. /* > case N even and TRANSR = 'N'. */
  580. /* > */
  581. /* > RFP A RFP A */
  582. /* > */
  583. /* > -- -- -- */
  584. /* > 03 04 05 33 43 53 */
  585. /* > -- -- */
  586. /* > 13 14 15 00 44 54 */
  587. /* > -- */
  588. /* > 23 24 25 10 11 55 */
  589. /* > */
  590. /* > 33 34 35 20 21 22 */
  591. /* > -- */
  592. /* > 00 44 45 30 31 32 */
  593. /* > -- -- */
  594. /* > 01 11 55 40 41 42 */
  595. /* > -- -- -- */
  596. /* > 02 12 22 50 51 52 */
  597. /* > */
  598. /* > Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
  599. /* > transpose of RFP A above. One therefore gets: */
  600. /* > */
  601. /* > */
  602. /* > RFP A RFP A */
  603. /* > */
  604. /* > -- -- -- -- -- -- -- -- -- -- */
  605. /* > 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */
  606. /* > -- -- -- -- -- -- -- -- -- -- */
  607. /* > 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */
  608. /* > -- -- -- -- -- -- -- -- -- -- */
  609. /* > 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */
  610. /* > */
  611. /* > */
  612. /* > We next consider Standard Packed Format when N is odd. */
  613. /* > We give an example where N = 5. */
  614. /* > */
  615. /* > AP is Upper AP is Lower */
  616. /* > */
  617. /* > 00 01 02 03 04 00 */
  618. /* > 11 12 13 14 10 11 */
  619. /* > 22 23 24 20 21 22 */
  620. /* > 33 34 30 31 32 33 */
  621. /* > 44 40 41 42 43 44 */
  622. /* > */
  623. /* > */
  624. /* > Let TRANSR = 'N'. RFP holds AP as follows: */
  625. /* > For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
  626. /* > three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
  627. /* > conjugate-transpose of the first two columns of AP upper. */
  628. /* > For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
  629. /* > three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
  630. /* > conjugate-transpose of the last two columns of AP lower. */
  631. /* > To denote conjugate we place -- above the element. This covers the */
  632. /* > case N odd and TRANSR = 'N'. */
  633. /* > */
  634. /* > RFP A RFP A */
  635. /* > */
  636. /* > -- -- */
  637. /* > 02 03 04 00 33 43 */
  638. /* > -- */
  639. /* > 12 13 14 10 11 44 */
  640. /* > */
  641. /* > 22 23 24 20 21 22 */
  642. /* > -- */
  643. /* > 00 33 34 30 31 32 */
  644. /* > -- -- */
  645. /* > 01 11 44 40 41 42 */
  646. /* > */
  647. /* > Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
  648. /* > transpose of RFP A above. One therefore gets: */
  649. /* > */
  650. /* > */
  651. /* > RFP A RFP A */
  652. /* > */
  653. /* > -- -- -- -- -- -- -- -- -- */
  654. /* > 02 12 22 00 01 00 10 20 30 40 50 */
  655. /* > -- -- -- -- -- -- -- -- -- */
  656. /* > 03 13 23 33 11 33 11 21 31 41 51 */
  657. /* > -- -- -- -- -- -- -- -- -- */
  658. /* > 04 14 24 34 44 43 44 22 32 42 52 */
  659. /* > \endverbatim */
  660. /* > */
  661. /* ===================================================================== */
  662. /* Subroutine */ int ctfsm_(char *transr, char *side, char *uplo, char *trans,
  663. char *diag, integer *m, integer *n, complex *alpha, complex *a,
  664. complex *b, integer *ldb)
  665. {
  666. /* System generated locals */
  667. integer b_dim1, b_offset, i__1, i__2, i__3;
  668. complex q__1;
  669. /* Local variables */
  670. integer info, i__, j, k;
  671. logical normaltransr;
  672. extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *,
  673. integer *, complex *, complex *, integer *, complex *, integer *,
  674. complex *, complex *, integer *);
  675. logical lside;
  676. extern logical lsame_(char *, char *);
  677. logical lower;
  678. extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *,
  679. integer *, integer *, complex *, complex *, integer *, complex *,
  680. integer *);
  681. integer m1, m2, n1, n2;
  682. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  683. logical misodd, nisodd, notrans;
  684. /* -- LAPACK computational routine (version 3.7.0) -- */
  685. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  686. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  687. /* December 2016 */
  688. /* ===================================================================== */
  689. /* Test the input parameters. */
  690. /* Parameter adjustments */
  691. b_dim1 = *ldb - 1 - 0 + 1;
  692. b_offset = 0 + b_dim1 * 0;
  693. b -= b_offset;
  694. /* Function Body */
  695. info = 0;
  696. normaltransr = lsame_(transr, "N");
  697. lside = lsame_(side, "L");
  698. lower = lsame_(uplo, "L");
  699. notrans = lsame_(trans, "N");
  700. if (! normaltransr && ! lsame_(transr, "C")) {
  701. info = -1;
  702. } else if (! lside && ! lsame_(side, "R")) {
  703. info = -2;
  704. } else if (! lower && ! lsame_(uplo, "U")) {
  705. info = -3;
  706. } else if (! notrans && ! lsame_(trans, "C")) {
  707. info = -4;
  708. } else if (! lsame_(diag, "N") && ! lsame_(diag,
  709. "U")) {
  710. info = -5;
  711. } else if (*m < 0) {
  712. info = -6;
  713. } else if (*n < 0) {
  714. info = -7;
  715. } else if (*ldb < f2cmax(1,*m)) {
  716. info = -11;
  717. }
  718. if (info != 0) {
  719. i__1 = -info;
  720. xerbla_("CTFSM ", &i__1, (ftnlen)6);
  721. return 0;
  722. }
  723. /* Quick return when ( (N.EQ.0).OR.(M.EQ.0) ) */
  724. if (*m == 0 || *n == 0) {
  725. return 0;
  726. }
  727. /* Quick return when ALPHA.EQ.(0E+0,0E+0) */
  728. if (alpha->r == 0.f && alpha->i == 0.f) {
  729. i__1 = *n - 1;
  730. for (j = 0; j <= i__1; ++j) {
  731. i__2 = *m - 1;
  732. for (i__ = 0; i__ <= i__2; ++i__) {
  733. i__3 = i__ + j * b_dim1;
  734. b[i__3].r = 0.f, b[i__3].i = 0.f;
  735. /* L10: */
  736. }
  737. /* L20: */
  738. }
  739. return 0;
  740. }
  741. if (lside) {
  742. /* SIDE = 'L' */
  743. /* A is M-by-M. */
  744. /* If M is odd, set NISODD = .TRUE., and M1 and M2. */
  745. /* If M is even, NISODD = .FALSE., and M. */
  746. if (*m % 2 == 0) {
  747. misodd = FALSE_;
  748. k = *m / 2;
  749. } else {
  750. misodd = TRUE_;
  751. if (lower) {
  752. m2 = *m / 2;
  753. m1 = *m - m2;
  754. } else {
  755. m1 = *m / 2;
  756. m2 = *m - m1;
  757. }
  758. }
  759. if (misodd) {
  760. /* SIDE = 'L' and N is odd */
  761. if (normaltransr) {
  762. /* SIDE = 'L', N is odd, and TRANSR = 'N' */
  763. if (lower) {
  764. /* SIDE ='L', N is odd, TRANSR = 'N', and UPLO = 'L' */
  765. if (notrans) {
  766. /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'L', and */
  767. /* TRANS = 'N' */
  768. if (*m == 1) {
  769. ctrsm_("L", "L", "N", diag, &m1, n, alpha, a, m, &
  770. b[b_offset], ldb);
  771. } else {
  772. ctrsm_("L", "L", "N", diag, &m1, n, alpha, a, m, &
  773. b[b_offset], ldb);
  774. q__1.r = -1.f, q__1.i = 0.f;
  775. cgemm_("N", "N", &m2, n, &m1, &q__1, &a[m1], m, &
  776. b[b_offset], ldb, alpha, &b[m1], ldb);
  777. ctrsm_("L", "U", "C", diag, &m2, n, &c_b1, &a[*m],
  778. m, &b[m1], ldb);
  779. }
  780. } else {
  781. /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'L', and */
  782. /* TRANS = 'C' */
  783. if (*m == 1) {
  784. ctrsm_("L", "L", "C", diag, &m1, n, alpha, a, m, &
  785. b[b_offset], ldb);
  786. } else {
  787. ctrsm_("L", "U", "N", diag, &m2, n, alpha, &a[*m],
  788. m, &b[m1], ldb);
  789. q__1.r = -1.f, q__1.i = 0.f;
  790. cgemm_("C", "N", &m1, n, &m2, &q__1, &a[m1], m, &
  791. b[m1], ldb, alpha, &b[b_offset], ldb);
  792. ctrsm_("L", "L", "C", diag, &m1, n, &c_b1, a, m, &
  793. b[b_offset], ldb);
  794. }
  795. }
  796. } else {
  797. /* SIDE ='L', N is odd, TRANSR = 'N', and UPLO = 'U' */
  798. if (! notrans) {
  799. /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'U', and */
  800. /* TRANS = 'N' */
  801. ctrsm_("L", "L", "N", diag, &m1, n, alpha, &a[m2], m,
  802. &b[b_offset], ldb);
  803. q__1.r = -1.f, q__1.i = 0.f;
  804. cgemm_("C", "N", &m2, n, &m1, &q__1, a, m, &b[
  805. b_offset], ldb, alpha, &b[m1], ldb);
  806. ctrsm_("L", "U", "C", diag, &m2, n, &c_b1, &a[m1], m,
  807. &b[m1], ldb);
  808. } else {
  809. /* SIDE ='L', N is odd, TRANSR = 'N', UPLO = 'U', and */
  810. /* TRANS = 'C' */
  811. ctrsm_("L", "U", "N", diag, &m2, n, alpha, &a[m1], m,
  812. &b[m1], ldb);
  813. q__1.r = -1.f, q__1.i = 0.f;
  814. cgemm_("N", "N", &m1, n, &m2, &q__1, a, m, &b[m1],
  815. ldb, alpha, &b[b_offset], ldb);
  816. ctrsm_("L", "L", "C", diag, &m1, n, &c_b1, &a[m2], m,
  817. &b[b_offset], ldb);
  818. }
  819. }
  820. } else {
  821. /* SIDE = 'L', N is odd, and TRANSR = 'C' */
  822. if (lower) {
  823. /* SIDE ='L', N is odd, TRANSR = 'C', and UPLO = 'L' */
  824. if (notrans) {
  825. /* SIDE ='L', N is odd, TRANSR = 'C', UPLO = 'L', and */
  826. /* TRANS = 'N' */
  827. if (*m == 1) {
  828. ctrsm_("L", "U", "C", diag, &m1, n, alpha, a, &m1,
  829. &b[b_offset], ldb);
  830. } else {
  831. ctrsm_("L", "U", "C", diag, &m1, n, alpha, a, &m1,
  832. &b[b_offset], ldb);
  833. q__1.r = -1.f, q__1.i = 0.f;
  834. cgemm_("C", "N", &m2, n, &m1, &q__1, &a[m1 * m1],
  835. &m1, &b[b_offset], ldb, alpha, &b[m1],
  836. ldb);
  837. ctrsm_("L", "L", "N", diag, &m2, n, &c_b1, &a[1],
  838. &m1, &b[m1], ldb);
  839. }
  840. } else {
  841. /* SIDE ='L', N is odd, TRANSR = 'C', UPLO = 'L', and */
  842. /* TRANS = 'C' */
  843. if (*m == 1) {
  844. ctrsm_("L", "U", "N", diag, &m1, n, alpha, a, &m1,
  845. &b[b_offset], ldb);
  846. } else {
  847. ctrsm_("L", "L", "C", diag, &m2, n, alpha, &a[1],
  848. &m1, &b[m1], ldb);
  849. q__1.r = -1.f, q__1.i = 0.f;
  850. cgemm_("N", "N", &m1, n, &m2, &q__1, &a[m1 * m1],
  851. &m1, &b[m1], ldb, alpha, &b[b_offset],
  852. ldb);
  853. ctrsm_("L", "U", "N", diag, &m1, n, &c_b1, a, &m1,
  854. &b[b_offset], ldb);
  855. }
  856. }
  857. } else {
  858. /* SIDE ='L', N is odd, TRANSR = 'C', and UPLO = 'U' */
  859. if (! notrans) {
  860. /* SIDE ='L', N is odd, TRANSR = 'C', UPLO = 'U', and */
  861. /* TRANS = 'N' */
  862. ctrsm_("L", "U", "C", diag, &m1, n, alpha, &a[m2 * m2]
  863. , &m2, &b[b_offset], ldb);
  864. q__1.r = -1.f, q__1.i = 0.f;
  865. cgemm_("N", "N", &m2, n, &m1, &q__1, a, &m2, &b[
  866. b_offset], ldb, alpha, &b[m1], ldb);
  867. ctrsm_("L", "L", "N", diag, &m2, n, &c_b1, &a[m1 * m2]
  868. , &m2, &b[m1], ldb);
  869. } else {
  870. /* SIDE ='L', N is odd, TRANSR = 'C', UPLO = 'U', and */
  871. /* TRANS = 'C' */
  872. ctrsm_("L", "L", "C", diag, &m2, n, alpha, &a[m1 * m2]
  873. , &m2, &b[m1], ldb);
  874. q__1.r = -1.f, q__1.i = 0.f;
  875. cgemm_("C", "N", &m1, n, &m2, &q__1, a, &m2, &b[m1],
  876. ldb, alpha, &b[b_offset], ldb);
  877. ctrsm_("L", "U", "N", diag, &m1, n, &c_b1, &a[m2 * m2]
  878. , &m2, &b[b_offset], ldb);
  879. }
  880. }
  881. }
  882. } else {
  883. /* SIDE = 'L' and N is even */
  884. if (normaltransr) {
  885. /* SIDE = 'L', N is even, and TRANSR = 'N' */
  886. if (lower) {
  887. /* SIDE ='L', N is even, TRANSR = 'N', and UPLO = 'L' */
  888. if (notrans) {
  889. /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'L', */
  890. /* and TRANS = 'N' */
  891. i__1 = *m + 1;
  892. ctrsm_("L", "L", "N", diag, &k, n, alpha, &a[1], &
  893. i__1, &b[b_offset], ldb);
  894. q__1.r = -1.f, q__1.i = 0.f;
  895. i__1 = *m + 1;
  896. cgemm_("N", "N", &k, n, &k, &q__1, &a[k + 1], &i__1, &
  897. b[b_offset], ldb, alpha, &b[k], ldb);
  898. i__1 = *m + 1;
  899. ctrsm_("L", "U", "C", diag, &k, n, &c_b1, a, &i__1, &
  900. b[k], ldb);
  901. } else {
  902. /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'L', */
  903. /* and TRANS = 'C' */
  904. i__1 = *m + 1;
  905. ctrsm_("L", "U", "N", diag, &k, n, alpha, a, &i__1, &
  906. b[k], ldb);
  907. q__1.r = -1.f, q__1.i = 0.f;
  908. i__1 = *m + 1;
  909. cgemm_("C", "N", &k, n, &k, &q__1, &a[k + 1], &i__1, &
  910. b[k], ldb, alpha, &b[b_offset], ldb);
  911. i__1 = *m + 1;
  912. ctrsm_("L", "L", "C", diag, &k, n, &c_b1, &a[1], &
  913. i__1, &b[b_offset], ldb);
  914. }
  915. } else {
  916. /* SIDE ='L', N is even, TRANSR = 'N', and UPLO = 'U' */
  917. if (! notrans) {
  918. /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'U', */
  919. /* and TRANS = 'N' */
  920. i__1 = *m + 1;
  921. ctrsm_("L", "L", "N", diag, &k, n, alpha, &a[k + 1], &
  922. i__1, &b[b_offset], ldb);
  923. q__1.r = -1.f, q__1.i = 0.f;
  924. i__1 = *m + 1;
  925. cgemm_("C", "N", &k, n, &k, &q__1, a, &i__1, &b[
  926. b_offset], ldb, alpha, &b[k], ldb);
  927. i__1 = *m + 1;
  928. ctrsm_("L", "U", "C", diag, &k, n, &c_b1, &a[k], &
  929. i__1, &b[k], ldb);
  930. } else {
  931. /* SIDE ='L', N is even, TRANSR = 'N', UPLO = 'U', */
  932. /* and TRANS = 'C' */
  933. i__1 = *m + 1;
  934. ctrsm_("L", "U", "N", diag, &k, n, alpha, &a[k], &
  935. i__1, &b[k], ldb);
  936. q__1.r = -1.f, q__1.i = 0.f;
  937. i__1 = *m + 1;
  938. cgemm_("N", "N", &k, n, &k, &q__1, a, &i__1, &b[k],
  939. ldb, alpha, &b[b_offset], ldb);
  940. i__1 = *m + 1;
  941. ctrsm_("L", "L", "C", diag, &k, n, &c_b1, &a[k + 1], &
  942. i__1, &b[b_offset], ldb);
  943. }
  944. }
  945. } else {
  946. /* SIDE = 'L', N is even, and TRANSR = 'C' */
  947. if (lower) {
  948. /* SIDE ='L', N is even, TRANSR = 'C', and UPLO = 'L' */
  949. if (notrans) {
  950. /* SIDE ='L', N is even, TRANSR = 'C', UPLO = 'L', */
  951. /* and TRANS = 'N' */
  952. ctrsm_("L", "U", "C", diag, &k, n, alpha, &a[k], &k, &
  953. b[b_offset], ldb);
  954. q__1.r = -1.f, q__1.i = 0.f;
  955. cgemm_("C", "N", &k, n, &k, &q__1, &a[k * (k + 1)], &
  956. k, &b[b_offset], ldb, alpha, &b[k], ldb);
  957. ctrsm_("L", "L", "N", diag, &k, n, &c_b1, a, &k, &b[k]
  958. , ldb);
  959. } else {
  960. /* SIDE ='L', N is even, TRANSR = 'C', UPLO = 'L', */
  961. /* and TRANS = 'C' */
  962. ctrsm_("L", "L", "C", diag, &k, n, alpha, a, &k, &b[k]
  963. , ldb);
  964. q__1.r = -1.f, q__1.i = 0.f;
  965. cgemm_("N", "N", &k, n, &k, &q__1, &a[k * (k + 1)], &
  966. k, &b[k], ldb, alpha, &b[b_offset], ldb);
  967. ctrsm_("L", "U", "N", diag, &k, n, &c_b1, &a[k], &k, &
  968. b[b_offset], ldb);
  969. }
  970. } else {
  971. /* SIDE ='L', N is even, TRANSR = 'C', and UPLO = 'U' */
  972. if (! notrans) {
  973. /* SIDE ='L', N is even, TRANSR = 'C', UPLO = 'U', */
  974. /* and TRANS = 'N' */
  975. ctrsm_("L", "U", "C", diag, &k, n, alpha, &a[k * (k +
  976. 1)], &k, &b[b_offset], ldb);
  977. q__1.r = -1.f, q__1.i = 0.f;
  978. cgemm_("N", "N", &k, n, &k, &q__1, a, &k, &b[b_offset]
  979. , ldb, alpha, &b[k], ldb);
  980. ctrsm_("L", "L", "N", diag, &k, n, &c_b1, &a[k * k], &
  981. k, &b[k], ldb);
  982. } else {
  983. /* SIDE ='L', N is even, TRANSR = 'C', UPLO = 'U', */
  984. /* and TRANS = 'C' */
  985. ctrsm_("L", "L", "C", diag, &k, n, alpha, &a[k * k], &
  986. k, &b[k], ldb);
  987. q__1.r = -1.f, q__1.i = 0.f;
  988. cgemm_("C", "N", &k, n, &k, &q__1, a, &k, &b[k], ldb,
  989. alpha, &b[b_offset], ldb);
  990. ctrsm_("L", "U", "N", diag, &k, n, &c_b1, &a[k * (k +
  991. 1)], &k, &b[b_offset], ldb);
  992. }
  993. }
  994. }
  995. }
  996. } else {
  997. /* SIDE = 'R' */
  998. /* A is N-by-N. */
  999. /* If N is odd, set NISODD = .TRUE., and N1 and N2. */
  1000. /* If N is even, NISODD = .FALSE., and K. */
  1001. if (*n % 2 == 0) {
  1002. nisodd = FALSE_;
  1003. k = *n / 2;
  1004. } else {
  1005. nisodd = TRUE_;
  1006. if (lower) {
  1007. n2 = *n / 2;
  1008. n1 = *n - n2;
  1009. } else {
  1010. n1 = *n / 2;
  1011. n2 = *n - n1;
  1012. }
  1013. }
  1014. if (nisodd) {
  1015. /* SIDE = 'R' and N is odd */
  1016. if (normaltransr) {
  1017. /* SIDE = 'R', N is odd, and TRANSR = 'N' */
  1018. if (lower) {
  1019. /* SIDE ='R', N is odd, TRANSR = 'N', and UPLO = 'L' */
  1020. if (notrans) {
  1021. /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'L', and */
  1022. /* TRANS = 'N' */
  1023. ctrsm_("R", "U", "C", diag, m, &n2, alpha, &a[*n], n,
  1024. &b[n1 * b_dim1], ldb);
  1025. q__1.r = -1.f, q__1.i = 0.f;
  1026. cgemm_("N", "N", m, &n1, &n2, &q__1, &b[n1 * b_dim1],
  1027. ldb, &a[n1], n, alpha, b, ldb);
  1028. ctrsm_("R", "L", "N", diag, m, &n1, &c_b1, a, n, b,
  1029. ldb);
  1030. } else {
  1031. /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'L', and */
  1032. /* TRANS = 'C' */
  1033. ctrsm_("R", "L", "C", diag, m, &n1, alpha, a, n, b,
  1034. ldb);
  1035. q__1.r = -1.f, q__1.i = 0.f;
  1036. cgemm_("N", "C", m, &n2, &n1, &q__1, b, ldb, &a[n1],
  1037. n, alpha, &b[n1 * b_dim1], ldb);
  1038. ctrsm_("R", "U", "N", diag, m, &n2, &c_b1, &a[*n], n,
  1039. &b[n1 * b_dim1], ldb);
  1040. }
  1041. } else {
  1042. /* SIDE ='R', N is odd, TRANSR = 'N', and UPLO = 'U' */
  1043. if (notrans) {
  1044. /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'U', and */
  1045. /* TRANS = 'N' */
  1046. ctrsm_("R", "L", "C", diag, m, &n1, alpha, &a[n2], n,
  1047. b, ldb);
  1048. q__1.r = -1.f, q__1.i = 0.f;
  1049. cgemm_("N", "N", m, &n2, &n1, &q__1, b, ldb, a, n,
  1050. alpha, &b[n1 * b_dim1], ldb);
  1051. ctrsm_("R", "U", "N", diag, m, &n2, &c_b1, &a[n1], n,
  1052. &b[n1 * b_dim1], ldb);
  1053. } else {
  1054. /* SIDE ='R', N is odd, TRANSR = 'N', UPLO = 'U', and */
  1055. /* TRANS = 'C' */
  1056. ctrsm_("R", "U", "C", diag, m, &n2, alpha, &a[n1], n,
  1057. &b[n1 * b_dim1], ldb);
  1058. q__1.r = -1.f, q__1.i = 0.f;
  1059. cgemm_("N", "C", m, &n1, &n2, &q__1, &b[n1 * b_dim1],
  1060. ldb, a, n, alpha, b, ldb);
  1061. ctrsm_("R", "L", "N", diag, m, &n1, &c_b1, &a[n2], n,
  1062. b, ldb);
  1063. }
  1064. }
  1065. } else {
  1066. /* SIDE = 'R', N is odd, and TRANSR = 'C' */
  1067. if (lower) {
  1068. /* SIDE ='R', N is odd, TRANSR = 'C', and UPLO = 'L' */
  1069. if (notrans) {
  1070. /* SIDE ='R', N is odd, TRANSR = 'C', UPLO = 'L', and */
  1071. /* TRANS = 'N' */
  1072. ctrsm_("R", "L", "N", diag, m, &n2, alpha, &a[1], &n1,
  1073. &b[n1 * b_dim1], ldb);
  1074. q__1.r = -1.f, q__1.i = 0.f;
  1075. cgemm_("N", "C", m, &n1, &n2, &q__1, &b[n1 * b_dim1],
  1076. ldb, &a[n1 * n1], &n1, alpha, b, ldb);
  1077. ctrsm_("R", "U", "C", diag, m, &n1, &c_b1, a, &n1, b,
  1078. ldb);
  1079. } else {
  1080. /* SIDE ='R', N is odd, TRANSR = 'C', UPLO = 'L', and */
  1081. /* TRANS = 'C' */
  1082. ctrsm_("R", "U", "N", diag, m, &n1, alpha, a, &n1, b,
  1083. ldb);
  1084. q__1.r = -1.f, q__1.i = 0.f;
  1085. cgemm_("N", "N", m, &n2, &n1, &q__1, b, ldb, &a[n1 *
  1086. n1], &n1, alpha, &b[n1 * b_dim1], ldb);
  1087. ctrsm_("R", "L", "C", diag, m, &n2, &c_b1, &a[1], &n1,
  1088. &b[n1 * b_dim1], ldb);
  1089. }
  1090. } else {
  1091. /* SIDE ='R', N is odd, TRANSR = 'C', and UPLO = 'U' */
  1092. if (notrans) {
  1093. /* SIDE ='R', N is odd, TRANSR = 'C', UPLO = 'U', and */
  1094. /* TRANS = 'N' */
  1095. ctrsm_("R", "U", "N", diag, m, &n1, alpha, &a[n2 * n2]
  1096. , &n2, b, ldb);
  1097. q__1.r = -1.f, q__1.i = 0.f;
  1098. cgemm_("N", "C", m, &n2, &n1, &q__1, b, ldb, a, &n2,
  1099. alpha, &b[n1 * b_dim1], ldb);
  1100. ctrsm_("R", "L", "C", diag, m, &n2, &c_b1, &a[n1 * n2]
  1101. , &n2, &b[n1 * b_dim1], ldb);
  1102. } else {
  1103. /* SIDE ='R', N is odd, TRANSR = 'C', UPLO = 'U', and */
  1104. /* TRANS = 'C' */
  1105. ctrsm_("R", "L", "N", diag, m, &n2, alpha, &a[n1 * n2]
  1106. , &n2, &b[n1 * b_dim1], ldb);
  1107. q__1.r = -1.f, q__1.i = 0.f;
  1108. cgemm_("N", "N", m, &n1, &n2, &q__1, &b[n1 * b_dim1],
  1109. ldb, a, &n2, alpha, b, ldb);
  1110. ctrsm_("R", "U", "C", diag, m, &n1, &c_b1, &a[n2 * n2]
  1111. , &n2, b, ldb);
  1112. }
  1113. }
  1114. }
  1115. } else {
  1116. /* SIDE = 'R' and N is even */
  1117. if (normaltransr) {
  1118. /* SIDE = 'R', N is even, and TRANSR = 'N' */
  1119. if (lower) {
  1120. /* SIDE ='R', N is even, TRANSR = 'N', and UPLO = 'L' */
  1121. if (notrans) {
  1122. /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'L', */
  1123. /* and TRANS = 'N' */
  1124. i__1 = *n + 1;
  1125. ctrsm_("R", "U", "C", diag, m, &k, alpha, a, &i__1, &
  1126. b[k * b_dim1], ldb);
  1127. q__1.r = -1.f, q__1.i = 0.f;
  1128. i__1 = *n + 1;
  1129. cgemm_("N", "N", m, &k, &k, &q__1, &b[k * b_dim1],
  1130. ldb, &a[k + 1], &i__1, alpha, b, ldb);
  1131. i__1 = *n + 1;
  1132. ctrsm_("R", "L", "N", diag, m, &k, &c_b1, &a[1], &
  1133. i__1, b, ldb);
  1134. } else {
  1135. /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'L', */
  1136. /* and TRANS = 'C' */
  1137. i__1 = *n + 1;
  1138. ctrsm_("R", "L", "C", diag, m, &k, alpha, &a[1], &
  1139. i__1, b, ldb);
  1140. q__1.r = -1.f, q__1.i = 0.f;
  1141. i__1 = *n + 1;
  1142. cgemm_("N", "C", m, &k, &k, &q__1, b, ldb, &a[k + 1],
  1143. &i__1, alpha, &b[k * b_dim1], ldb);
  1144. i__1 = *n + 1;
  1145. ctrsm_("R", "U", "N", diag, m, &k, &c_b1, a, &i__1, &
  1146. b[k * b_dim1], ldb);
  1147. }
  1148. } else {
  1149. /* SIDE ='R', N is even, TRANSR = 'N', and UPLO = 'U' */
  1150. if (notrans) {
  1151. /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'U', */
  1152. /* and TRANS = 'N' */
  1153. i__1 = *n + 1;
  1154. ctrsm_("R", "L", "C", diag, m, &k, alpha, &a[k + 1], &
  1155. i__1, b, ldb);
  1156. q__1.r = -1.f, q__1.i = 0.f;
  1157. i__1 = *n + 1;
  1158. cgemm_("N", "N", m, &k, &k, &q__1, b, ldb, a, &i__1,
  1159. alpha, &b[k * b_dim1], ldb);
  1160. i__1 = *n + 1;
  1161. ctrsm_("R", "U", "N", diag, m, &k, &c_b1, &a[k], &
  1162. i__1, &b[k * b_dim1], ldb);
  1163. } else {
  1164. /* SIDE ='R', N is even, TRANSR = 'N', UPLO = 'U', */
  1165. /* and TRANS = 'C' */
  1166. i__1 = *n + 1;
  1167. ctrsm_("R", "U", "C", diag, m, &k, alpha, &a[k], &
  1168. i__1, &b[k * b_dim1], ldb);
  1169. q__1.r = -1.f, q__1.i = 0.f;
  1170. i__1 = *n + 1;
  1171. cgemm_("N", "C", m, &k, &k, &q__1, &b[k * b_dim1],
  1172. ldb, a, &i__1, alpha, b, ldb);
  1173. i__1 = *n + 1;
  1174. ctrsm_("R", "L", "N", diag, m, &k, &c_b1, &a[k + 1], &
  1175. i__1, b, ldb);
  1176. }
  1177. }
  1178. } else {
  1179. /* SIDE = 'R', N is even, and TRANSR = 'C' */
  1180. if (lower) {
  1181. /* SIDE ='R', N is even, TRANSR = 'C', and UPLO = 'L' */
  1182. if (notrans) {
  1183. /* SIDE ='R', N is even, TRANSR = 'C', UPLO = 'L', */
  1184. /* and TRANS = 'N' */
  1185. ctrsm_("R", "L", "N", diag, m, &k, alpha, a, &k, &b[k
  1186. * b_dim1], ldb);
  1187. q__1.r = -1.f, q__1.i = 0.f;
  1188. cgemm_("N", "C", m, &k, &k, &q__1, &b[k * b_dim1],
  1189. ldb, &a[(k + 1) * k], &k, alpha, b, ldb);
  1190. ctrsm_("R", "U", "C", diag, m, &k, &c_b1, &a[k], &k,
  1191. b, ldb);
  1192. } else {
  1193. /* SIDE ='R', N is even, TRANSR = 'C', UPLO = 'L', */
  1194. /* and TRANS = 'C' */
  1195. ctrsm_("R", "U", "N", diag, m, &k, alpha, &a[k], &k,
  1196. b, ldb);
  1197. q__1.r = -1.f, q__1.i = 0.f;
  1198. cgemm_("N", "N", m, &k, &k, &q__1, b, ldb, &a[(k + 1)
  1199. * k], &k, alpha, &b[k * b_dim1], ldb);
  1200. ctrsm_("R", "L", "C", diag, m, &k, &c_b1, a, &k, &b[k
  1201. * b_dim1], ldb);
  1202. }
  1203. } else {
  1204. /* SIDE ='R', N is even, TRANSR = 'C', and UPLO = 'U' */
  1205. if (notrans) {
  1206. /* SIDE ='R', N is even, TRANSR = 'C', UPLO = 'U', */
  1207. /* and TRANS = 'N' */
  1208. ctrsm_("R", "U", "N", diag, m, &k, alpha, &a[(k + 1) *
  1209. k], &k, b, ldb);
  1210. q__1.r = -1.f, q__1.i = 0.f;
  1211. cgemm_("N", "C", m, &k, &k, &q__1, b, ldb, a, &k,
  1212. alpha, &b[k * b_dim1], ldb);
  1213. ctrsm_("R", "L", "C", diag, m, &k, &c_b1, &a[k * k], &
  1214. k, &b[k * b_dim1], ldb);
  1215. } else {
  1216. /* SIDE ='R', N is even, TRANSR = 'C', UPLO = 'U', */
  1217. /* and TRANS = 'C' */
  1218. ctrsm_("R", "L", "N", diag, m, &k, alpha, &a[k * k], &
  1219. k, &b[k * b_dim1], ldb);
  1220. q__1.r = -1.f, q__1.i = 0.f;
  1221. cgemm_("N", "N", m, &k, &k, &q__1, &b[k * b_dim1],
  1222. ldb, a, &k, alpha, b, ldb);
  1223. ctrsm_("R", "U", "C", diag, m, &k, &c_b1, &a[(k + 1) *
  1224. k], &k, b, ldb);
  1225. }
  1226. }
  1227. }
  1228. }
  1229. }
  1230. return 0;
  1231. /* End of CTFSM */
  1232. } /* ctfsm_ */