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.

dtgsy2.c 49 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712
  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 integer c__8 = 8;
  487. static integer c__1 = 1;
  488. static doublereal c_b27 = -1.;
  489. static doublereal c_b42 = 1.;
  490. static doublereal c_b56 = 0.;
  491. /* > \brief \b DTGSY2 solves the generalized Sylvester equation (unblocked algorithm). */
  492. /* =========== DOCUMENTATION =========== */
  493. /* Online html documentation available at */
  494. /* http://www.netlib.org/lapack/explore-html/ */
  495. /* > \htmlonly */
  496. /* > Download DTGSY2 + dependencies */
  497. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtgsy2.
  498. f"> */
  499. /* > [TGZ]</a> */
  500. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtgsy2.
  501. f"> */
  502. /* > [ZIP]</a> */
  503. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtgsy2.
  504. f"> */
  505. /* > [TXT]</a> */
  506. /* > \endhtmlonly */
  507. /* Definition: */
  508. /* =========== */
  509. /* SUBROUTINE DTGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D, */
  510. /* LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL, */
  511. /* IWORK, PQ, INFO ) */
  512. /* CHARACTER TRANS */
  513. /* INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N, */
  514. /* $ PQ */
  515. /* DOUBLE PRECISION RDSCAL, RDSUM, SCALE */
  516. /* INTEGER IWORK( * ) */
  517. /* DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * ), */
  518. /* $ D( LDD, * ), E( LDE, * ), F( LDF, * ) */
  519. /* > \par Purpose: */
  520. /* ============= */
  521. /* > */
  522. /* > \verbatim */
  523. /* > */
  524. /* > DTGSY2 solves the generalized Sylvester equation: */
  525. /* > */
  526. /* > A * R - L * B = scale * C (1) */
  527. /* > D * R - L * E = scale * F, */
  528. /* > */
  529. /* > using Level 1 and 2 BLAS. where R and L are unknown M-by-N matrices, */
  530. /* > (A, D), (B, E) and (C, F) are given matrix pairs of size M-by-M, */
  531. /* > N-by-N and M-by-N, respectively, with real entries. (A, D) and (B, E) */
  532. /* > must be in generalized Schur canonical form, i.e. A, B are upper */
  533. /* > quasi triangular and D, E are upper triangular. The solution (R, L) */
  534. /* > overwrites (C, F). 0 <= SCALE <= 1 is an output scaling factor */
  535. /* > chosen to avoid overflow. */
  536. /* > */
  537. /* > In matrix notation solving equation (1) corresponds to solve */
  538. /* > Z*x = scale*b, where Z is defined as */
  539. /* > */
  540. /* > Z = [ kron(In, A) -kron(B**T, Im) ] (2) */
  541. /* > [ kron(In, D) -kron(E**T, Im) ], */
  542. /* > */
  543. /* > Ik is the identity matrix of size k and X**T is the transpose of X. */
  544. /* > kron(X, Y) is the Kronecker product between the matrices X and Y. */
  545. /* > In the process of solving (1), we solve a number of such systems */
  546. /* > where Dim(In), Dim(In) = 1 or 2. */
  547. /* > */
  548. /* > If TRANS = 'T', solve the transposed system Z**T*y = scale*b for y, */
  549. /* > which is equivalent to solve for R and L in */
  550. /* > */
  551. /* > A**T * R + D**T * L = scale * C (3) */
  552. /* > R * B**T + L * E**T = scale * -F */
  553. /* > */
  554. /* > This case is used to compute an estimate of Dif[(A, D), (B, E)] = */
  555. /* > sigma_min(Z) using reverse communication with DLACON. */
  556. /* > */
  557. /* > DTGSY2 also (IJOB >= 1) contributes to the computation in DTGSYL */
  558. /* > of an upper bound on the separation between to matrix pairs. Then */
  559. /* > the input (A, D), (B, E) are sub-pencils of the matrix pair in */
  560. /* > DTGSYL. See DTGSYL for details. */
  561. /* > \endverbatim */
  562. /* Arguments: */
  563. /* ========== */
  564. /* > \param[in] TRANS */
  565. /* > \verbatim */
  566. /* > TRANS is CHARACTER*1 */
  567. /* > = 'N': solve the generalized Sylvester equation (1). */
  568. /* > = 'T': solve the 'transposed' system (3). */
  569. /* > \endverbatim */
  570. /* > */
  571. /* > \param[in] IJOB */
  572. /* > \verbatim */
  573. /* > IJOB is INTEGER */
  574. /* > Specifies what kind of functionality to be performed. */
  575. /* > = 0: solve (1) only. */
  576. /* > = 1: A contribution from this subsystem to a Frobenius */
  577. /* > norm-based estimate of the separation between two matrix */
  578. /* > pairs is computed. (look ahead strategy is used). */
  579. /* > = 2: A contribution from this subsystem to a Frobenius */
  580. /* > norm-based estimate of the separation between two matrix */
  581. /* > pairs is computed. (DGECON on sub-systems is used.) */
  582. /* > Not referenced if TRANS = 'T'. */
  583. /* > \endverbatim */
  584. /* > */
  585. /* > \param[in] M */
  586. /* > \verbatim */
  587. /* > M is INTEGER */
  588. /* > On entry, M specifies the order of A and D, and the row */
  589. /* > dimension of C, F, R and L. */
  590. /* > \endverbatim */
  591. /* > */
  592. /* > \param[in] N */
  593. /* > \verbatim */
  594. /* > N is INTEGER */
  595. /* > On entry, N specifies the order of B and E, and the column */
  596. /* > dimension of C, F, R and L. */
  597. /* > \endverbatim */
  598. /* > */
  599. /* > \param[in] A */
  600. /* > \verbatim */
  601. /* > A is DOUBLE PRECISION array, dimension (LDA, M) */
  602. /* > On entry, A contains an upper quasi triangular matrix. */
  603. /* > \endverbatim */
  604. /* > */
  605. /* > \param[in] LDA */
  606. /* > \verbatim */
  607. /* > LDA is INTEGER */
  608. /* > The leading dimension of the matrix A. LDA >= f2cmax(1, M). */
  609. /* > \endverbatim */
  610. /* > */
  611. /* > \param[in] B */
  612. /* > \verbatim */
  613. /* > B is DOUBLE PRECISION array, dimension (LDB, N) */
  614. /* > On entry, B contains an upper quasi triangular matrix. */
  615. /* > \endverbatim */
  616. /* > */
  617. /* > \param[in] LDB */
  618. /* > \verbatim */
  619. /* > LDB is INTEGER */
  620. /* > The leading dimension of the matrix B. LDB >= f2cmax(1, N). */
  621. /* > \endverbatim */
  622. /* > */
  623. /* > \param[in,out] C */
  624. /* > \verbatim */
  625. /* > C is DOUBLE PRECISION array, dimension (LDC, N) */
  626. /* > On entry, C contains the right-hand-side of the first matrix */
  627. /* > equation in (1). */
  628. /* > On exit, if IJOB = 0, C has been overwritten by the */
  629. /* > solution R. */
  630. /* > \endverbatim */
  631. /* > */
  632. /* > \param[in] LDC */
  633. /* > \verbatim */
  634. /* > LDC is INTEGER */
  635. /* > The leading dimension of the matrix C. LDC >= f2cmax(1, M). */
  636. /* > \endverbatim */
  637. /* > */
  638. /* > \param[in] D */
  639. /* > \verbatim */
  640. /* > D is DOUBLE PRECISION array, dimension (LDD, M) */
  641. /* > On entry, D contains an upper triangular matrix. */
  642. /* > \endverbatim */
  643. /* > */
  644. /* > \param[in] LDD */
  645. /* > \verbatim */
  646. /* > LDD is INTEGER */
  647. /* > The leading dimension of the matrix D. LDD >= f2cmax(1, M). */
  648. /* > \endverbatim */
  649. /* > */
  650. /* > \param[in] E */
  651. /* > \verbatim */
  652. /* > E is DOUBLE PRECISION array, dimension (LDE, N) */
  653. /* > On entry, E contains an upper triangular matrix. */
  654. /* > \endverbatim */
  655. /* > */
  656. /* > \param[in] LDE */
  657. /* > \verbatim */
  658. /* > LDE is INTEGER */
  659. /* > The leading dimension of the matrix E. LDE >= f2cmax(1, N). */
  660. /* > \endverbatim */
  661. /* > */
  662. /* > \param[in,out] F */
  663. /* > \verbatim */
  664. /* > F is DOUBLE PRECISION array, dimension (LDF, N) */
  665. /* > On entry, F contains the right-hand-side of the second matrix */
  666. /* > equation in (1). */
  667. /* > On exit, if IJOB = 0, F has been overwritten by the */
  668. /* > solution L. */
  669. /* > \endverbatim */
  670. /* > */
  671. /* > \param[in] LDF */
  672. /* > \verbatim */
  673. /* > LDF is INTEGER */
  674. /* > The leading dimension of the matrix F. LDF >= f2cmax(1, M). */
  675. /* > \endverbatim */
  676. /* > */
  677. /* > \param[out] SCALE */
  678. /* > \verbatim */
  679. /* > SCALE is DOUBLE PRECISION */
  680. /* > On exit, 0 <= SCALE <= 1. If 0 < SCALE < 1, the solutions */
  681. /* > R and L (C and F on entry) will hold the solutions to a */
  682. /* > slightly perturbed system but the input matrices A, B, D and */
  683. /* > E have not been changed. If SCALE = 0, R and L will hold the */
  684. /* > solutions to the homogeneous system with C = F = 0. Normally, */
  685. /* > SCALE = 1. */
  686. /* > \endverbatim */
  687. /* > */
  688. /* > \param[in,out] RDSUM */
  689. /* > \verbatim */
  690. /* > RDSUM is DOUBLE PRECISION */
  691. /* > On entry, the sum of squares of computed contributions to */
  692. /* > the Dif-estimate under computation by DTGSYL, where the */
  693. /* > scaling factor RDSCAL (see below) has been factored out. */
  694. /* > On exit, the corresponding sum of squares updated with the */
  695. /* > contributions from the current sub-system. */
  696. /* > If TRANS = 'T' RDSUM is not touched. */
  697. /* > NOTE: RDSUM only makes sense when DTGSY2 is called by DTGSYL. */
  698. /* > \endverbatim */
  699. /* > */
  700. /* > \param[in,out] RDSCAL */
  701. /* > \verbatim */
  702. /* > RDSCAL is DOUBLE PRECISION */
  703. /* > On entry, scaling factor used to prevent overflow in RDSUM. */
  704. /* > On exit, RDSCAL is updated w.r.t. the current contributions */
  705. /* > in RDSUM. */
  706. /* > If TRANS = 'T', RDSCAL is not touched. */
  707. /* > NOTE: RDSCAL only makes sense when DTGSY2 is called by */
  708. /* > DTGSYL. */
  709. /* > \endverbatim */
  710. /* > */
  711. /* > \param[out] IWORK */
  712. /* > \verbatim */
  713. /* > IWORK is INTEGER array, dimension (M+N+2) */
  714. /* > \endverbatim */
  715. /* > */
  716. /* > \param[out] PQ */
  717. /* > \verbatim */
  718. /* > PQ is INTEGER */
  719. /* > On exit, the number of subsystems (of size 2-by-2, 4-by-4 and */
  720. /* > 8-by-8) solved by this routine. */
  721. /* > \endverbatim */
  722. /* > */
  723. /* > \param[out] INFO */
  724. /* > \verbatim */
  725. /* > INFO is INTEGER */
  726. /* > On exit, if INFO is set to */
  727. /* > =0: Successful exit */
  728. /* > <0: If INFO = -i, the i-th argument had an illegal value. */
  729. /* > >0: The matrix pairs (A, D) and (B, E) have common or very */
  730. /* > close eigenvalues. */
  731. /* > \endverbatim */
  732. /* Authors: */
  733. /* ======== */
  734. /* > \author Univ. of Tennessee */
  735. /* > \author Univ. of California Berkeley */
  736. /* > \author Univ. of Colorado Denver */
  737. /* > \author NAG Ltd. */
  738. /* > \date December 2016 */
  739. /* > \ingroup doubleSYauxiliary */
  740. /* > \par Contributors: */
  741. /* ================== */
  742. /* > */
  743. /* > Bo Kagstrom and Peter Poromaa, Department of Computing Science, */
  744. /* > Umea University, S-901 87 Umea, Sweden. */
  745. /* ===================================================================== */
  746. /* Subroutine */ int dtgsy2_(char *trans, integer *ijob, integer *m, integer *
  747. n, doublereal *a, integer *lda, doublereal *b, integer *ldb,
  748. doublereal *c__, integer *ldc, doublereal *d__, integer *ldd,
  749. doublereal *e, integer *lde, doublereal *f, integer *ldf, doublereal *
  750. scale, doublereal *rdsum, doublereal *rdscal, integer *iwork, integer
  751. *pq, integer *info)
  752. {
  753. /* System generated locals */
  754. integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1,
  755. d_offset, e_dim1, e_offset, f_dim1, f_offset, i__1, i__2, i__3;
  756. /* Local variables */
  757. extern /* Subroutine */ int dger_(integer *, integer *, doublereal *,
  758. doublereal *, integer *, doublereal *, integer *, doublereal *,
  759. integer *);
  760. integer ierr, zdim, ipiv[8], jpiv[8], i__, j, k, p, q;
  761. doublereal alpha;
  762. extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
  763. integer *), dgemm_(char *, char *, integer *, integer *, integer *
  764. , doublereal *, doublereal *, integer *, doublereal *, integer *,
  765. doublereal *, doublereal *, integer *);
  766. doublereal z__[64] /* was [8][8] */;
  767. extern logical lsame_(char *, char *);
  768. extern /* Subroutine */ int dgemv_(char *, integer *, integer *,
  769. doublereal *, doublereal *, integer *, doublereal *, integer *,
  770. doublereal *, doublereal *, integer *), dcopy_(integer *,
  771. doublereal *, integer *, doublereal *, integer *), daxpy_(integer
  772. *, doublereal *, doublereal *, integer *, doublereal *, integer *)
  773. , dgesc2_(integer *, doublereal *, integer *, doublereal *,
  774. integer *, integer *, doublereal *), dgetc2_(integer *,
  775. doublereal *, integer *, integer *, integer *, integer *);
  776. integer ie, je, mb, nb, ii, jj, is, js;
  777. extern /* Subroutine */ int dlatdf_(integer *, integer *, doublereal *,
  778. integer *, doublereal *, doublereal *, doublereal *, integer *,
  779. integer *);
  780. doublereal scaloc;
  781. extern /* Subroutine */ int dlaset_(char *, integer *, integer *,
  782. doublereal *, doublereal *, doublereal *, integer *),
  783. xerbla_(char *, integer *, ftnlen);
  784. logical notran;
  785. doublereal rhs[8];
  786. integer isp1, jsp1;
  787. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  788. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  789. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  790. /* December 2016 */
  791. /* ===================================================================== */
  792. /* Replaced various illegal calls to DCOPY by calls to DLASET. */
  793. /* Sven Hammarling, 27/5/02. */
  794. /* Decode and test input parameters */
  795. /* Parameter adjustments */
  796. a_dim1 = *lda;
  797. a_offset = 1 + a_dim1 * 1;
  798. a -= a_offset;
  799. b_dim1 = *ldb;
  800. b_offset = 1 + b_dim1 * 1;
  801. b -= b_offset;
  802. c_dim1 = *ldc;
  803. c_offset = 1 + c_dim1 * 1;
  804. c__ -= c_offset;
  805. d_dim1 = *ldd;
  806. d_offset = 1 + d_dim1 * 1;
  807. d__ -= d_offset;
  808. e_dim1 = *lde;
  809. e_offset = 1 + e_dim1 * 1;
  810. e -= e_offset;
  811. f_dim1 = *ldf;
  812. f_offset = 1 + f_dim1 * 1;
  813. f -= f_offset;
  814. --iwork;
  815. /* Function Body */
  816. *info = 0;
  817. ierr = 0;
  818. notran = lsame_(trans, "N");
  819. if (! notran && ! lsame_(trans, "T")) {
  820. *info = -1;
  821. } else if (notran) {
  822. if (*ijob < 0 || *ijob > 2) {
  823. *info = -2;
  824. }
  825. }
  826. if (*info == 0) {
  827. if (*m <= 0) {
  828. *info = -3;
  829. } else if (*n <= 0) {
  830. *info = -4;
  831. } else if (*lda < f2cmax(1,*m)) {
  832. *info = -6;
  833. } else if (*ldb < f2cmax(1,*n)) {
  834. *info = -8;
  835. } else if (*ldc < f2cmax(1,*m)) {
  836. *info = -10;
  837. } else if (*ldd < f2cmax(1,*m)) {
  838. *info = -12;
  839. } else if (*lde < f2cmax(1,*n)) {
  840. *info = -14;
  841. } else if (*ldf < f2cmax(1,*m)) {
  842. *info = -16;
  843. }
  844. }
  845. if (*info != 0) {
  846. i__1 = -(*info);
  847. xerbla_("DTGSY2", &i__1, (ftnlen)6);
  848. return 0;
  849. }
  850. /* Determine block structure of A */
  851. *pq = 0;
  852. p = 0;
  853. i__ = 1;
  854. L10:
  855. if (i__ > *m) {
  856. goto L20;
  857. }
  858. ++p;
  859. iwork[p] = i__;
  860. if (i__ == *m) {
  861. goto L20;
  862. }
  863. if (a[i__ + 1 + i__ * a_dim1] != 0.) {
  864. i__ += 2;
  865. } else {
  866. ++i__;
  867. }
  868. goto L10;
  869. L20:
  870. iwork[p + 1] = *m + 1;
  871. /* Determine block structure of B */
  872. q = p + 1;
  873. j = 1;
  874. L30:
  875. if (j > *n) {
  876. goto L40;
  877. }
  878. ++q;
  879. iwork[q] = j;
  880. if (j == *n) {
  881. goto L40;
  882. }
  883. if (b[j + 1 + j * b_dim1] != 0.) {
  884. j += 2;
  885. } else {
  886. ++j;
  887. }
  888. goto L30;
  889. L40:
  890. iwork[q + 1] = *n + 1;
  891. *pq = p * (q - p - 1);
  892. if (notran) {
  893. /* Solve (I, J) - subsystem */
  894. /* A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J) */
  895. /* D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J) */
  896. /* for I = P, P - 1, ..., 1; J = 1, 2, ..., Q */
  897. *scale = 1.;
  898. scaloc = 1.;
  899. i__1 = q;
  900. for (j = p + 2; j <= i__1; ++j) {
  901. js = iwork[j];
  902. jsp1 = js + 1;
  903. je = iwork[j + 1] - 1;
  904. nb = je - js + 1;
  905. for (i__ = p; i__ >= 1; --i__) {
  906. is = iwork[i__];
  907. isp1 = is + 1;
  908. ie = iwork[i__ + 1] - 1;
  909. mb = ie - is + 1;
  910. zdim = mb * nb << 1;
  911. if (mb == 1 && nb == 1) {
  912. /* Build a 2-by-2 system Z * x = RHS */
  913. z__[0] = a[is + is * a_dim1];
  914. z__[1] = d__[is + is * d_dim1];
  915. z__[8] = -b[js + js * b_dim1];
  916. z__[9] = -e[js + js * e_dim1];
  917. /* Set up right hand side(s) */
  918. rhs[0] = c__[is + js * c_dim1];
  919. rhs[1] = f[is + js * f_dim1];
  920. /* Solve Z * x = RHS */
  921. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  922. if (ierr > 0) {
  923. *info = ierr;
  924. }
  925. if (*ijob == 0) {
  926. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  927. if (scaloc != 1.) {
  928. i__2 = *n;
  929. for (k = 1; k <= i__2; ++k) {
  930. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
  931. c__1);
  932. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  933. /* L50: */
  934. }
  935. *scale *= scaloc;
  936. }
  937. } else {
  938. dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
  939. ipiv, jpiv);
  940. }
  941. /* Unpack solution vector(s) */
  942. c__[is + js * c_dim1] = rhs[0];
  943. f[is + js * f_dim1] = rhs[1];
  944. /* Substitute R(I, J) and L(I, J) into remaining */
  945. /* equation. */
  946. if (i__ > 1) {
  947. alpha = -rhs[0];
  948. i__2 = is - 1;
  949. daxpy_(&i__2, &alpha, &a[is * a_dim1 + 1], &c__1, &
  950. c__[js * c_dim1 + 1], &c__1);
  951. i__2 = is - 1;
  952. daxpy_(&i__2, &alpha, &d__[is * d_dim1 + 1], &c__1, &
  953. f[js * f_dim1 + 1], &c__1);
  954. }
  955. if (j < q) {
  956. i__2 = *n - je;
  957. daxpy_(&i__2, &rhs[1], &b[js + (je + 1) * b_dim1],
  958. ldb, &c__[is + (je + 1) * c_dim1], ldc);
  959. i__2 = *n - je;
  960. daxpy_(&i__2, &rhs[1], &e[js + (je + 1) * e_dim1],
  961. lde, &f[is + (je + 1) * f_dim1], ldf);
  962. }
  963. } else if (mb == 1 && nb == 2) {
  964. /* Build a 4-by-4 system Z * x = RHS */
  965. z__[0] = a[is + is * a_dim1];
  966. z__[1] = 0.;
  967. z__[2] = d__[is + is * d_dim1];
  968. z__[3] = 0.;
  969. z__[8] = 0.;
  970. z__[9] = a[is + is * a_dim1];
  971. z__[10] = 0.;
  972. z__[11] = d__[is + is * d_dim1];
  973. z__[16] = -b[js + js * b_dim1];
  974. z__[17] = -b[js + jsp1 * b_dim1];
  975. z__[18] = -e[js + js * e_dim1];
  976. z__[19] = -e[js + jsp1 * e_dim1];
  977. z__[24] = -b[jsp1 + js * b_dim1];
  978. z__[25] = -b[jsp1 + jsp1 * b_dim1];
  979. z__[26] = 0.;
  980. z__[27] = -e[jsp1 + jsp1 * e_dim1];
  981. /* Set up right hand side(s) */
  982. rhs[0] = c__[is + js * c_dim1];
  983. rhs[1] = c__[is + jsp1 * c_dim1];
  984. rhs[2] = f[is + js * f_dim1];
  985. rhs[3] = f[is + jsp1 * f_dim1];
  986. /* Solve Z * x = RHS */
  987. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  988. if (ierr > 0) {
  989. *info = ierr;
  990. }
  991. if (*ijob == 0) {
  992. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  993. if (scaloc != 1.) {
  994. i__2 = *n;
  995. for (k = 1; k <= i__2; ++k) {
  996. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
  997. c__1);
  998. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  999. /* L60: */
  1000. }
  1001. *scale *= scaloc;
  1002. }
  1003. } else {
  1004. dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
  1005. ipiv, jpiv);
  1006. }
  1007. /* Unpack solution vector(s) */
  1008. c__[is + js * c_dim1] = rhs[0];
  1009. c__[is + jsp1 * c_dim1] = rhs[1];
  1010. f[is + js * f_dim1] = rhs[2];
  1011. f[is + jsp1 * f_dim1] = rhs[3];
  1012. /* Substitute R(I, J) and L(I, J) into remaining */
  1013. /* equation. */
  1014. if (i__ > 1) {
  1015. i__2 = is - 1;
  1016. dger_(&i__2, &nb, &c_b27, &a[is * a_dim1 + 1], &c__1,
  1017. rhs, &c__1, &c__[js * c_dim1 + 1], ldc);
  1018. i__2 = is - 1;
  1019. dger_(&i__2, &nb, &c_b27, &d__[is * d_dim1 + 1], &
  1020. c__1, rhs, &c__1, &f[js * f_dim1 + 1], ldf);
  1021. }
  1022. if (j < q) {
  1023. i__2 = *n - je;
  1024. daxpy_(&i__2, &rhs[2], &b[js + (je + 1) * b_dim1],
  1025. ldb, &c__[is + (je + 1) * c_dim1], ldc);
  1026. i__2 = *n - je;
  1027. daxpy_(&i__2, &rhs[2], &e[js + (je + 1) * e_dim1],
  1028. lde, &f[is + (je + 1) * f_dim1], ldf);
  1029. i__2 = *n - je;
  1030. daxpy_(&i__2, &rhs[3], &b[jsp1 + (je + 1) * b_dim1],
  1031. ldb, &c__[is + (je + 1) * c_dim1], ldc);
  1032. i__2 = *n - je;
  1033. daxpy_(&i__2, &rhs[3], &e[jsp1 + (je + 1) * e_dim1],
  1034. lde, &f[is + (je + 1) * f_dim1], ldf);
  1035. }
  1036. } else if (mb == 2 && nb == 1) {
  1037. /* Build a 4-by-4 system Z * x = RHS */
  1038. z__[0] = a[is + is * a_dim1];
  1039. z__[1] = a[isp1 + is * a_dim1];
  1040. z__[2] = d__[is + is * d_dim1];
  1041. z__[3] = 0.;
  1042. z__[8] = a[is + isp1 * a_dim1];
  1043. z__[9] = a[isp1 + isp1 * a_dim1];
  1044. z__[10] = d__[is + isp1 * d_dim1];
  1045. z__[11] = d__[isp1 + isp1 * d_dim1];
  1046. z__[16] = -b[js + js * b_dim1];
  1047. z__[17] = 0.;
  1048. z__[18] = -e[js + js * e_dim1];
  1049. z__[19] = 0.;
  1050. z__[24] = 0.;
  1051. z__[25] = -b[js + js * b_dim1];
  1052. z__[26] = 0.;
  1053. z__[27] = -e[js + js * e_dim1];
  1054. /* Set up right hand side(s) */
  1055. rhs[0] = c__[is + js * c_dim1];
  1056. rhs[1] = c__[isp1 + js * c_dim1];
  1057. rhs[2] = f[is + js * f_dim1];
  1058. rhs[3] = f[isp1 + js * f_dim1];
  1059. /* Solve Z * x = RHS */
  1060. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  1061. if (ierr > 0) {
  1062. *info = ierr;
  1063. }
  1064. if (*ijob == 0) {
  1065. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  1066. if (scaloc != 1.) {
  1067. i__2 = *n;
  1068. for (k = 1; k <= i__2; ++k) {
  1069. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
  1070. c__1);
  1071. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  1072. /* L70: */
  1073. }
  1074. *scale *= scaloc;
  1075. }
  1076. } else {
  1077. dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
  1078. ipiv, jpiv);
  1079. }
  1080. /* Unpack solution vector(s) */
  1081. c__[is + js * c_dim1] = rhs[0];
  1082. c__[isp1 + js * c_dim1] = rhs[1];
  1083. f[is + js * f_dim1] = rhs[2];
  1084. f[isp1 + js * f_dim1] = rhs[3];
  1085. /* Substitute R(I, J) and L(I, J) into remaining */
  1086. /* equation. */
  1087. if (i__ > 1) {
  1088. i__2 = is - 1;
  1089. dgemv_("N", &i__2, &mb, &c_b27, &a[is * a_dim1 + 1],
  1090. lda, rhs, &c__1, &c_b42, &c__[js * c_dim1 + 1]
  1091. , &c__1);
  1092. i__2 = is - 1;
  1093. dgemv_("N", &i__2, &mb, &c_b27, &d__[is * d_dim1 + 1],
  1094. ldd, rhs, &c__1, &c_b42, &f[js * f_dim1 + 1],
  1095. &c__1);
  1096. }
  1097. if (j < q) {
  1098. i__2 = *n - je;
  1099. dger_(&mb, &i__2, &c_b42, &rhs[2], &c__1, &b[js + (je
  1100. + 1) * b_dim1], ldb, &c__[is + (je + 1) *
  1101. c_dim1], ldc);
  1102. i__2 = *n - je;
  1103. dger_(&mb, &i__2, &c_b42, &rhs[2], &c__1, &e[js + (je
  1104. + 1) * e_dim1], lde, &f[is + (je + 1) *
  1105. f_dim1], ldf);
  1106. }
  1107. } else if (mb == 2 && nb == 2) {
  1108. /* Build an 8-by-8 system Z * x = RHS */
  1109. dlaset_("F", &c__8, &c__8, &c_b56, &c_b56, z__, &c__8);
  1110. z__[0] = a[is + is * a_dim1];
  1111. z__[1] = a[isp1 + is * a_dim1];
  1112. z__[4] = d__[is + is * d_dim1];
  1113. z__[8] = a[is + isp1 * a_dim1];
  1114. z__[9] = a[isp1 + isp1 * a_dim1];
  1115. z__[12] = d__[is + isp1 * d_dim1];
  1116. z__[13] = d__[isp1 + isp1 * d_dim1];
  1117. z__[18] = a[is + is * a_dim1];
  1118. z__[19] = a[isp1 + is * a_dim1];
  1119. z__[22] = d__[is + is * d_dim1];
  1120. z__[26] = a[is + isp1 * a_dim1];
  1121. z__[27] = a[isp1 + isp1 * a_dim1];
  1122. z__[30] = d__[is + isp1 * d_dim1];
  1123. z__[31] = d__[isp1 + isp1 * d_dim1];
  1124. z__[32] = -b[js + js * b_dim1];
  1125. z__[34] = -b[js + jsp1 * b_dim1];
  1126. z__[36] = -e[js + js * e_dim1];
  1127. z__[38] = -e[js + jsp1 * e_dim1];
  1128. z__[41] = -b[js + js * b_dim1];
  1129. z__[43] = -b[js + jsp1 * b_dim1];
  1130. z__[45] = -e[js + js * e_dim1];
  1131. z__[47] = -e[js + jsp1 * e_dim1];
  1132. z__[48] = -b[jsp1 + js * b_dim1];
  1133. z__[50] = -b[jsp1 + jsp1 * b_dim1];
  1134. z__[54] = -e[jsp1 + jsp1 * e_dim1];
  1135. z__[57] = -b[jsp1 + js * b_dim1];
  1136. z__[59] = -b[jsp1 + jsp1 * b_dim1];
  1137. z__[63] = -e[jsp1 + jsp1 * e_dim1];
  1138. /* Set up right hand side(s) */
  1139. k = 1;
  1140. ii = mb * nb + 1;
  1141. i__2 = nb - 1;
  1142. for (jj = 0; jj <= i__2; ++jj) {
  1143. dcopy_(&mb, &c__[is + (js + jj) * c_dim1], &c__1, &
  1144. rhs[k - 1], &c__1);
  1145. dcopy_(&mb, &f[is + (js + jj) * f_dim1], &c__1, &rhs[
  1146. ii - 1], &c__1);
  1147. k += mb;
  1148. ii += mb;
  1149. /* L80: */
  1150. }
  1151. /* Solve Z * x = RHS */
  1152. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  1153. if (ierr > 0) {
  1154. *info = ierr;
  1155. }
  1156. if (*ijob == 0) {
  1157. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  1158. if (scaloc != 1.) {
  1159. i__2 = *n;
  1160. for (k = 1; k <= i__2; ++k) {
  1161. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &
  1162. c__1);
  1163. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  1164. /* L90: */
  1165. }
  1166. *scale *= scaloc;
  1167. }
  1168. } else {
  1169. dlatdf_(ijob, &zdim, z__, &c__8, rhs, rdsum, rdscal,
  1170. ipiv, jpiv);
  1171. }
  1172. /* Unpack solution vector(s) */
  1173. k = 1;
  1174. ii = mb * nb + 1;
  1175. i__2 = nb - 1;
  1176. for (jj = 0; jj <= i__2; ++jj) {
  1177. dcopy_(&mb, &rhs[k - 1], &c__1, &c__[is + (js + jj) *
  1178. c_dim1], &c__1);
  1179. dcopy_(&mb, &rhs[ii - 1], &c__1, &f[is + (js + jj) *
  1180. f_dim1], &c__1);
  1181. k += mb;
  1182. ii += mb;
  1183. /* L100: */
  1184. }
  1185. /* Substitute R(I, J) and L(I, J) into remaining */
  1186. /* equation. */
  1187. if (i__ > 1) {
  1188. i__2 = is - 1;
  1189. dgemm_("N", "N", &i__2, &nb, &mb, &c_b27, &a[is *
  1190. a_dim1 + 1], lda, rhs, &mb, &c_b42, &c__[js *
  1191. c_dim1 + 1], ldc);
  1192. i__2 = is - 1;
  1193. dgemm_("N", "N", &i__2, &nb, &mb, &c_b27, &d__[is *
  1194. d_dim1 + 1], ldd, rhs, &mb, &c_b42, &f[js *
  1195. f_dim1 + 1], ldf);
  1196. }
  1197. if (j < q) {
  1198. k = mb * nb + 1;
  1199. i__2 = *n - je;
  1200. dgemm_("N", "N", &mb, &i__2, &nb, &c_b42, &rhs[k - 1],
  1201. &mb, &b[js + (je + 1) * b_dim1], ldb, &c_b42,
  1202. &c__[is + (je + 1) * c_dim1], ldc);
  1203. i__2 = *n - je;
  1204. dgemm_("N", "N", &mb, &i__2, &nb, &c_b42, &rhs[k - 1],
  1205. &mb, &e[js + (je + 1) * e_dim1], lde, &c_b42,
  1206. &f[is + (je + 1) * f_dim1], ldf);
  1207. }
  1208. }
  1209. /* L110: */
  1210. }
  1211. /* L120: */
  1212. }
  1213. } else {
  1214. /* Solve (I, J) - subsystem */
  1215. /* A(I, I)**T * R(I, J) + D(I, I)**T * L(J, J) = C(I, J) */
  1216. /* R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J) */
  1217. /* for I = 1, 2, ..., P, J = Q, Q - 1, ..., 1 */
  1218. *scale = 1.;
  1219. scaloc = 1.;
  1220. i__1 = p;
  1221. for (i__ = 1; i__ <= i__1; ++i__) {
  1222. is = iwork[i__];
  1223. isp1 = is + 1;
  1224. ie = iwork[i__ + 1] - 1;
  1225. mb = ie - is + 1;
  1226. i__2 = p + 2;
  1227. for (j = q; j >= i__2; --j) {
  1228. js = iwork[j];
  1229. jsp1 = js + 1;
  1230. je = iwork[j + 1] - 1;
  1231. nb = je - js + 1;
  1232. zdim = mb * nb << 1;
  1233. if (mb == 1 && nb == 1) {
  1234. /* Build a 2-by-2 system Z**T * x = RHS */
  1235. z__[0] = a[is + is * a_dim1];
  1236. z__[1] = -b[js + js * b_dim1];
  1237. z__[8] = d__[is + is * d_dim1];
  1238. z__[9] = -e[js + js * e_dim1];
  1239. /* Set up right hand side(s) */
  1240. rhs[0] = c__[is + js * c_dim1];
  1241. rhs[1] = f[is + js * f_dim1];
  1242. /* Solve Z**T * x = RHS */
  1243. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  1244. if (ierr > 0) {
  1245. *info = ierr;
  1246. }
  1247. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  1248. if (scaloc != 1.) {
  1249. i__3 = *n;
  1250. for (k = 1; k <= i__3; ++k) {
  1251. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
  1252. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  1253. /* L130: */
  1254. }
  1255. *scale *= scaloc;
  1256. }
  1257. /* Unpack solution vector(s) */
  1258. c__[is + js * c_dim1] = rhs[0];
  1259. f[is + js * f_dim1] = rhs[1];
  1260. /* Substitute R(I, J) and L(I, J) into remaining */
  1261. /* equation. */
  1262. if (j > p + 2) {
  1263. alpha = rhs[0];
  1264. i__3 = js - 1;
  1265. daxpy_(&i__3, &alpha, &b[js * b_dim1 + 1], &c__1, &f[
  1266. is + f_dim1], ldf);
  1267. alpha = rhs[1];
  1268. i__3 = js - 1;
  1269. daxpy_(&i__3, &alpha, &e[js * e_dim1 + 1], &c__1, &f[
  1270. is + f_dim1], ldf);
  1271. }
  1272. if (i__ < p) {
  1273. alpha = -rhs[0];
  1274. i__3 = *m - ie;
  1275. daxpy_(&i__3, &alpha, &a[is + (ie + 1) * a_dim1], lda,
  1276. &c__[ie + 1 + js * c_dim1], &c__1);
  1277. alpha = -rhs[1];
  1278. i__3 = *m - ie;
  1279. daxpy_(&i__3, &alpha, &d__[is + (ie + 1) * d_dim1],
  1280. ldd, &c__[ie + 1 + js * c_dim1], &c__1);
  1281. }
  1282. } else if (mb == 1 && nb == 2) {
  1283. /* Build a 4-by-4 system Z**T * x = RHS */
  1284. z__[0] = a[is + is * a_dim1];
  1285. z__[1] = 0.;
  1286. z__[2] = -b[js + js * b_dim1];
  1287. z__[3] = -b[jsp1 + js * b_dim1];
  1288. z__[8] = 0.;
  1289. z__[9] = a[is + is * a_dim1];
  1290. z__[10] = -b[js + jsp1 * b_dim1];
  1291. z__[11] = -b[jsp1 + jsp1 * b_dim1];
  1292. z__[16] = d__[is + is * d_dim1];
  1293. z__[17] = 0.;
  1294. z__[18] = -e[js + js * e_dim1];
  1295. z__[19] = 0.;
  1296. z__[24] = 0.;
  1297. z__[25] = d__[is + is * d_dim1];
  1298. z__[26] = -e[js + jsp1 * e_dim1];
  1299. z__[27] = -e[jsp1 + jsp1 * e_dim1];
  1300. /* Set up right hand side(s) */
  1301. rhs[0] = c__[is + js * c_dim1];
  1302. rhs[1] = c__[is + jsp1 * c_dim1];
  1303. rhs[2] = f[is + js * f_dim1];
  1304. rhs[3] = f[is + jsp1 * f_dim1];
  1305. /* Solve Z**T * x = RHS */
  1306. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  1307. if (ierr > 0) {
  1308. *info = ierr;
  1309. }
  1310. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  1311. if (scaloc != 1.) {
  1312. i__3 = *n;
  1313. for (k = 1; k <= i__3; ++k) {
  1314. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
  1315. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  1316. /* L140: */
  1317. }
  1318. *scale *= scaloc;
  1319. }
  1320. /* Unpack solution vector(s) */
  1321. c__[is + js * c_dim1] = rhs[0];
  1322. c__[is + jsp1 * c_dim1] = rhs[1];
  1323. f[is + js * f_dim1] = rhs[2];
  1324. f[is + jsp1 * f_dim1] = rhs[3];
  1325. /* Substitute R(I, J) and L(I, J) into remaining */
  1326. /* equation. */
  1327. if (j > p + 2) {
  1328. i__3 = js - 1;
  1329. daxpy_(&i__3, rhs, &b[js * b_dim1 + 1], &c__1, &f[is
  1330. + f_dim1], ldf);
  1331. i__3 = js - 1;
  1332. daxpy_(&i__3, &rhs[1], &b[jsp1 * b_dim1 + 1], &c__1, &
  1333. f[is + f_dim1], ldf);
  1334. i__3 = js - 1;
  1335. daxpy_(&i__3, &rhs[2], &e[js * e_dim1 + 1], &c__1, &f[
  1336. is + f_dim1], ldf);
  1337. i__3 = js - 1;
  1338. daxpy_(&i__3, &rhs[3], &e[jsp1 * e_dim1 + 1], &c__1, &
  1339. f[is + f_dim1], ldf);
  1340. }
  1341. if (i__ < p) {
  1342. i__3 = *m - ie;
  1343. dger_(&i__3, &nb, &c_b27, &a[is + (ie + 1) * a_dim1],
  1344. lda, rhs, &c__1, &c__[ie + 1 + js * c_dim1],
  1345. ldc);
  1346. i__3 = *m - ie;
  1347. dger_(&i__3, &nb, &c_b27, &d__[is + (ie + 1) * d_dim1]
  1348. , ldd, &rhs[2], &c__1, &c__[ie + 1 + js *
  1349. c_dim1], ldc);
  1350. }
  1351. } else if (mb == 2 && nb == 1) {
  1352. /* Build a 4-by-4 system Z**T * x = RHS */
  1353. z__[0] = a[is + is * a_dim1];
  1354. z__[1] = a[is + isp1 * a_dim1];
  1355. z__[2] = -b[js + js * b_dim1];
  1356. z__[3] = 0.;
  1357. z__[8] = a[isp1 + is * a_dim1];
  1358. z__[9] = a[isp1 + isp1 * a_dim1];
  1359. z__[10] = 0.;
  1360. z__[11] = -b[js + js * b_dim1];
  1361. z__[16] = d__[is + is * d_dim1];
  1362. z__[17] = d__[is + isp1 * d_dim1];
  1363. z__[18] = -e[js + js * e_dim1];
  1364. z__[19] = 0.;
  1365. z__[24] = 0.;
  1366. z__[25] = d__[isp1 + isp1 * d_dim1];
  1367. z__[26] = 0.;
  1368. z__[27] = -e[js + js * e_dim1];
  1369. /* Set up right hand side(s) */
  1370. rhs[0] = c__[is + js * c_dim1];
  1371. rhs[1] = c__[isp1 + js * c_dim1];
  1372. rhs[2] = f[is + js * f_dim1];
  1373. rhs[3] = f[isp1 + js * f_dim1];
  1374. /* Solve Z**T * x = RHS */
  1375. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  1376. if (ierr > 0) {
  1377. *info = ierr;
  1378. }
  1379. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  1380. if (scaloc != 1.) {
  1381. i__3 = *n;
  1382. for (k = 1; k <= i__3; ++k) {
  1383. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
  1384. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  1385. /* L150: */
  1386. }
  1387. *scale *= scaloc;
  1388. }
  1389. /* Unpack solution vector(s) */
  1390. c__[is + js * c_dim1] = rhs[0];
  1391. c__[isp1 + js * c_dim1] = rhs[1];
  1392. f[is + js * f_dim1] = rhs[2];
  1393. f[isp1 + js * f_dim1] = rhs[3];
  1394. /* Substitute R(I, J) and L(I, J) into remaining */
  1395. /* equation. */
  1396. if (j > p + 2) {
  1397. i__3 = js - 1;
  1398. dger_(&mb, &i__3, &c_b42, rhs, &c__1, &b[js * b_dim1
  1399. + 1], &c__1, &f[is + f_dim1], ldf);
  1400. i__3 = js - 1;
  1401. dger_(&mb, &i__3, &c_b42, &rhs[2], &c__1, &e[js *
  1402. e_dim1 + 1], &c__1, &f[is + f_dim1], ldf);
  1403. }
  1404. if (i__ < p) {
  1405. i__3 = *m - ie;
  1406. dgemv_("T", &mb, &i__3, &c_b27, &a[is + (ie + 1) *
  1407. a_dim1], lda, rhs, &c__1, &c_b42, &c__[ie + 1
  1408. + js * c_dim1], &c__1);
  1409. i__3 = *m - ie;
  1410. dgemv_("T", &mb, &i__3, &c_b27, &d__[is + (ie + 1) *
  1411. d_dim1], ldd, &rhs[2], &c__1, &c_b42, &c__[ie
  1412. + 1 + js * c_dim1], &c__1);
  1413. }
  1414. } else if (mb == 2 && nb == 2) {
  1415. /* Build an 8-by-8 system Z**T * x = RHS */
  1416. dlaset_("F", &c__8, &c__8, &c_b56, &c_b56, z__, &c__8);
  1417. z__[0] = a[is + is * a_dim1];
  1418. z__[1] = a[is + isp1 * a_dim1];
  1419. z__[4] = -b[js + js * b_dim1];
  1420. z__[6] = -b[jsp1 + js * b_dim1];
  1421. z__[8] = a[isp1 + is * a_dim1];
  1422. z__[9] = a[isp1 + isp1 * a_dim1];
  1423. z__[13] = -b[js + js * b_dim1];
  1424. z__[15] = -b[jsp1 + js * b_dim1];
  1425. z__[18] = a[is + is * a_dim1];
  1426. z__[19] = a[is + isp1 * a_dim1];
  1427. z__[20] = -b[js + jsp1 * b_dim1];
  1428. z__[22] = -b[jsp1 + jsp1 * b_dim1];
  1429. z__[26] = a[isp1 + is * a_dim1];
  1430. z__[27] = a[isp1 + isp1 * a_dim1];
  1431. z__[29] = -b[js + jsp1 * b_dim1];
  1432. z__[31] = -b[jsp1 + jsp1 * b_dim1];
  1433. z__[32] = d__[is + is * d_dim1];
  1434. z__[33] = d__[is + isp1 * d_dim1];
  1435. z__[36] = -e[js + js * e_dim1];
  1436. z__[41] = d__[isp1 + isp1 * d_dim1];
  1437. z__[45] = -e[js + js * e_dim1];
  1438. z__[50] = d__[is + is * d_dim1];
  1439. z__[51] = d__[is + isp1 * d_dim1];
  1440. z__[52] = -e[js + jsp1 * e_dim1];
  1441. z__[54] = -e[jsp1 + jsp1 * e_dim1];
  1442. z__[59] = d__[isp1 + isp1 * d_dim1];
  1443. z__[61] = -e[js + jsp1 * e_dim1];
  1444. z__[63] = -e[jsp1 + jsp1 * e_dim1];
  1445. /* Set up right hand side(s) */
  1446. k = 1;
  1447. ii = mb * nb + 1;
  1448. i__3 = nb - 1;
  1449. for (jj = 0; jj <= i__3; ++jj) {
  1450. dcopy_(&mb, &c__[is + (js + jj) * c_dim1], &c__1, &
  1451. rhs[k - 1], &c__1);
  1452. dcopy_(&mb, &f[is + (js + jj) * f_dim1], &c__1, &rhs[
  1453. ii - 1], &c__1);
  1454. k += mb;
  1455. ii += mb;
  1456. /* L160: */
  1457. }
  1458. /* Solve Z**T * x = RHS */
  1459. dgetc2_(&zdim, z__, &c__8, ipiv, jpiv, &ierr);
  1460. if (ierr > 0) {
  1461. *info = ierr;
  1462. }
  1463. dgesc2_(&zdim, z__, &c__8, rhs, ipiv, jpiv, &scaloc);
  1464. if (scaloc != 1.) {
  1465. i__3 = *n;
  1466. for (k = 1; k <= i__3; ++k) {
  1467. dscal_(m, &scaloc, &c__[k * c_dim1 + 1], &c__1);
  1468. dscal_(m, &scaloc, &f[k * f_dim1 + 1], &c__1);
  1469. /* L170: */
  1470. }
  1471. *scale *= scaloc;
  1472. }
  1473. /* Unpack solution vector(s) */
  1474. k = 1;
  1475. ii = mb * nb + 1;
  1476. i__3 = nb - 1;
  1477. for (jj = 0; jj <= i__3; ++jj) {
  1478. dcopy_(&mb, &rhs[k - 1], &c__1, &c__[is + (js + jj) *
  1479. c_dim1], &c__1);
  1480. dcopy_(&mb, &rhs[ii - 1], &c__1, &f[is + (js + jj) *
  1481. f_dim1], &c__1);
  1482. k += mb;
  1483. ii += mb;
  1484. /* L180: */
  1485. }
  1486. /* Substitute R(I, J) and L(I, J) into remaining */
  1487. /* equation. */
  1488. if (j > p + 2) {
  1489. i__3 = js - 1;
  1490. dgemm_("N", "T", &mb, &i__3, &nb, &c_b42, &c__[is +
  1491. js * c_dim1], ldc, &b[js * b_dim1 + 1], ldb, &
  1492. c_b42, &f[is + f_dim1], ldf);
  1493. i__3 = js - 1;
  1494. dgemm_("N", "T", &mb, &i__3, &nb, &c_b42, &f[is + js *
  1495. f_dim1], ldf, &e[js * e_dim1 + 1], lde, &
  1496. c_b42, &f[is + f_dim1], ldf);
  1497. }
  1498. if (i__ < p) {
  1499. i__3 = *m - ie;
  1500. dgemm_("T", "N", &i__3, &nb, &mb, &c_b27, &a[is + (ie
  1501. + 1) * a_dim1], lda, &c__[is + js * c_dim1],
  1502. ldc, &c_b42, &c__[ie + 1 + js * c_dim1], ldc);
  1503. i__3 = *m - ie;
  1504. dgemm_("T", "N", &i__3, &nb, &mb, &c_b27, &d__[is + (
  1505. ie + 1) * d_dim1], ldd, &f[is + js * f_dim1],
  1506. ldf, &c_b42, &c__[ie + 1 + js * c_dim1], ldc);
  1507. }
  1508. }
  1509. /* L190: */
  1510. }
  1511. /* L200: */
  1512. }
  1513. }
  1514. return 0;
  1515. /* End of DTGSY2 */
  1516. } /* dtgsy2_ */