You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sorbdb.c 38 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 SORBDB */
  364. /* =========== DOCUMENTATION =========== */
  365. /* Online html documentation available at */
  366. /* http://www.netlib.org/lapack/explore-html/ */
  367. /* > \htmlonly */
  368. /* > Download SORBDB + dependencies */
  369. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sorbdb.
  370. f"> */
  371. /* > [TGZ]</a> */
  372. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sorbdb.
  373. f"> */
  374. /* > [ZIP]</a> */
  375. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sorbdb.
  376. f"> */
  377. /* > [TXT]</a> */
  378. /* > \endhtmlonly */
  379. /* Definition: */
  380. /* =========== */
  381. /* SUBROUTINE SORBDB( TRANS, SIGNS, M, P, Q, X11, LDX11, X12, LDX12, */
  382. /* X21, LDX21, X22, LDX22, THETA, PHI, TAUP1, */
  383. /* TAUP2, TAUQ1, TAUQ2, WORK, LWORK, INFO ) */
  384. /* CHARACTER SIGNS, TRANS */
  385. /* INTEGER INFO, LDX11, LDX12, LDX21, LDX22, LWORK, M, P, */
  386. /* $ Q */
  387. /* REAL PHI( * ), THETA( * ) */
  388. /* REAL TAUP1( * ), TAUP2( * ), TAUQ1( * ), TAUQ2( * ), */
  389. /* $ WORK( * ), X11( LDX11, * ), X12( LDX12, * ), */
  390. /* $ X21( LDX21, * ), X22( LDX22, * ) */
  391. /* > \par Purpose: */
  392. /* ============= */
  393. /* > */
  394. /* > \verbatim */
  395. /* > */
  396. /* > SORBDB 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 SORCSD */
  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 REAL 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 REAL 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 REAL 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 REAL 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 REAL array, dimension (Q) */
  537. /* > The entries of the bidiagonal blocks B11, B12, B21, B22 can */
  538. /* > be computed from the angles THETA and PHI. See Further */
  539. /* > Details. */
  540. /* > \endverbatim */
  541. /* > */
  542. /* > \param[out] PHI */
  543. /* > \verbatim */
  544. /* > PHI is REAL array, dimension (Q-1) */
  545. /* > The entries of the bidiagonal blocks B11, B12, B21, B22 can */
  546. /* > be computed from the angles THETA and PHI. See Further */
  547. /* > Details. */
  548. /* > \endverbatim */
  549. /* > */
  550. /* > \param[out] TAUP1 */
  551. /* > \verbatim */
  552. /* > TAUP1 is REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 realOTHERcomputational */
  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 SORCSD for details. */
  619. /* > */
  620. /* > P1, P2, Q1, and Q2 are represented as products of elementary */
  621. /* > reflectors. See SORCSD for details on generating P1, P2, Q1, and Q2 */
  622. /* > using SORGQR and SORGLQ. */
  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 sorbdb_(char *trans, char *signs, integer *m, integer *p,
  632. integer *q, real *x11, integer *ldx11, real *x12, integer *ldx12,
  633. real *x21, integer *ldx21, real *x22, integer *ldx22, real *theta,
  634. real *phi, real *taup1, real *taup2, real *tauq1, real *tauq2, real *
  635. work, integer *lwork, integer *info)
  636. {
  637. /* System generated locals */
  638. integer x11_dim1, x11_offset, x12_dim1, x12_offset, x21_dim1, x21_offset,
  639. x22_dim1, x22_offset, i__1, i__2, i__3;
  640. real r__1;
  641. /* Local variables */
  642. logical colmajor;
  643. integer lworkmin, lworkopt;
  644. extern real snrm2_(integer *, real *, integer *);
  645. integer i__;
  646. extern logical lsame_(char *, char *);
  647. extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *),
  648. slarf_(char *, integer *, integer *, real *, integer *, real *,
  649. real *, integer *, real *), saxpy_(integer *, real *,
  650. real *, integer *, real *, integer *);
  651. real z1, z2, z3, z4;
  652. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  653. logical lquery;
  654. extern /* Subroutine */ int slarfgp_(integer *, real *, real *, integer *,
  655. real *);
  656. /* -- LAPACK computational routine (version 3.7.0) -- */
  657. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  658. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  659. /* December 2016 */
  660. /* ==================================================================== */
  661. /* Test input arguments */
  662. /* Parameter adjustments */
  663. x11_dim1 = *ldx11;
  664. x11_offset = 1 + x11_dim1 * 1;
  665. x11 -= x11_offset;
  666. x12_dim1 = *ldx12;
  667. x12_offset = 1 + x12_dim1 * 1;
  668. x12 -= x12_offset;
  669. x21_dim1 = *ldx21;
  670. x21_offset = 1 + x21_dim1 * 1;
  671. x21 -= x21_offset;
  672. x22_dim1 = *ldx22;
  673. x22_offset = 1 + x22_dim1 * 1;
  674. x22 -= x22_offset;
  675. --theta;
  676. --phi;
  677. --taup1;
  678. --taup2;
  679. --tauq1;
  680. --tauq2;
  681. --work;
  682. /* Function Body */
  683. *info = 0;
  684. colmajor = ! lsame_(trans, "T");
  685. if (! lsame_(signs, "O")) {
  686. z1 = 1.f;
  687. z2 = 1.f;
  688. z3 = 1.f;
  689. z4 = 1.f;
  690. } else {
  691. z1 = 1.f;
  692. z2 = -1.f;
  693. z3 = 1.f;
  694. z4 = -1.f;
  695. }
  696. lquery = *lwork == -1;
  697. if (*m < 0) {
  698. *info = -3;
  699. } else if (*p < 0 || *p > *m) {
  700. *info = -4;
  701. } else if (*q < 0 || *q > *p || *q > *m - *p || *q > *m - *q) {
  702. *info = -5;
  703. } else if (colmajor && *ldx11 < f2cmax(1,*p)) {
  704. *info = -7;
  705. } else if (! colmajor && *ldx11 < f2cmax(1,*q)) {
  706. *info = -7;
  707. } else if (colmajor && *ldx12 < f2cmax(1,*p)) {
  708. *info = -9;
  709. } else /* if(complicated condition) */ {
  710. /* Computing MAX */
  711. i__1 = 1, i__2 = *m - *q;
  712. if (! colmajor && *ldx12 < f2cmax(i__1,i__2)) {
  713. *info = -9;
  714. } else /* if(complicated condition) */ {
  715. /* Computing MAX */
  716. i__1 = 1, i__2 = *m - *p;
  717. if (colmajor && *ldx21 < f2cmax(i__1,i__2)) {
  718. *info = -11;
  719. } else if (! colmajor && *ldx21 < f2cmax(1,*q)) {
  720. *info = -11;
  721. } else /* if(complicated condition) */ {
  722. /* Computing MAX */
  723. i__1 = 1, i__2 = *m - *p;
  724. if (colmajor && *ldx22 < f2cmax(i__1,i__2)) {
  725. *info = -13;
  726. } else /* if(complicated condition) */ {
  727. /* Computing MAX */
  728. i__1 = 1, i__2 = *m - *q;
  729. if (! colmajor && *ldx22 < f2cmax(i__1,i__2)) {
  730. *info = -13;
  731. }
  732. }
  733. }
  734. }
  735. }
  736. /* Compute workspace */
  737. if (*info == 0) {
  738. lworkopt = *m - *q;
  739. lworkmin = *m - *q;
  740. work[1] = (real) lworkopt;
  741. if (*lwork < lworkmin && ! lquery) {
  742. *info = -21;
  743. }
  744. }
  745. if (*info != 0) {
  746. i__1 = -(*info);
  747. xerbla_("xORBDB", &i__1, (ftnlen)6);
  748. return 0;
  749. } else if (lquery) {
  750. return 0;
  751. }
  752. /* Handle column-major and row-major separately */
  753. if (colmajor) {
  754. /* Reduce columns 1, ..., Q of X11, X12, X21, and X22 */
  755. i__1 = *q;
  756. for (i__ = 1; i__ <= i__1; ++i__) {
  757. if (i__ == 1) {
  758. i__2 = *p - i__ + 1;
  759. sscal_(&i__2, &z1, &x11[i__ + i__ * x11_dim1], &c__1);
  760. } else {
  761. i__2 = *p - i__ + 1;
  762. r__1 = z1 * cos(phi[i__ - 1]);
  763. sscal_(&i__2, &r__1, &x11[i__ + i__ * x11_dim1], &c__1);
  764. i__2 = *p - i__ + 1;
  765. r__1 = -z1 * z3 * z4 * sin(phi[i__ - 1]);
  766. saxpy_(&i__2, &r__1, &x12[i__ + (i__ - 1) * x12_dim1], &c__1,
  767. &x11[i__ + i__ * x11_dim1], &c__1);
  768. }
  769. if (i__ == 1) {
  770. i__2 = *m - *p - i__ + 1;
  771. sscal_(&i__2, &z2, &x21[i__ + i__ * x21_dim1], &c__1);
  772. } else {
  773. i__2 = *m - *p - i__ + 1;
  774. r__1 = z2 * cos(phi[i__ - 1]);
  775. sscal_(&i__2, &r__1, &x21[i__ + i__ * x21_dim1], &c__1);
  776. i__2 = *m - *p - i__ + 1;
  777. r__1 = -z2 * z3 * z4 * sin(phi[i__ - 1]);
  778. saxpy_(&i__2, &r__1, &x22[i__ + (i__ - 1) * x22_dim1], &c__1,
  779. &x21[i__ + i__ * x21_dim1], &c__1);
  780. }
  781. i__2 = *m - *p - i__ + 1;
  782. i__3 = *p - i__ + 1;
  783. theta[i__] = atan2(snrm2_(&i__2, &x21[i__ + i__ * x21_dim1], &
  784. c__1), snrm2_(&i__3, &x11[i__ + i__ * x11_dim1], &c__1));
  785. if (*p > i__) {
  786. i__2 = *p - i__ + 1;
  787. slarfgp_(&i__2, &x11[i__ + i__ * x11_dim1], &x11[i__ + 1 +
  788. i__ * x11_dim1], &c__1, &taup1[i__]);
  789. } else if (*p == i__) {
  790. i__2 = *p - i__ + 1;
  791. slarfgp_(&i__2, &x11[i__ + i__ * x11_dim1], &x11[i__ + i__ *
  792. x11_dim1], &c__1, &taup1[i__]);
  793. }
  794. x11[i__ + i__ * x11_dim1] = 1.f;
  795. if (*m - *p > i__) {
  796. i__2 = *m - *p - i__ + 1;
  797. slarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + 1 +
  798. i__ * x21_dim1], &c__1, &taup2[i__]);
  799. } else if (*m - *p == i__) {
  800. i__2 = *m - *p - i__ + 1;
  801. slarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + i__ *
  802. x21_dim1], &c__1, &taup2[i__]);
  803. }
  804. x21[i__ + i__ * x21_dim1] = 1.f;
  805. if (*q > i__) {
  806. i__2 = *p - i__ + 1;
  807. i__3 = *q - i__;
  808. slarf_("L", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], &c__1, &
  809. taup1[i__], &x11[i__ + (i__ + 1) * x11_dim1], ldx11, &
  810. work[1]);
  811. }
  812. if (*m - *q + 1 > i__) {
  813. i__2 = *p - i__ + 1;
  814. i__3 = *m - *q - i__ + 1;
  815. slarf_("L", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], &c__1, &
  816. taup1[i__], &x12[i__ + i__ * x12_dim1], ldx12, &work[
  817. 1]);
  818. }
  819. if (*q > i__) {
  820. i__2 = *m - *p - i__ + 1;
  821. i__3 = *q - i__;
  822. slarf_("L", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], &c__1, &
  823. taup2[i__], &x21[i__ + (i__ + 1) * x21_dim1], ldx21, &
  824. work[1]);
  825. }
  826. if (*m - *q + 1 > i__) {
  827. i__2 = *m - *p - i__ + 1;
  828. i__3 = *m - *q - i__ + 1;
  829. slarf_("L", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], &c__1, &
  830. taup2[i__], &x22[i__ + i__ * x22_dim1], ldx22, &work[
  831. 1]);
  832. }
  833. if (i__ < *q) {
  834. i__2 = *q - i__;
  835. r__1 = -z1 * z3 * sin(theta[i__]);
  836. sscal_(&i__2, &r__1, &x11[i__ + (i__ + 1) * x11_dim1], ldx11);
  837. i__2 = *q - i__;
  838. r__1 = z2 * z3 * cos(theta[i__]);
  839. saxpy_(&i__2, &r__1, &x21[i__ + (i__ + 1) * x21_dim1], ldx21,
  840. &x11[i__ + (i__ + 1) * x11_dim1], ldx11);
  841. }
  842. i__2 = *m - *q - i__ + 1;
  843. r__1 = -z1 * z4 * sin(theta[i__]);
  844. sscal_(&i__2, &r__1, &x12[i__ + i__ * x12_dim1], ldx12);
  845. i__2 = *m - *q - i__ + 1;
  846. r__1 = z2 * z4 * cos(theta[i__]);
  847. saxpy_(&i__2, &r__1, &x22[i__ + i__ * x22_dim1], ldx22, &x12[i__
  848. + i__ * x12_dim1], ldx12);
  849. if (i__ < *q) {
  850. i__2 = *q - i__;
  851. i__3 = *m - *q - i__ + 1;
  852. phi[i__] = atan2(snrm2_(&i__2, &x11[i__ + (i__ + 1) *
  853. x11_dim1], ldx11), snrm2_(&i__3, &x12[i__ + i__ *
  854. x12_dim1], ldx12));
  855. }
  856. if (i__ < *q) {
  857. if (*q - i__ == 1) {
  858. i__2 = *q - i__;
  859. slarfgp_(&i__2, &x11[i__ + (i__ + 1) * x11_dim1], &x11[
  860. i__ + (i__ + 1) * x11_dim1], ldx11, &tauq1[i__]);
  861. } else {
  862. i__2 = *q - i__;
  863. slarfgp_(&i__2, &x11[i__ + (i__ + 1) * x11_dim1], &x11[
  864. i__ + (i__ + 2) * x11_dim1], ldx11, &tauq1[i__]);
  865. }
  866. x11[i__ + (i__ + 1) * x11_dim1] = 1.f;
  867. }
  868. if (*q + i__ - 1 < *m) {
  869. if (*m - *q == i__) {
  870. i__2 = *m - *q - i__ + 1;
  871. slarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ +
  872. i__ * x12_dim1], ldx12, &tauq2[i__]);
  873. } else {
  874. i__2 = *m - *q - i__ + 1;
  875. slarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + (
  876. i__ + 1) * x12_dim1], ldx12, &tauq2[i__]);
  877. }
  878. }
  879. x12[i__ + i__ * x12_dim1] = 1.f;
  880. if (i__ < *q) {
  881. i__2 = *p - i__;
  882. i__3 = *q - i__;
  883. slarf_("R", &i__2, &i__3, &x11[i__ + (i__ + 1) * x11_dim1],
  884. ldx11, &tauq1[i__], &x11[i__ + 1 + (i__ + 1) *
  885. x11_dim1], ldx11, &work[1]);
  886. i__2 = *m - *p - i__;
  887. i__3 = *q - i__;
  888. slarf_("R", &i__2, &i__3, &x11[i__ + (i__ + 1) * x11_dim1],
  889. ldx11, &tauq1[i__], &x21[i__ + 1 + (i__ + 1) *
  890. x21_dim1], ldx21, &work[1]);
  891. }
  892. if (*p > i__) {
  893. i__2 = *p - i__;
  894. i__3 = *m - *q - i__ + 1;
  895. slarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  896. tauq2[i__], &x12[i__ + 1 + i__ * x12_dim1], ldx12, &
  897. work[1]);
  898. }
  899. if (*m - *p > i__) {
  900. i__2 = *m - *p - i__;
  901. i__3 = *m - *q - i__ + 1;
  902. slarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  903. tauq2[i__], &x22[i__ + 1 + i__ * x22_dim1], ldx22, &
  904. work[1]);
  905. }
  906. }
  907. /* Reduce columns Q + 1, ..., P of X12, X22 */
  908. i__1 = *p;
  909. for (i__ = *q + 1; i__ <= i__1; ++i__) {
  910. i__2 = *m - *q - i__ + 1;
  911. r__1 = -z1 * z4;
  912. sscal_(&i__2, &r__1, &x12[i__ + i__ * x12_dim1], ldx12);
  913. if (i__ >= *m - *q) {
  914. i__2 = *m - *q - i__ + 1;
  915. slarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + i__ *
  916. x12_dim1], ldx12, &tauq2[i__]);
  917. } else {
  918. i__2 = *m - *q - i__ + 1;
  919. slarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + (i__ +
  920. 1) * x12_dim1], ldx12, &tauq2[i__]);
  921. }
  922. x12[i__ + i__ * x12_dim1] = 1.f;
  923. if (*p > i__) {
  924. i__2 = *p - i__;
  925. i__3 = *m - *q - i__ + 1;
  926. slarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  927. tauq2[i__], &x12[i__ + 1 + i__ * x12_dim1], ldx12, &
  928. work[1]);
  929. }
  930. if (*m - *p - *q >= 1) {
  931. i__2 = *m - *p - *q;
  932. i__3 = *m - *q - i__ + 1;
  933. slarf_("R", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], ldx12, &
  934. tauq2[i__], &x22[*q + 1 + i__ * x22_dim1], ldx22, &
  935. work[1]);
  936. }
  937. }
  938. /* Reduce columns P + 1, ..., M - Q of X12, X22 */
  939. i__1 = *m - *p - *q;
  940. for (i__ = 1; i__ <= i__1; ++i__) {
  941. i__2 = *m - *p - *q - i__ + 1;
  942. r__1 = z2 * z4;
  943. sscal_(&i__2, &r__1, &x22[*q + i__ + (*p + i__) * x22_dim1],
  944. ldx22);
  945. if (i__ == *m - *p - *q) {
  946. i__2 = *m - *p - *q - i__ + 1;
  947. slarfgp_(&i__2, &x22[*q + i__ + (*p + i__) * x22_dim1], &x22[*
  948. q + i__ + (*p + i__) * x22_dim1], ldx22, &tauq2[*p +
  949. i__]);
  950. } else {
  951. i__2 = *m - *p - *q - i__ + 1;
  952. slarfgp_(&i__2, &x22[*q + i__ + (*p + i__) * x22_dim1], &x22[*
  953. q + i__ + (*p + i__ + 1) * x22_dim1], ldx22, &tauq2[*
  954. p + i__]);
  955. }
  956. x22[*q + i__ + (*p + i__) * x22_dim1] = 1.f;
  957. if (i__ < *m - *p - *q) {
  958. i__2 = *m - *p - *q - i__;
  959. i__3 = *m - *p - *q - i__ + 1;
  960. slarf_("R", &i__2, &i__3, &x22[*q + i__ + (*p + i__) *
  961. x22_dim1], ldx22, &tauq2[*p + i__], &x22[*q + i__ + 1
  962. + (*p + i__) * x22_dim1], ldx22, &work[1]);
  963. }
  964. }
  965. } else {
  966. /* Reduce columns 1, ..., Q of X11, X12, X21, X22 */
  967. i__1 = *q;
  968. for (i__ = 1; i__ <= i__1; ++i__) {
  969. if (i__ == 1) {
  970. i__2 = *p - i__ + 1;
  971. sscal_(&i__2, &z1, &x11[i__ + i__ * x11_dim1], ldx11);
  972. } else {
  973. i__2 = *p - i__ + 1;
  974. r__1 = z1 * cos(phi[i__ - 1]);
  975. sscal_(&i__2, &r__1, &x11[i__ + i__ * x11_dim1], ldx11);
  976. i__2 = *p - i__ + 1;
  977. r__1 = -z1 * z3 * z4 * sin(phi[i__ - 1]);
  978. saxpy_(&i__2, &r__1, &x12[i__ - 1 + i__ * x12_dim1], ldx12, &
  979. x11[i__ + i__ * x11_dim1], ldx11);
  980. }
  981. if (i__ == 1) {
  982. i__2 = *m - *p - i__ + 1;
  983. sscal_(&i__2, &z2, &x21[i__ + i__ * x21_dim1], ldx21);
  984. } else {
  985. i__2 = *m - *p - i__ + 1;
  986. r__1 = z2 * cos(phi[i__ - 1]);
  987. sscal_(&i__2, &r__1, &x21[i__ + i__ * x21_dim1], ldx21);
  988. i__2 = *m - *p - i__ + 1;
  989. r__1 = -z2 * z3 * z4 * sin(phi[i__ - 1]);
  990. saxpy_(&i__2, &r__1, &x22[i__ - 1 + i__ * x22_dim1], ldx22, &
  991. x21[i__ + i__ * x21_dim1], ldx21);
  992. }
  993. i__2 = *m - *p - i__ + 1;
  994. i__3 = *p - i__ + 1;
  995. theta[i__] = atan2(snrm2_(&i__2, &x21[i__ + i__ * x21_dim1],
  996. ldx21), snrm2_(&i__3, &x11[i__ + i__ * x11_dim1], ldx11));
  997. i__2 = *p - i__ + 1;
  998. slarfgp_(&i__2, &x11[i__ + i__ * x11_dim1], &x11[i__ + (i__ + 1) *
  999. x11_dim1], ldx11, &taup1[i__]);
  1000. x11[i__ + i__ * x11_dim1] = 1.f;
  1001. if (i__ == *m - *p) {
  1002. i__2 = *m - *p - i__ + 1;
  1003. slarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + i__ *
  1004. x21_dim1], ldx21, &taup2[i__]);
  1005. } else {
  1006. i__2 = *m - *p - i__ + 1;
  1007. slarfgp_(&i__2, &x21[i__ + i__ * x21_dim1], &x21[i__ + (i__ +
  1008. 1) * x21_dim1], ldx21, &taup2[i__]);
  1009. }
  1010. x21[i__ + i__ * x21_dim1] = 1.f;
  1011. if (*q > i__) {
  1012. i__2 = *q - i__;
  1013. i__3 = *p - i__ + 1;
  1014. slarf_("R", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], ldx11, &
  1015. taup1[i__], &x11[i__ + 1 + i__ * x11_dim1], ldx11, &
  1016. work[1]);
  1017. }
  1018. if (*m - *q + 1 > i__) {
  1019. i__2 = *m - *q - i__ + 1;
  1020. i__3 = *p - i__ + 1;
  1021. slarf_("R", &i__2, &i__3, &x11[i__ + i__ * x11_dim1], ldx11, &
  1022. taup1[i__], &x12[i__ + i__ * x12_dim1], ldx12, &work[
  1023. 1]);
  1024. }
  1025. if (*q > i__) {
  1026. i__2 = *q - i__;
  1027. i__3 = *m - *p - i__ + 1;
  1028. slarf_("R", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], ldx21, &
  1029. taup2[i__], &x21[i__ + 1 + i__ * x21_dim1], ldx21, &
  1030. work[1]);
  1031. }
  1032. if (*m - *q + 1 > i__) {
  1033. i__2 = *m - *q - i__ + 1;
  1034. i__3 = *m - *p - i__ + 1;
  1035. slarf_("R", &i__2, &i__3, &x21[i__ + i__ * x21_dim1], ldx21, &
  1036. taup2[i__], &x22[i__ + i__ * x22_dim1], ldx22, &work[
  1037. 1]);
  1038. }
  1039. if (i__ < *q) {
  1040. i__2 = *q - i__;
  1041. r__1 = -z1 * z3 * sin(theta[i__]);
  1042. sscal_(&i__2, &r__1, &x11[i__ + 1 + i__ * x11_dim1], &c__1);
  1043. i__2 = *q - i__;
  1044. r__1 = z2 * z3 * cos(theta[i__]);
  1045. saxpy_(&i__2, &r__1, &x21[i__ + 1 + i__ * x21_dim1], &c__1, &
  1046. x11[i__ + 1 + i__ * x11_dim1], &c__1);
  1047. }
  1048. i__2 = *m - *q - i__ + 1;
  1049. r__1 = -z1 * z4 * sin(theta[i__]);
  1050. sscal_(&i__2, &r__1, &x12[i__ + i__ * x12_dim1], &c__1);
  1051. i__2 = *m - *q - i__ + 1;
  1052. r__1 = z2 * z4 * cos(theta[i__]);
  1053. saxpy_(&i__2, &r__1, &x22[i__ + i__ * x22_dim1], &c__1, &x12[i__
  1054. + i__ * x12_dim1], &c__1);
  1055. if (i__ < *q) {
  1056. i__2 = *q - i__;
  1057. i__3 = *m - *q - i__ + 1;
  1058. phi[i__] = atan2(snrm2_(&i__2, &x11[i__ + 1 + i__ * x11_dim1],
  1059. &c__1), snrm2_(&i__3, &x12[i__ + i__ * x12_dim1], &
  1060. c__1));
  1061. }
  1062. if (i__ < *q) {
  1063. if (*q - i__ == 1) {
  1064. i__2 = *q - i__;
  1065. slarfgp_(&i__2, &x11[i__ + 1 + i__ * x11_dim1], &x11[i__
  1066. + 1 + i__ * x11_dim1], &c__1, &tauq1[i__]);
  1067. } else {
  1068. i__2 = *q - i__;
  1069. slarfgp_(&i__2, &x11[i__ + 1 + i__ * x11_dim1], &x11[i__
  1070. + 2 + i__ * x11_dim1], &c__1, &tauq1[i__]);
  1071. }
  1072. x11[i__ + 1 + i__ * x11_dim1] = 1.f;
  1073. }
  1074. if (*m - *q > i__) {
  1075. i__2 = *m - *q - i__ + 1;
  1076. slarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + 1 +
  1077. i__ * x12_dim1], &c__1, &tauq2[i__]);
  1078. } else {
  1079. i__2 = *m - *q - i__ + 1;
  1080. slarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + i__ *
  1081. x12_dim1], &c__1, &tauq2[i__]);
  1082. }
  1083. x12[i__ + i__ * x12_dim1] = 1.f;
  1084. if (i__ < *q) {
  1085. i__2 = *q - i__;
  1086. i__3 = *p - i__;
  1087. slarf_("L", &i__2, &i__3, &x11[i__ + 1 + i__ * x11_dim1], &
  1088. c__1, &tauq1[i__], &x11[i__ + 1 + (i__ + 1) *
  1089. x11_dim1], ldx11, &work[1]);
  1090. i__2 = *q - i__;
  1091. i__3 = *m - *p - i__;
  1092. slarf_("L", &i__2, &i__3, &x11[i__ + 1 + i__ * x11_dim1], &
  1093. c__1, &tauq1[i__], &x21[i__ + 1 + (i__ + 1) *
  1094. x21_dim1], ldx21, &work[1]);
  1095. }
  1096. i__2 = *m - *q - i__ + 1;
  1097. i__3 = *p - i__;
  1098. slarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1099. tauq2[i__], &x12[i__ + (i__ + 1) * x12_dim1], ldx12, &
  1100. work[1]);
  1101. if (*m - *p - i__ > 0) {
  1102. i__2 = *m - *q - i__ + 1;
  1103. i__3 = *m - *p - i__;
  1104. slarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1105. tauq2[i__], &x22[i__ + (i__ + 1) * x22_dim1], ldx22, &
  1106. work[1]);
  1107. }
  1108. }
  1109. /* Reduce columns Q + 1, ..., P of X12, X22 */
  1110. i__1 = *p;
  1111. for (i__ = *q + 1; i__ <= i__1; ++i__) {
  1112. i__2 = *m - *q - i__ + 1;
  1113. r__1 = -z1 * z4;
  1114. sscal_(&i__2, &r__1, &x12[i__ + i__ * x12_dim1], &c__1);
  1115. i__2 = *m - *q - i__ + 1;
  1116. slarfgp_(&i__2, &x12[i__ + i__ * x12_dim1], &x12[i__ + 1 + i__ *
  1117. x12_dim1], &c__1, &tauq2[i__]);
  1118. x12[i__ + i__ * x12_dim1] = 1.f;
  1119. if (*p > i__) {
  1120. i__2 = *m - *q - i__ + 1;
  1121. i__3 = *p - i__;
  1122. slarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1123. tauq2[i__], &x12[i__ + (i__ + 1) * x12_dim1], ldx12, &
  1124. work[1]);
  1125. }
  1126. if (*m - *p - *q >= 1) {
  1127. i__2 = *m - *q - i__ + 1;
  1128. i__3 = *m - *p - *q;
  1129. slarf_("L", &i__2, &i__3, &x12[i__ + i__ * x12_dim1], &c__1, &
  1130. tauq2[i__], &x22[i__ + (*q + 1) * x22_dim1], ldx22, &
  1131. work[1]);
  1132. }
  1133. }
  1134. /* Reduce columns P + 1, ..., M - Q of X12, X22 */
  1135. i__1 = *m - *p - *q;
  1136. for (i__ = 1; i__ <= i__1; ++i__) {
  1137. i__2 = *m - *p - *q - i__ + 1;
  1138. r__1 = z2 * z4;
  1139. sscal_(&i__2, &r__1, &x22[*p + i__ + (*q + i__) * x22_dim1], &
  1140. c__1);
  1141. if (*m - *p - *q == i__) {
  1142. i__2 = *m - *p - *q - i__ + 1;
  1143. slarfgp_(&i__2, &x22[*p + i__ + (*q + i__) * x22_dim1], &x22[*
  1144. p + i__ + (*q + i__) * x22_dim1], &c__1, &tauq2[*p +
  1145. i__]);
  1146. x22[*p + i__ + (*q + i__) * x22_dim1] = 1.f;
  1147. } else {
  1148. i__2 = *m - *p - *q - i__ + 1;
  1149. slarfgp_(&i__2, &x22[*p + i__ + (*q + i__) * x22_dim1], &x22[*
  1150. p + i__ + 1 + (*q + i__) * x22_dim1], &c__1, &tauq2[*
  1151. p + i__]);
  1152. x22[*p + i__ + (*q + i__) * x22_dim1] = 1.f;
  1153. i__2 = *m - *p - *q - i__ + 1;
  1154. i__3 = *m - *p - *q - i__;
  1155. slarf_("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. }
  1160. }
  1161. return 0;
  1162. /* End of SORBDB */
  1163. } /* sorbdb_ */