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

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