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.

stprfb.c 44 kB

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