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.

sorbdb.c 42 kB

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