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

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