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.

dorbdb.c 39 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270
  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 DORBDB */
  364. /* =========== DOCUMENTATION =========== */
  365. /* Online html documentation available at */
  366. /* http://www.netlib.org/lapack/explore-html/ */
  367. /* > \htmlonly */
  368. /* > Download DORBDB + dependencies */
  369. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dorbdb.
  370. f"> */
  371. /* > [TGZ]</a> */
  372. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dorbdb.
  373. f"> */
  374. /* > [ZIP]</a> */
  375. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dorbdb.
  376. f"> */
  377. /* > [TXT]</a> */
  378. /* > \endhtmlonly */
  379. /* Definition: */
  380. /* =========== */
  381. /* SUBROUTINE DORBDB( 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. /* DOUBLE PRECISION PHI( * ), THETA( * ) */
  388. /* DOUBLE PRECISION TAUP1( * ), TAUP2( * ), TAUQ1( * ), TAUQ2( * ), */
  389. /* $ WORK( * ), X11( LDX11, * ), X12( LDX12, * ), */
  390. /* $ X21( LDX21, * ), X22( LDX22, * ) */
  391. /* > \par Purpose: */
  392. /* ============= */
  393. /* > */
  394. /* > \verbatim */
  395. /* > */
  396. /* > DORBDB simultaneously bidiagonalizes the blocks of an M-by-M */
  397. /* > partitioned orthogonal matrix X: */
  398. /* > */
  399. /* > [ B11 | B12 0 0 ] */
  400. /* > [ X11 | X12 ] [ P1 | ] [ 0 | 0 -I 0 ] [ Q1 | ]**T */
  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 DORCSD */
  408. /* > for details.) */
  409. /* > */
  410. /* > The orthogonal 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 DOUBLE PRECISION array, dimension (LDX11,Q) */
  459. /* > On entry, the top-left block of the orthogonal 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 DOUBLE PRECISION array, dimension (LDX12,M-Q) */
  479. /* > On entry, the top-right block of the orthogonal 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 DOUBLE PRECISION array, dimension (LDX21,Q) */
  499. /* > On entry, the bottom-left block of the orthogonal 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 DOUBLE PRECISION array, dimension (LDX22,M-Q) */
  517. /* > On entry, the bottom-right block of the orthogonal 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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 doubleOTHERcomputational */
  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 DORCSD for details. */
  619. /* > */
  620. /* > P1, P2, Q1, and Q2 are represented as products of elementary */
  621. /* > reflectors. See DORCSD for details on generating P1, P2, Q1, and Q2 */
  622. /* > using DORGQR and DORGLQ. */
  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 dorbdb_(char *trans, char *signs, integer *m, integer *p,
  632. integer *q, doublereal *x11, integer *ldx11, doublereal *x12,
  633. integer *ldx12, doublereal *x21, integer *ldx21, doublereal *x22,
  634. integer *ldx22, doublereal *theta, doublereal *phi, doublereal *taup1,
  635. doublereal *taup2, doublereal *tauq1, doublereal *tauq2, doublereal *
  636. work, integer *lwork, integer *info)
  637. {
  638. /* System generated locals */
  639. integer x11_dim1, x11_offset, x12_dim1, x12_offset, x21_dim1, x21_offset,
  640. x22_dim1, x22_offset, i__1, i__2, i__3;
  641. doublereal d__1;
  642. /* Local variables */
  643. logical colmajor;
  644. integer lworkmin;
  645. extern doublereal dnrm2_(integer *, doublereal *, integer *);
  646. integer lworkopt, i__;
  647. extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
  648. integer *), dlarf_(char *, integer *, integer *, doublereal *,
  649. integer *, doublereal *, doublereal *, integer *, doublereal *);
  650. extern logical lsame_(char *, char *);
  651. extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *,
  652. integer *, doublereal *, integer *);
  653. doublereal z1, z2, z3, z4;
  654. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  655. logical lquery;
  656. extern /* Subroutine */ int dlarfgp_(integer *, doublereal *, doublereal *
  657. , integer *, doublereal *);
  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.;
  689. z2 = 1.;
  690. z3 = 1.;
  691. z4 = 1.;
  692. } else {
  693. z1 = 1.;
  694. z2 = -1.;
  695. z3 = 1.;
  696. z4 = -1.;
  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] = (doublereal) lworkopt;
  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. dscal_(&i__2, &z1, &x11[i__ + i__ * x11_dim1], &c__1);
  762. } else {
  763. i__2 = *p - i__ + 1;
  764. d__1 = z1 * cos(phi[i__ - 1]);
  765. dscal_(&i__2, &d__1, &x11[i__ + i__ * x11_dim1], &c__1);
  766. i__2 = *p - i__ + 1;
  767. d__1 = -z1 * z3 * z4 * sin(phi[i__ - 1]);
  768. daxpy_(&i__2, &d__1, &x12[i__ + (i__ - 1) * x12_dim1], &c__1,
  769. &x11[i__ + i__ * x11_dim1], &c__1);
  770. }
  771. if (i__ == 1) {
  772. i__2 = *m - *p - i__ + 1;
  773. dscal_(&i__2, &z2, &x21[i__ + i__ * x21_dim1], &c__1);
  774. } else {
  775. i__2 = *m - *p - i__ + 1;
  776. d__1 = z2 * cos(phi[i__ - 1]);
  777. dscal_(&i__2, &d__1, &x21[i__ + i__ * x21_dim1], &c__1);
  778. i__2 = *m - *p - i__ + 1;
  779. d__1 = -z2 * z3 * z4 * sin(phi[i__ - 1]);
  780. daxpy_(&i__2, &d__1, &x22[i__ + (i__ - 1) * x22_dim1], &c__1,
  781. &x21[i__ + i__ * x21_dim1], &c__1);
  782. }
  783. i__2 = *m - *p - i__ + 1;
  784. i__3 = *p - i__ + 1;
  785. theta[i__] = atan2(dnrm2_(&i__2, &x21[i__ + i__ * x21_dim1], &
  786. c__1), dnrm2_(&i__3, &x11[i__ + i__ * x11_dim1], &c__1));
  787. if (*p > i__) {
  788. i__2 = *p - i__ + 1;
  789. dlarfgp_(&i__2, &x11[i__ + i__ * x11_dim1], &x11[i__ + 1 +
  790. i__ * x11_dim1], &c__1, &taup1[i__]);
  791. } else if (*p == i__) {
  792. i__2 = *p - i__ + 1;
  793. dlarfgp_(&i__2, &x11[i__ + i__ * x11_dim1], &x11[i__ + i__ *
  794. x11_dim1], &c__1, &taup1[i__]);
  795. }
  796. x11[i__ + i__ * x11_dim1] = 1.;
  797. if (*m - *p > i__) {
  798. i__2 = *m - *p - i__ + 1;
  799. dlarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + 1 +
  800. i__ * x21_dim1], &c__1, &taup2[i__]);
  801. } else if (*m - *p == i__) {
  802. i__2 = *m - *p - i__ + 1;
  803. dlarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + i__ *
  804. x21_dim1], &c__1, &taup2[i__]);
  805. }
  806. x21[i__ + i__ * x21_dim1] = 1.;
  807. if (*q > i__) {
  808. i__2 = *p - i__ + 1;
  809. i__3 = *q - i__;
  810. dlarf_("L", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], &c__1, &
  811. taup1[i__], &x11[i__ + (i__ + 1) * x11_dim1], ldx11, &
  812. work[1]);
  813. }
  814. if (*m - *q + 1 > i__) {
  815. i__2 = *p - i__ + 1;
  816. i__3 = *m - *q - i__ + 1;
  817. dlarf_("L", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], &c__1, &
  818. taup1[i__], &x12[i__ + i__ * x12_dim1], ldx12, &work[
  819. 1]);
  820. }
  821. if (*q > i__) {
  822. i__2 = *m - *p - i__ + 1;
  823. i__3 = *q - i__;
  824. dlarf_("L", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], &c__1, &
  825. taup2[i__], &x21[i__ + (i__ + 1) * x21_dim1], ldx21, &
  826. work[1]);
  827. }
  828. if (*m - *q + 1 > i__) {
  829. i__2 = *m - *p - i__ + 1;
  830. i__3 = *m - *q - i__ + 1;
  831. dlarf_("L", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], &c__1, &
  832. taup2[i__], &x22[i__ + i__ * x22_dim1], ldx22, &work[
  833. 1]);
  834. }
  835. if (i__ < *q) {
  836. i__2 = *q - i__;
  837. d__1 = -z1 * z3 * sin(theta[i__]);
  838. dscal_(&i__2, &d__1, &x11[i__ + (i__ + 1) * x11_dim1], ldx11);
  839. i__2 = *q - i__;
  840. d__1 = z2 * z3 * cos(theta[i__]);
  841. daxpy_(&i__2, &d__1, &x21[i__ + (i__ + 1) * x21_dim1], ldx21,
  842. &x11[i__ + (i__ + 1) * x11_dim1], ldx11);
  843. }
  844. i__2 = *m - *q - i__ + 1;
  845. d__1 = -z1 * z4 * sin(theta[i__]);
  846. dscal_(&i__2, &d__1, &x12[i__ + i__ * x12_dim1], ldx12);
  847. i__2 = *m - *q - i__ + 1;
  848. d__1 = z2 * z4 * cos(theta[i__]);
  849. daxpy_(&i__2, &d__1, &x22[i__ + i__ * x22_dim1], ldx22, &x12[i__
  850. + i__ * x12_dim1], ldx12);
  851. if (i__ < *q) {
  852. i__2 = *q - i__;
  853. i__3 = *m - *q - i__ + 1;
  854. phi[i__] = atan2(dnrm2_(&i__2, &x11[i__ + (i__ + 1) *
  855. x11_dim1], ldx11), dnrm2_(&i__3, &x12[i__ + i__ *
  856. x12_dim1], ldx12));
  857. }
  858. if (i__ < *q) {
  859. if (*q - i__ == 1) {
  860. i__2 = *q - i__;
  861. dlarfgp_(&i__2, &x11[i__ + (i__ + 1) * x11_dim1], &x11[
  862. i__ + (i__ + 1) * x11_dim1], ldx11, &tauq1[i__]);
  863. } else {
  864. i__2 = *q - i__;
  865. dlarfgp_(&i__2, &x11[i__ + (i__ + 1) * x11_dim1], &x11[
  866. i__ + (i__ + 2) * x11_dim1], ldx11, &tauq1[i__]);
  867. }
  868. x11[i__ + (i__ + 1) * x11_dim1] = 1.;
  869. }
  870. if (*q + i__ - 1 < *m) {
  871. if (*m - *q == i__) {
  872. i__2 = *m - *q - i__ + 1;
  873. dlarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ +
  874. i__ * x12_dim1], ldx12, &tauq2[i__]);
  875. } else {
  876. i__2 = *m - *q - i__ + 1;
  877. dlarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + (
  878. i__ + 1) * x12_dim1], ldx12, &tauq2[i__]);
  879. }
  880. }
  881. x12[i__ + i__ * x12_dim1] = 1.;
  882. if (i__ < *q) {
  883. i__2 = *p - i__;
  884. i__3 = *q - i__;
  885. dlarf_("R", &i__2, &i__3, &x11[i__ + (i__ + 1) * x11_dim1],
  886. ldx11, &tauq1[i__], &x11[i__ + 1 + (i__ + 1) *
  887. x11_dim1], ldx11, &work[1]);
  888. i__2 = *m - *p - i__;
  889. i__3 = *q - i__;
  890. dlarf_("R", &i__2, &i__3, &x11[i__ + (i__ + 1) * x11_dim1],
  891. ldx11, &tauq1[i__], &x21[i__ + 1 + (i__ + 1) *
  892. x21_dim1], ldx21, &work[1]);
  893. }
  894. if (*p > i__) {
  895. i__2 = *p - i__;
  896. i__3 = *m - *q - i__ + 1;
  897. dlarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  898. tauq2[i__], &x12[i__ + 1 + i__ * x12_dim1], ldx12, &
  899. work[1]);
  900. }
  901. if (*m - *p > i__) {
  902. i__2 = *m - *p - i__;
  903. i__3 = *m - *q - i__ + 1;
  904. dlarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  905. tauq2[i__], &x22[i__ + 1 + i__ * x22_dim1], ldx22, &
  906. work[1]);
  907. }
  908. }
  909. /* Reduce columns Q + 1, ..., P of X12, X22 */
  910. i__1 = *p;
  911. for (i__ = *q + 1; i__ <= i__1; ++i__) {
  912. i__2 = *m - *q - i__ + 1;
  913. d__1 = -z1 * z4;
  914. dscal_(&i__2, &d__1, &x12[i__ + i__ * x12_dim1], ldx12);
  915. if (i__ >= *m - *q) {
  916. i__2 = *m - *q - i__ + 1;
  917. dlarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + i__ *
  918. x12_dim1], ldx12, &tauq2[i__]);
  919. } else {
  920. i__2 = *m - *q - i__ + 1;
  921. dlarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + (i__ +
  922. 1) * x12_dim1], ldx12, &tauq2[i__]);
  923. }
  924. x12[i__ + i__ * x12_dim1] = 1.;
  925. if (*p > i__) {
  926. i__2 = *p - i__;
  927. i__3 = *m - *q - i__ + 1;
  928. dlarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  929. tauq2[i__], &x12[i__ + 1 + i__ * x12_dim1], ldx12, &
  930. work[1]);
  931. }
  932. if (*m - *p - *q >= 1) {
  933. i__2 = *m - *p - *q;
  934. i__3 = *m - *q - i__ + 1;
  935. dlarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  936. tauq2[i__], &x22[*q + 1 + i__ * x22_dim1], ldx22, &
  937. work[1]);
  938. }
  939. }
  940. /* Reduce columns P + 1, ..., M - Q of X12, X22 */
  941. i__1 = *m - *p - *q;
  942. for (i__ = 1; i__ <= i__1; ++i__) {
  943. i__2 = *m - *p - *q - i__ + 1;
  944. d__1 = z2 * z4;
  945. dscal_(&i__2, &d__1, &x22[*q + i__ + (*p + i__) * x22_dim1],
  946. ldx22);
  947. if (i__ == *m - *p - *q) {
  948. i__2 = *m - *p - *q - i__ + 1;
  949. dlarfgp_(&i__2, &x22[*q + i__ + (*p + i__) * x22_dim1], &x22[*
  950. q + i__ + (*p + i__) * x22_dim1], ldx22, &tauq2[*p +
  951. i__]);
  952. } else {
  953. i__2 = *m - *p - *q - i__ + 1;
  954. dlarfgp_(&i__2, &x22[*q + i__ + (*p + i__) * x22_dim1], &x22[*
  955. q + i__ + (*p + i__ + 1) * x22_dim1], ldx22, &tauq2[*
  956. p + i__]);
  957. }
  958. x22[*q + i__ + (*p + i__) * x22_dim1] = 1.;
  959. if (i__ < *m - *p - *q) {
  960. i__2 = *m - *p - *q - i__;
  961. i__3 = *m - *p - *q - i__ + 1;
  962. dlarf_("R", &i__2, &i__3, &x22[*q + i__ + (*p + i__) *
  963. x22_dim1], ldx22, &tauq2[*p + i__], &x22[*q + i__ + 1
  964. + (*p + i__) * x22_dim1], ldx22, &work[1]);
  965. }
  966. }
  967. } else {
  968. /* Reduce columns 1, ..., Q of X11, X12, X21, X22 */
  969. i__1 = *q;
  970. for (i__ = 1; i__ <= i__1; ++i__) {
  971. if (i__ == 1) {
  972. i__2 = *p - i__ + 1;
  973. dscal_(&i__2, &z1, &x11[i__ + i__ * x11_dim1], ldx11);
  974. } else {
  975. i__2 = *p - i__ + 1;
  976. d__1 = z1 * cos(phi[i__ - 1]);
  977. dscal_(&i__2, &d__1, &x11[i__ + i__ * x11_dim1], ldx11);
  978. i__2 = *p - i__ + 1;
  979. d__1 = -z1 * z3 * z4 * sin(phi[i__ - 1]);
  980. daxpy_(&i__2, &d__1, &x12[i__ - 1 + i__ * x12_dim1], ldx12, &
  981. x11[i__ + i__ * x11_dim1], ldx11);
  982. }
  983. if (i__ == 1) {
  984. i__2 = *m - *p - i__ + 1;
  985. dscal_(&i__2, &z2, &x21[i__ + i__ * x21_dim1], ldx21);
  986. } else {
  987. i__2 = *m - *p - i__ + 1;
  988. d__1 = z2 * cos(phi[i__ - 1]);
  989. dscal_(&i__2, &d__1, &x21[i__ + i__ * x21_dim1], ldx21);
  990. i__2 = *m - *p - i__ + 1;
  991. d__1 = -z2 * z3 * z4 * sin(phi[i__ - 1]);
  992. daxpy_(&i__2, &d__1, &x22[i__ - 1 + i__ * x22_dim1], ldx22, &
  993. x21[i__ + i__ * x21_dim1], ldx21);
  994. }
  995. i__2 = *m - *p - i__ + 1;
  996. i__3 = *p - i__ + 1;
  997. theta[i__] = atan2(dnrm2_(&i__2, &x21[i__ + i__ * x21_dim1],
  998. ldx21), dnrm2_(&i__3, &x11[i__ + i__ * x11_dim1], ldx11));
  999. i__2 = *p - i__ + 1;
  1000. dlarfgp_(&i__2, &x11[i__ + i__ * x11_dim1], &x11[i__ + (i__ + 1) *
  1001. x11_dim1], ldx11, &taup1[i__]);
  1002. x11[i__ + i__ * x11_dim1] = 1.;
  1003. if (i__ == *m - *p) {
  1004. i__2 = *m - *p - i__ + 1;
  1005. dlarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + i__ *
  1006. x21_dim1], ldx21, &taup2[i__]);
  1007. } else {
  1008. i__2 = *m - *p - i__ + 1;
  1009. dlarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + (i__ +
  1010. 1) * x21_dim1], ldx21, &taup2[i__]);
  1011. }
  1012. x21[i__ + i__ * x21_dim1] = 1.;
  1013. if (*q > i__) {
  1014. i__2 = *q - i__;
  1015. i__3 = *p - i__ + 1;
  1016. dlarf_("R", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], ldx11, &
  1017. taup1[i__], &x11[i__ + 1 + i__ * x11_dim1], ldx11, &
  1018. work[1]);
  1019. }
  1020. if (*m - *q + 1 > i__) {
  1021. i__2 = *m - *q - i__ + 1;
  1022. i__3 = *p - i__ + 1;
  1023. dlarf_("R", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], ldx11, &
  1024. taup1[i__], &x12[i__ + i__ * x12_dim1], ldx12, &work[
  1025. 1]);
  1026. }
  1027. if (*q > i__) {
  1028. i__2 = *q - i__;
  1029. i__3 = *m - *p - i__ + 1;
  1030. dlarf_("R", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], ldx21, &
  1031. taup2[i__], &x21[i__ + 1 + i__ * x21_dim1], ldx21, &
  1032. work[1]);
  1033. }
  1034. if (*m - *q + 1 > i__) {
  1035. i__2 = *m - *q - i__ + 1;
  1036. i__3 = *m - *p - i__ + 1;
  1037. dlarf_("R", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], ldx21, &
  1038. taup2[i__], &x22[i__ + i__ * x22_dim1], ldx22, &work[
  1039. 1]);
  1040. }
  1041. if (i__ < *q) {
  1042. i__2 = *q - i__;
  1043. d__1 = -z1 * z3 * sin(theta[i__]);
  1044. dscal_(&i__2, &d__1, &x11[i__ + 1 + i__ * x11_dim1], &c__1);
  1045. i__2 = *q - i__;
  1046. d__1 = z2 * z3 * cos(theta[i__]);
  1047. daxpy_(&i__2, &d__1, &x21[i__ + 1 + i__ * x21_dim1], &c__1, &
  1048. x11[i__ + 1 + i__ * x11_dim1], &c__1);
  1049. }
  1050. i__2 = *m - *q - i__ + 1;
  1051. d__1 = -z1 * z4 * sin(theta[i__]);
  1052. dscal_(&i__2, &d__1, &x12[i__ + i__ * x12_dim1], &c__1);
  1053. i__2 = *m - *q - i__ + 1;
  1054. d__1 = z2 * z4 * cos(theta[i__]);
  1055. daxpy_(&i__2, &d__1, &x22[i__ + i__ * x22_dim1], &c__1, &x12[i__
  1056. + i__ * x12_dim1], &c__1);
  1057. if (i__ < *q) {
  1058. i__2 = *q - i__;
  1059. i__3 = *m - *q - i__ + 1;
  1060. phi[i__] = atan2(dnrm2_(&i__2, &x11[i__ + 1 + i__ * x11_dim1],
  1061. &c__1), dnrm2_(&i__3, &x12[i__ + i__ * x12_dim1], &
  1062. c__1));
  1063. }
  1064. if (i__ < *q) {
  1065. if (*q - i__ == 1) {
  1066. i__2 = *q - i__;
  1067. dlarfgp_(&i__2, &x11[i__ + 1 + i__ * x11_dim1], &x11[i__
  1068. + 1 + i__ * x11_dim1], &c__1, &tauq1[i__]);
  1069. } else {
  1070. i__2 = *q - i__;
  1071. dlarfgp_(&i__2, &x11[i__ + 1 + i__ * x11_dim1], &x11[i__
  1072. + 2 + i__ * x11_dim1], &c__1, &tauq1[i__]);
  1073. }
  1074. x11[i__ + 1 + i__ * x11_dim1] = 1.;
  1075. }
  1076. if (*m - *q > i__) {
  1077. i__2 = *m - *q - i__ + 1;
  1078. dlarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + 1 +
  1079. i__ * x12_dim1], &c__1, &tauq2[i__]);
  1080. } else {
  1081. i__2 = *m - *q - i__ + 1;
  1082. dlarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + i__ *
  1083. x12_dim1], &c__1, &tauq2[i__]);
  1084. }
  1085. x12[i__ + i__ * x12_dim1] = 1.;
  1086. if (i__ < *q) {
  1087. i__2 = *q - i__;
  1088. i__3 = *p - i__;
  1089. dlarf_("L", &i__2, &i__3, &x11[i__ + 1 + i__ * x11_dim1], &
  1090. c__1, &tauq1[i__], &x11[i__ + 1 + (i__ + 1) *
  1091. x11_dim1], ldx11, &work[1]);
  1092. i__2 = *q - i__;
  1093. i__3 = *m - *p - i__;
  1094. dlarf_("L", &i__2, &i__3, &x11[i__ + 1 + i__ * x11_dim1], &
  1095. c__1, &tauq1[i__], &x21[i__ + 1 + (i__ + 1) *
  1096. x21_dim1], ldx21, &work[1]);
  1097. }
  1098. i__2 = *m - *q - i__ + 1;
  1099. i__3 = *p - i__;
  1100. dlarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1101. tauq2[i__], &x12[i__ + (i__ + 1) * x12_dim1], ldx12, &
  1102. work[1]);
  1103. if (*m - *p - i__ > 0) {
  1104. i__2 = *m - *q - i__ + 1;
  1105. i__3 = *m - *p - i__;
  1106. dlarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1107. tauq2[i__], &x22[i__ + (i__ + 1) * x22_dim1], ldx22, &
  1108. work[1]);
  1109. }
  1110. }
  1111. /* Reduce columns Q + 1, ..., P of X12, X22 */
  1112. i__1 = *p;
  1113. for (i__ = *q + 1; i__ <= i__1; ++i__) {
  1114. i__2 = *m - *q - i__ + 1;
  1115. d__1 = -z1 * z4;
  1116. dscal_(&i__2, &d__1, &x12[i__ + i__ * x12_dim1], &c__1);
  1117. i__2 = *m - *q - i__ + 1;
  1118. dlarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + 1 + i__ *
  1119. x12_dim1], &c__1, &tauq2[i__]);
  1120. x12[i__ + i__ * x12_dim1] = 1.;
  1121. if (*p > i__) {
  1122. i__2 = *m - *q - i__ + 1;
  1123. i__3 = *p - i__;
  1124. dlarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1125. tauq2[i__], &x12[i__ + (i__ + 1) * x12_dim1], ldx12, &
  1126. work[1]);
  1127. }
  1128. if (*m - *p - *q >= 1) {
  1129. i__2 = *m - *q - i__ + 1;
  1130. i__3 = *m - *p - *q;
  1131. dlarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1132. tauq2[i__], &x22[i__ + (*q + 1) * x22_dim1], ldx22, &
  1133. work[1]);
  1134. }
  1135. }
  1136. /* Reduce columns P + 1, ..., M - Q of X12, X22 */
  1137. i__1 = *m - *p - *q;
  1138. for (i__ = 1; i__ <= i__1; ++i__) {
  1139. i__2 = *m - *p - *q - i__ + 1;
  1140. d__1 = z2 * z4;
  1141. dscal_(&i__2, &d__1, &x22[*p + i__ + (*q + i__) * x22_dim1], &
  1142. c__1);
  1143. if (*m - *p - *q == i__) {
  1144. i__2 = *m - *p - *q - i__ + 1;
  1145. dlarfgp_(&i__2, &x22[*p + i__ + (*q + i__) * x22_dim1], &x22[*
  1146. p + i__ + (*q + i__) * x22_dim1], &c__1, &tauq2[*p +
  1147. i__]);
  1148. } else {
  1149. i__2 = *m - *p - *q - i__ + 1;
  1150. dlarfgp_(&i__2, &x22[*p + i__ + (*q + i__) * x22_dim1], &x22[*
  1151. p + i__ + 1 + (*q + i__) * x22_dim1], &c__1, &tauq2[*
  1152. p + i__]);
  1153. i__2 = *m - *p - *q - i__ + 1;
  1154. i__3 = *m - *p - *q - i__;
  1155. dlarf_("L", &i__2, &i__3, &x22[*p + i__ + (*q + i__) *
  1156. x22_dim1], &c__1, &tauq2[*p + i__], &x22[*p + i__ + (*
  1157. q + i__ + 1) * x22_dim1], ldx22, &work[1]);
  1158. }
  1159. x22[*p + i__ + (*q + i__) * x22_dim1] = 1.;
  1160. }
  1161. }
  1162. return 0;
  1163. /* End of DORBDB */
  1164. } /* dorbdb_ */