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.

cunbdb.c 40 kB

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