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.

dlatm5.c 24 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. #include <math.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. #include <complex.h>
  6. #ifdef complex
  7. #undef complex
  8. #endif
  9. #ifdef I
  10. #undef I
  11. #endif
  12. #if defined(_WIN64)
  13. typedef long long BLASLONG;
  14. typedef unsigned long long BLASULONG;
  15. #else
  16. typedef long BLASLONG;
  17. typedef unsigned long BLASULONG;
  18. #endif
  19. #ifdef LAPACK_ILP64
  20. typedef BLASLONG blasint;
  21. #if defined(_WIN64)
  22. #define blasabs(x) llabs(x)
  23. #else
  24. #define blasabs(x) labs(x)
  25. #endif
  26. #else
  27. typedef int blasint;
  28. #define blasabs(x) abs(x)
  29. #endif
  30. typedef blasint integer;
  31. typedef unsigned int uinteger;
  32. typedef char *address;
  33. typedef short int shortint;
  34. typedef float real;
  35. typedef double doublereal;
  36. typedef struct { real r, i; } complex;
  37. typedef struct { doublereal r, i; } doublecomplex;
  38. #ifdef _MSC_VER
  39. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  40. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  41. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  42. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  43. #else
  44. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  46. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  47. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  48. #endif
  49. #define pCf(z) (*_pCf(z))
  50. #define pCd(z) (*_pCd(z))
  51. typedef char integer1;
  52. #define TRUE_ (1)
  53. #define FALSE_ (0)
  54. /* Extern is for use with -E */
  55. #ifndef Extern
  56. #define Extern extern
  57. #endif
  58. /* I/O stuff */
  59. typedef int flag;
  60. typedef int ftnlen;
  61. typedef int ftnint;
  62. /*external read, write*/
  63. typedef struct
  64. { flag cierr;
  65. ftnint ciunit;
  66. flag ciend;
  67. char *cifmt;
  68. ftnint cirec;
  69. } cilist;
  70. /*internal read, write*/
  71. typedef struct
  72. { flag icierr;
  73. char *iciunit;
  74. flag iciend;
  75. char *icifmt;
  76. ftnint icirlen;
  77. ftnint icirnum;
  78. } icilist;
  79. /*open*/
  80. typedef struct
  81. { flag oerr;
  82. ftnint ounit;
  83. char *ofnm;
  84. ftnlen ofnmlen;
  85. char *osta;
  86. char *oacc;
  87. char *ofm;
  88. ftnint orl;
  89. char *oblnk;
  90. } olist;
  91. /*close*/
  92. typedef struct
  93. { flag cerr;
  94. ftnint cunit;
  95. char *csta;
  96. } cllist;
  97. /*rewind, backspace, endfile*/
  98. typedef struct
  99. { flag aerr;
  100. ftnint aunit;
  101. } alist;
  102. /* inquire */
  103. typedef struct
  104. { flag inerr;
  105. ftnint inunit;
  106. char *infile;
  107. ftnlen infilen;
  108. ftnint *inex; /*parameters in standard's order*/
  109. ftnint *inopen;
  110. ftnint *innum;
  111. ftnint *innamed;
  112. char *inname;
  113. ftnlen innamlen;
  114. char *inacc;
  115. ftnlen inacclen;
  116. char *inseq;
  117. ftnlen inseqlen;
  118. char *indir;
  119. ftnlen indirlen;
  120. char *infmt;
  121. ftnlen infmtlen;
  122. char *inform;
  123. ftnint informlen;
  124. char *inunf;
  125. ftnlen inunflen;
  126. ftnint *inrecl;
  127. ftnint *innrec;
  128. char *inblank;
  129. ftnlen inblanklen;
  130. } inlist;
  131. #define VOID void
  132. union Multitype { /* for multiple entry points */
  133. integer1 g;
  134. shortint h;
  135. integer i;
  136. /* longint j; */
  137. real r;
  138. doublereal d;
  139. complex c;
  140. doublecomplex z;
  141. };
  142. typedef union Multitype Multitype;
  143. struct Vardesc { /* for Namelist */
  144. char *name;
  145. char *addr;
  146. ftnlen *dims;
  147. int type;
  148. };
  149. typedef struct Vardesc Vardesc;
  150. struct Namelist {
  151. char *name;
  152. Vardesc **vars;
  153. int nvars;
  154. };
  155. typedef struct Namelist Namelist;
  156. #define abs(x) ((x) >= 0 ? (x) : -(x))
  157. #define dabs(x) (fabs(x))
  158. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  159. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  160. #define dmin(a,b) (f2cmin(a,b))
  161. #define dmax(a,b) (f2cmax(a,b))
  162. #define bit_test(a,b) ((a) >> (b) & 1)
  163. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  164. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  165. #define abort_() { sig_die("Fortran abort routine called", 1); }
  166. #define c_abs(z) (cabsf(Cf(z)))
  167. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  168. #ifdef _MSC_VER
  169. #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
  170. #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
  171. #else
  172. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  173. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  174. #endif
  175. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  176. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  177. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  178. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  179. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  180. #define d_abs(x) (fabs(*(x)))
  181. #define d_acos(x) (acos(*(x)))
  182. #define d_asin(x) (asin(*(x)))
  183. #define d_atan(x) (atan(*(x)))
  184. #define d_atn2(x, y) (atan2(*(x),*(y)))
  185. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  186. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  187. #define d_cos(x) (cos(*(x)))
  188. #define d_cosh(x) (cosh(*(x)))
  189. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  190. #define d_exp(x) (exp(*(x)))
  191. #define d_imag(z) (cimag(Cd(z)))
  192. #define r_imag(z) (cimagf(Cf(z)))
  193. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  194. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  195. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  196. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  197. #define d_log(x) (log(*(x)))
  198. #define d_mod(x, y) (fmod(*(x), *(y)))
  199. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  200. #define d_nint(x) u_nint(*(x))
  201. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  202. #define d_sign(a,b) u_sign(*(a),*(b))
  203. #define r_sign(a,b) u_sign(*(a),*(b))
  204. #define d_sin(x) (sin(*(x)))
  205. #define d_sinh(x) (sinh(*(x)))
  206. #define d_sqrt(x) (sqrt(*(x)))
  207. #define d_tan(x) (tan(*(x)))
  208. #define d_tanh(x) (tanh(*(x)))
  209. #define i_abs(x) abs(*(x))
  210. #define i_dnnt(x) ((integer)u_nint(*(x)))
  211. #define i_len(s, n) (n)
  212. #define i_nint(x) ((integer)u_nint(*(x)))
  213. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  214. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  215. #define pow_si(B,E) spow_ui(*(B),*(E))
  216. #define pow_ri(B,E) spow_ui(*(B),*(E))
  217. #define pow_di(B,E) dpow_ui(*(B),*(E))
  218. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  219. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  220. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  221. #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++ = ' '; }
  222. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  223. #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]; }
  224. #define sig_die(s, kill) { exit(1); }
  225. #define s_stop(s, n) {exit(0);}
  226. #define z_abs(z) (cabs(Cd(z)))
  227. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  228. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  229. #define myexit_() break;
  230. #define mycycle() continue;
  231. #define myceiling(w) {ceil(w)}
  232. #define myhuge(w) {HUGE_VAL}
  233. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  234. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  235. /* procedure parameter types for -A and -C++ */
  236. /* Table of constant values */
  237. static doublereal c_b29 = 1.;
  238. static doublereal c_b30 = 0.;
  239. static doublereal c_b33 = -1.;
  240. /* > \brief \b DLATM5 */
  241. /* =========== DOCUMENTATION =========== */
  242. /* Online html documentation available at */
  243. /* http://www.netlib.org/lapack/explore-html/ */
  244. /* Definition: */
  245. /* =========== */
  246. /* SUBROUTINE DLATM5( PRTYPE, M, N, A, LDA, B, LDB, C, LDC, D, LDD, */
  247. /* E, LDE, F, LDF, R, LDR, L, LDL, ALPHA, QBLCKA, */
  248. /* QBLCKB ) */
  249. /* INTEGER LDA, LDB, LDC, LDD, LDE, LDF, LDL, LDR, M, N, */
  250. /* $ PRTYPE, QBLCKA, QBLCKB */
  251. /* DOUBLE PRECISION ALPHA */
  252. /* DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * ), */
  253. /* $ D( LDD, * ), E( LDE, * ), F( LDF, * ), */
  254. /* $ L( LDL, * ), R( LDR, * ) */
  255. /* > \par Purpose: */
  256. /* ============= */
  257. /* > */
  258. /* > \verbatim */
  259. /* > */
  260. /* > DLATM5 generates matrices involved in the Generalized Sylvester */
  261. /* > equation: */
  262. /* > */
  263. /* > A * R - L * B = C */
  264. /* > D * R - L * E = F */
  265. /* > */
  266. /* > They also satisfy (the diagonalization condition) */
  267. /* > */
  268. /* > [ I -L ] ( [ A -C ], [ D -F ] ) [ I R ] = ( [ A ], [ D ] ) */
  269. /* > [ I ] ( [ B ] [ E ] ) [ I ] ( [ B ] [ E ] ) */
  270. /* > */
  271. /* > \endverbatim */
  272. /* Arguments: */
  273. /* ========== */
  274. /* > \param[in] PRTYPE */
  275. /* > \verbatim */
  276. /* > PRTYPE is INTEGER */
  277. /* > "Points" to a certain type of the matrices to generate */
  278. /* > (see further details). */
  279. /* > \endverbatim */
  280. /* > */
  281. /* > \param[in] M */
  282. /* > \verbatim */
  283. /* > M is INTEGER */
  284. /* > Specifies the order of A and D and the number of rows in */
  285. /* > C, F, R and L. */
  286. /* > \endverbatim */
  287. /* > */
  288. /* > \param[in] N */
  289. /* > \verbatim */
  290. /* > N is INTEGER */
  291. /* > Specifies the order of B and E and the number of columns in */
  292. /* > C, F, R and L. */
  293. /* > \endverbatim */
  294. /* > */
  295. /* > \param[out] A */
  296. /* > \verbatim */
  297. /* > A is DOUBLE PRECISION array, dimension (LDA, M). */
  298. /* > On exit A M-by-M is initialized according to PRTYPE. */
  299. /* > \endverbatim */
  300. /* > */
  301. /* > \param[in] LDA */
  302. /* > \verbatim */
  303. /* > LDA is INTEGER */
  304. /* > The leading dimension of A. */
  305. /* > \endverbatim */
  306. /* > */
  307. /* > \param[out] B */
  308. /* > \verbatim */
  309. /* > B is DOUBLE PRECISION array, dimension (LDB, N). */
  310. /* > On exit B N-by-N is initialized according to PRTYPE. */
  311. /* > \endverbatim */
  312. /* > */
  313. /* > \param[in] LDB */
  314. /* > \verbatim */
  315. /* > LDB is INTEGER */
  316. /* > The leading dimension of B. */
  317. /* > \endverbatim */
  318. /* > */
  319. /* > \param[out] C */
  320. /* > \verbatim */
  321. /* > C is DOUBLE PRECISION array, dimension (LDC, N). */
  322. /* > On exit C M-by-N is initialized according to PRTYPE. */
  323. /* > \endverbatim */
  324. /* > */
  325. /* > \param[in] LDC */
  326. /* > \verbatim */
  327. /* > LDC is INTEGER */
  328. /* > The leading dimension of C. */
  329. /* > \endverbatim */
  330. /* > */
  331. /* > \param[out] D */
  332. /* > \verbatim */
  333. /* > D is DOUBLE PRECISION array, dimension (LDD, M). */
  334. /* > On exit D M-by-M is initialized according to PRTYPE. */
  335. /* > \endverbatim */
  336. /* > */
  337. /* > \param[in] LDD */
  338. /* > \verbatim */
  339. /* > LDD is INTEGER */
  340. /* > The leading dimension of D. */
  341. /* > \endverbatim */
  342. /* > */
  343. /* > \param[out] E */
  344. /* > \verbatim */
  345. /* > E is DOUBLE PRECISION array, dimension (LDE, N). */
  346. /* > On exit E N-by-N is initialized according to PRTYPE. */
  347. /* > \endverbatim */
  348. /* > */
  349. /* > \param[in] LDE */
  350. /* > \verbatim */
  351. /* > LDE is INTEGER */
  352. /* > The leading dimension of E. */
  353. /* > \endverbatim */
  354. /* > */
  355. /* > \param[out] F */
  356. /* > \verbatim */
  357. /* > F is DOUBLE PRECISION array, dimension (LDF, N). */
  358. /* > On exit F M-by-N is initialized according to PRTYPE. */
  359. /* > \endverbatim */
  360. /* > */
  361. /* > \param[in] LDF */
  362. /* > \verbatim */
  363. /* > LDF is INTEGER */
  364. /* > The leading dimension of F. */
  365. /* > \endverbatim */
  366. /* > */
  367. /* > \param[out] R */
  368. /* > \verbatim */
  369. /* > R is DOUBLE PRECISION array, dimension (LDR, N). */
  370. /* > On exit R M-by-N is initialized according to PRTYPE. */
  371. /* > \endverbatim */
  372. /* > */
  373. /* > \param[in] LDR */
  374. /* > \verbatim */
  375. /* > LDR is INTEGER */
  376. /* > The leading dimension of R. */
  377. /* > \endverbatim */
  378. /* > */
  379. /* > \param[out] L */
  380. /* > \verbatim */
  381. /* > L is DOUBLE PRECISION array, dimension (LDL, N). */
  382. /* > On exit L M-by-N is initialized according to PRTYPE. */
  383. /* > \endverbatim */
  384. /* > */
  385. /* > \param[in] LDL */
  386. /* > \verbatim */
  387. /* > LDL is INTEGER */
  388. /* > The leading dimension of L. */
  389. /* > \endverbatim */
  390. /* > */
  391. /* > \param[in] ALPHA */
  392. /* > \verbatim */
  393. /* > ALPHA is DOUBLE PRECISION */
  394. /* > Parameter used in generating PRTYPE = 1 and 5 matrices. */
  395. /* > \endverbatim */
  396. /* > */
  397. /* > \param[in] QBLCKA */
  398. /* > \verbatim */
  399. /* > QBLCKA is INTEGER */
  400. /* > When PRTYPE = 3, specifies the distance between 2-by-2 */
  401. /* > blocks on the diagonal in A. Otherwise, QBLCKA is not */
  402. /* > referenced. QBLCKA > 1. */
  403. /* > \endverbatim */
  404. /* > */
  405. /* > \param[in] QBLCKB */
  406. /* > \verbatim */
  407. /* > QBLCKB is INTEGER */
  408. /* > When PRTYPE = 3, specifies the distance between 2-by-2 */
  409. /* > blocks on the diagonal in B. Otherwise, QBLCKB is not */
  410. /* > referenced. QBLCKB > 1. */
  411. /* > \endverbatim */
  412. /* Authors: */
  413. /* ======== */
  414. /* > \author Univ. of Tennessee */
  415. /* > \author Univ. of California Berkeley */
  416. /* > \author Univ. of Colorado Denver */
  417. /* > \author NAG Ltd. */
  418. /* > \date June 2016 */
  419. /* > \ingroup double_matgen */
  420. /* > \par Further Details: */
  421. /* ===================== */
  422. /* > */
  423. /* > \verbatim */
  424. /* > */
  425. /* > PRTYPE = 1: A and B are Jordan blocks, D and E are identity matrices */
  426. /* > */
  427. /* > A : if (i == j) then A(i, j) = 1.0 */
  428. /* > if (j == i + 1) then A(i, j) = -1.0 */
  429. /* > else A(i, j) = 0.0, i, j = 1...M */
  430. /* > */
  431. /* > B : if (i == j) then B(i, j) = 1.0 - ALPHA */
  432. /* > if (j == i + 1) then B(i, j) = 1.0 */
  433. /* > else B(i, j) = 0.0, i, j = 1...N */
  434. /* > */
  435. /* > D : if (i == j) then D(i, j) = 1.0 */
  436. /* > else D(i, j) = 0.0, i, j = 1...M */
  437. /* > */
  438. /* > E : if (i == j) then E(i, j) = 1.0 */
  439. /* > else E(i, j) = 0.0, i, j = 1...N */
  440. /* > */
  441. /* > L = R are chosen from [-10...10], */
  442. /* > which specifies the right hand sides (C, F). */
  443. /* > */
  444. /* > PRTYPE = 2 or 3: Triangular and/or quasi- triangular. */
  445. /* > */
  446. /* > A : if (i <= j) then A(i, j) = [-1...1] */
  447. /* > else A(i, j) = 0.0, i, j = 1...M */
  448. /* > */
  449. /* > if (PRTYPE = 3) then */
  450. /* > A(k + 1, k + 1) = A(k, k) */
  451. /* > A(k + 1, k) = [-1...1] */
  452. /* > sign(A(k, k + 1) = -(sin(A(k + 1, k)) */
  453. /* > k = 1, M - 1, QBLCKA */
  454. /* > */
  455. /* > B : if (i <= j) then B(i, j) = [-1...1] */
  456. /* > else B(i, j) = 0.0, i, j = 1...N */
  457. /* > */
  458. /* > if (PRTYPE = 3) then */
  459. /* > B(k + 1, k + 1) = B(k, k) */
  460. /* > B(k + 1, k) = [-1...1] */
  461. /* > sign(B(k, k + 1) = -(sign(B(k + 1, k)) */
  462. /* > k = 1, N - 1, QBLCKB */
  463. /* > */
  464. /* > D : if (i <= j) then D(i, j) = [-1...1]. */
  465. /* > else D(i, j) = 0.0, i, j = 1...M */
  466. /* > */
  467. /* > */
  468. /* > E : if (i <= j) then D(i, j) = [-1...1] */
  469. /* > else E(i, j) = 0.0, i, j = 1...N */
  470. /* > */
  471. /* > L, R are chosen from [-10...10], */
  472. /* > which specifies the right hand sides (C, F). */
  473. /* > */
  474. /* > PRTYPE = 4 Full */
  475. /* > A(i, j) = [-10...10] */
  476. /* > D(i, j) = [-1...1] i,j = 1...M */
  477. /* > B(i, j) = [-10...10] */
  478. /* > E(i, j) = [-1...1] i,j = 1...N */
  479. /* > R(i, j) = [-10...10] */
  480. /* > L(i, j) = [-1...1] i = 1..M ,j = 1...N */
  481. /* > */
  482. /* > L, R specifies the right hand sides (C, F). */
  483. /* > */
  484. /* > PRTYPE = 5 special case common and/or close eigs. */
  485. /* > \endverbatim */
  486. /* > */
  487. /* ===================================================================== */
  488. /* Subroutine */ void dlatm5_(integer *prtype, integer *m, integer *n,
  489. doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *
  490. c__, integer *ldc, doublereal *d__, integer *ldd, doublereal *e,
  491. integer *lde, doublereal *f, integer *ldf, doublereal *r__, integer *
  492. ldr, doublereal *l, integer *ldl, doublereal *alpha, integer *qblcka,
  493. integer *qblckb)
  494. {
  495. /* System generated locals */
  496. integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1,
  497. d_offset, e_dim1, e_offset, f_dim1, f_offset, l_dim1, l_offset,
  498. r_dim1, r_offset, i__1, i__2;
  499. /* Local variables */
  500. integer i__, j, k;
  501. extern /* Subroutine */ void dgemm_(char *, char *, integer *, integer *,
  502. integer *, doublereal *, doublereal *, integer *, doublereal *,
  503. integer *, doublereal *, doublereal *, integer *);
  504. doublereal imeps, reeps;
  505. /* -- LAPACK computational routine (version 3.7.0) -- */
  506. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  507. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  508. /* June 2016 */
  509. /* ===================================================================== */
  510. /* Parameter adjustments */
  511. a_dim1 = *lda;
  512. a_offset = 1 + a_dim1 * 1;
  513. a -= a_offset;
  514. b_dim1 = *ldb;
  515. b_offset = 1 + b_dim1 * 1;
  516. b -= b_offset;
  517. c_dim1 = *ldc;
  518. c_offset = 1 + c_dim1 * 1;
  519. c__ -= c_offset;
  520. d_dim1 = *ldd;
  521. d_offset = 1 + d_dim1 * 1;
  522. d__ -= d_offset;
  523. e_dim1 = *lde;
  524. e_offset = 1 + e_dim1 * 1;
  525. e -= e_offset;
  526. f_dim1 = *ldf;
  527. f_offset = 1 + f_dim1 * 1;
  528. f -= f_offset;
  529. r_dim1 = *ldr;
  530. r_offset = 1 + r_dim1 * 1;
  531. r__ -= r_offset;
  532. l_dim1 = *ldl;
  533. l_offset = 1 + l_dim1 * 1;
  534. l -= l_offset;
  535. /* Function Body */
  536. if (*prtype == 1) {
  537. i__1 = *m;
  538. for (i__ = 1; i__ <= i__1; ++i__) {
  539. i__2 = *m;
  540. for (j = 1; j <= i__2; ++j) {
  541. if (i__ == j) {
  542. a[i__ + j * a_dim1] = 1.;
  543. d__[i__ + j * d_dim1] = 1.;
  544. } else if (i__ == j - 1) {
  545. a[i__ + j * a_dim1] = -1.;
  546. d__[i__ + j * d_dim1] = 0.;
  547. } else {
  548. a[i__ + j * a_dim1] = 0.;
  549. d__[i__ + j * d_dim1] = 0.;
  550. }
  551. /* L10: */
  552. }
  553. /* L20: */
  554. }
  555. i__1 = *n;
  556. for (i__ = 1; i__ <= i__1; ++i__) {
  557. i__2 = *n;
  558. for (j = 1; j <= i__2; ++j) {
  559. if (i__ == j) {
  560. b[i__ + j * b_dim1] = 1. - *alpha;
  561. e[i__ + j * e_dim1] = 1.;
  562. } else if (i__ == j - 1) {
  563. b[i__ + j * b_dim1] = 1.;
  564. e[i__ + j * e_dim1] = 0.;
  565. } else {
  566. b[i__ + j * b_dim1] = 0.;
  567. e[i__ + j * e_dim1] = 0.;
  568. }
  569. /* L30: */
  570. }
  571. /* L40: */
  572. }
  573. i__1 = *m;
  574. for (i__ = 1; i__ <= i__1; ++i__) {
  575. i__2 = *n;
  576. for (j = 1; j <= i__2; ++j) {
  577. r__[i__ + j * r_dim1] = (.5 - sin((doublereal) (i__ / j))) *
  578. 20.;
  579. l[i__ + j * l_dim1] = r__[i__ + j * r_dim1];
  580. /* L50: */
  581. }
  582. /* L60: */
  583. }
  584. } else if (*prtype == 2 || *prtype == 3) {
  585. i__1 = *m;
  586. for (i__ = 1; i__ <= i__1; ++i__) {
  587. i__2 = *m;
  588. for (j = 1; j <= i__2; ++j) {
  589. if (i__ <= j) {
  590. a[i__ + j * a_dim1] = (.5 - sin((doublereal) i__)) * 2.;
  591. d__[i__ + j * d_dim1] = (.5 - sin((doublereal) (i__ * j)))
  592. * 2.;
  593. } else {
  594. a[i__ + j * a_dim1] = 0.;
  595. d__[i__ + j * d_dim1] = 0.;
  596. }
  597. /* L70: */
  598. }
  599. /* L80: */
  600. }
  601. i__1 = *n;
  602. for (i__ = 1; i__ <= i__1; ++i__) {
  603. i__2 = *n;
  604. for (j = 1; j <= i__2; ++j) {
  605. if (i__ <= j) {
  606. b[i__ + j * b_dim1] = (.5 - sin((doublereal) (i__ + j))) *
  607. 2.;
  608. e[i__ + j * e_dim1] = (.5 - sin((doublereal) j)) * 2.;
  609. } else {
  610. b[i__ + j * b_dim1] = 0.;
  611. e[i__ + j * e_dim1] = 0.;
  612. }
  613. /* L90: */
  614. }
  615. /* L100: */
  616. }
  617. i__1 = *m;
  618. for (i__ = 1; i__ <= i__1; ++i__) {
  619. i__2 = *n;
  620. for (j = 1; j <= i__2; ++j) {
  621. r__[i__ + j * r_dim1] = (.5 - sin((doublereal) (i__ * j))) *
  622. 20.;
  623. l[i__ + j * l_dim1] = (.5 - sin((doublereal) (i__ + j))) *
  624. 20.;
  625. /* L110: */
  626. }
  627. /* L120: */
  628. }
  629. if (*prtype == 3) {
  630. if (*qblcka <= 1) {
  631. *qblcka = 2;
  632. }
  633. i__1 = *m - 1;
  634. i__2 = *qblcka;
  635. for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
  636. a[k + 1 + (k + 1) * a_dim1] = a[k + k * a_dim1];
  637. a[k + 1 + k * a_dim1] = -sin(a[k + (k + 1) * a_dim1]);
  638. /* L130: */
  639. }
  640. if (*qblckb <= 1) {
  641. *qblckb = 2;
  642. }
  643. i__2 = *n - 1;
  644. i__1 = *qblckb;
  645. for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
  646. b[k + 1 + (k + 1) * b_dim1] = b[k + k * b_dim1];
  647. b[k + 1 + k * b_dim1] = -sin(b[k + (k + 1) * b_dim1]);
  648. /* L140: */
  649. }
  650. }
  651. } else if (*prtype == 4) {
  652. i__1 = *m;
  653. for (i__ = 1; i__ <= i__1; ++i__) {
  654. i__2 = *m;
  655. for (j = 1; j <= i__2; ++j) {
  656. a[i__ + j * a_dim1] = (.5 - sin((doublereal) (i__ * j))) *
  657. 20.;
  658. d__[i__ + j * d_dim1] = (.5 - sin((doublereal) (i__ + j))) *
  659. 2.;
  660. /* L150: */
  661. }
  662. /* L160: */
  663. }
  664. i__1 = *n;
  665. for (i__ = 1; i__ <= i__1; ++i__) {
  666. i__2 = *n;
  667. for (j = 1; j <= i__2; ++j) {
  668. b[i__ + j * b_dim1] = (.5 - sin((doublereal) (i__ + j))) *
  669. 20.;
  670. e[i__ + j * e_dim1] = (.5 - sin((doublereal) (i__ * j))) * 2.;
  671. /* L170: */
  672. }
  673. /* L180: */
  674. }
  675. i__1 = *m;
  676. for (i__ = 1; i__ <= i__1; ++i__) {
  677. i__2 = *n;
  678. for (j = 1; j <= i__2; ++j) {
  679. r__[i__ + j * r_dim1] = (.5 - sin((doublereal) (j / i__))) *
  680. 20.;
  681. l[i__ + j * l_dim1] = (.5 - sin((doublereal) (i__ * j))) * 2.;
  682. /* L190: */
  683. }
  684. /* L200: */
  685. }
  686. } else if (*prtype >= 5) {
  687. reeps = 20. / *alpha;
  688. imeps = -1.5 / *alpha;
  689. i__1 = *m;
  690. for (i__ = 1; i__ <= i__1; ++i__) {
  691. i__2 = *n;
  692. for (j = 1; j <= i__2; ++j) {
  693. r__[i__ + j * r_dim1] = (.5 - sin((doublereal) (i__ * j))) * *
  694. alpha / 20.;
  695. l[i__ + j * l_dim1] = (.5 - sin((doublereal) (i__ + j))) * *
  696. alpha / 20.;
  697. /* L210: */
  698. }
  699. /* L220: */
  700. }
  701. i__1 = *m;
  702. for (i__ = 1; i__ <= i__1; ++i__) {
  703. d__[i__ + i__ * d_dim1] = 1.;
  704. /* L230: */
  705. }
  706. i__1 = *m;
  707. for (i__ = 1; i__ <= i__1; ++i__) {
  708. if (i__ <= 4) {
  709. a[i__ + i__ * a_dim1] = 1.;
  710. if (i__ > 2) {
  711. a[i__ + i__ * a_dim1] = reeps + 1.;
  712. }
  713. if (i__ % 2 != 0 && i__ < *m) {
  714. a[i__ + (i__ + 1) * a_dim1] = imeps;
  715. } else if (i__ > 1) {
  716. a[i__ + (i__ - 1) * a_dim1] = -imeps;
  717. }
  718. } else if (i__ <= 8) {
  719. if (i__ <= 6) {
  720. a[i__ + i__ * a_dim1] = reeps;
  721. } else {
  722. a[i__ + i__ * a_dim1] = -reeps;
  723. }
  724. if (i__ % 2 != 0 && i__ < *m) {
  725. a[i__ + (i__ + 1) * a_dim1] = 1.;
  726. } else if (i__ > 1) {
  727. a[i__ + (i__ - 1) * a_dim1] = -1.;
  728. }
  729. } else {
  730. a[i__ + i__ * a_dim1] = 1.;
  731. if (i__ % 2 != 0 && i__ < *m) {
  732. a[i__ + (i__ + 1) * a_dim1] = imeps * 2;
  733. } else if (i__ > 1) {
  734. a[i__ + (i__ - 1) * a_dim1] = -imeps * 2;
  735. }
  736. }
  737. /* L240: */
  738. }
  739. i__1 = *n;
  740. for (i__ = 1; i__ <= i__1; ++i__) {
  741. e[i__ + i__ * e_dim1] = 1.;
  742. if (i__ <= 4) {
  743. b[i__ + i__ * b_dim1] = -1.;
  744. if (i__ > 2) {
  745. b[i__ + i__ * b_dim1] = 1. - reeps;
  746. }
  747. if (i__ % 2 != 0 && i__ < *n) {
  748. b[i__ + (i__ + 1) * b_dim1] = imeps;
  749. } else if (i__ > 1) {
  750. b[i__ + (i__ - 1) * b_dim1] = -imeps;
  751. }
  752. } else if (i__ <= 8) {
  753. if (i__ <= 6) {
  754. b[i__ + i__ * b_dim1] = reeps;
  755. } else {
  756. b[i__ + i__ * b_dim1] = -reeps;
  757. }
  758. if (i__ % 2 != 0 && i__ < *n) {
  759. b[i__ + (i__ + 1) * b_dim1] = imeps + 1.;
  760. } else if (i__ > 1) {
  761. b[i__ + (i__ - 1) * b_dim1] = -1. - imeps;
  762. }
  763. } else {
  764. b[i__ + i__ * b_dim1] = 1. - reeps;
  765. if (i__ % 2 != 0 && i__ < *n) {
  766. b[i__ + (i__ + 1) * b_dim1] = imeps * 2;
  767. } else if (i__ > 1) {
  768. b[i__ + (i__ - 1) * b_dim1] = -imeps * 2;
  769. }
  770. }
  771. /* L250: */
  772. }
  773. }
  774. /* Compute rhs (C, F) */
  775. dgemm_("N", "N", m, n, m, &c_b29, &a[a_offset], lda, &r__[r_offset], ldr,
  776. &c_b30, &c__[c_offset], ldc);
  777. dgemm_("N", "N", m, n, n, &c_b33, &l[l_offset], ldl, &b[b_offset], ldb, &
  778. c_b29, &c__[c_offset], ldc);
  779. dgemm_("N", "N", m, n, m, &c_b29, &d__[d_offset], ldd, &r__[r_offset],
  780. ldr, &c_b30, &f[f_offset], ldf);
  781. dgemm_("N", "N", m, n, n, &c_b33, &l[l_offset], ldl, &e[e_offset], lde, &
  782. c_b29, &f[f_offset], ldf);
  783. /* End of DLATM5 */
  784. return;
  785. } /* dlatm5_ */