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.

stfsm.c 40 kB

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