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.

slatm5.c 24 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  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 real c_b29 = 1.f;
  238. static real c_b30 = 0.f;
  239. static real c_b33 = -1.f;
  240. /* > \brief \b SLATM5 */
  241. /* =========== DOCUMENTATION =========== */
  242. /* Online html documentation available at */
  243. /* http://www.netlib.org/lapack/explore-html/ */
  244. /* Definition: */
  245. /* =========== */
  246. /* SUBROUTINE SLATM5( 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. /* REAL ALPHA */
  252. /* REAL 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. /* > SLATM5 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL 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 REAL */
  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 real_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 slatm5_(integer *prtype, integer *m, integer *n, real *a,
  489. integer *lda, real *b, integer *ldb, real *c__, integer *ldc, real *
  490. d__, integer *ldd, real *e, integer *lde, real *f, integer *ldf, real
  491. *r__, integer *ldr, real *l, integer *ldl, real *alpha, integer *
  492. qblcka, integer *qblckb)
  493. {
  494. /* System generated locals */
  495. integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1,
  496. d_offset, e_dim1, e_offset, f_dim1, f_offset, l_dim1, l_offset,
  497. r_dim1, r_offset, i__1, i__2;
  498. /* Local variables */
  499. integer i__, j, k;
  500. extern /* Subroutine */ void sgemm_(char *, char *, integer *, integer *,
  501. integer *, real *, real *, integer *, real *, integer *, real *,
  502. real *, integer *);
  503. real imeps, reeps;
  504. /* -- LAPACK computational routine (version 3.7.0) -- */
  505. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  506. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  507. /* June 2016 */
  508. /* ===================================================================== */
  509. /* Parameter adjustments */
  510. a_dim1 = *lda;
  511. a_offset = 1 + a_dim1 * 1;
  512. a -= a_offset;
  513. b_dim1 = *ldb;
  514. b_offset = 1 + b_dim1 * 1;
  515. b -= b_offset;
  516. c_dim1 = *ldc;
  517. c_offset = 1 + c_dim1 * 1;
  518. c__ -= c_offset;
  519. d_dim1 = *ldd;
  520. d_offset = 1 + d_dim1 * 1;
  521. d__ -= d_offset;
  522. e_dim1 = *lde;
  523. e_offset = 1 + e_dim1 * 1;
  524. e -= e_offset;
  525. f_dim1 = *ldf;
  526. f_offset = 1 + f_dim1 * 1;
  527. f -= f_offset;
  528. r_dim1 = *ldr;
  529. r_offset = 1 + r_dim1 * 1;
  530. r__ -= r_offset;
  531. l_dim1 = *ldl;
  532. l_offset = 1 + l_dim1 * 1;
  533. l -= l_offset;
  534. /* Function Body */
  535. if (*prtype == 1) {
  536. i__1 = *m;
  537. for (i__ = 1; i__ <= i__1; ++i__) {
  538. i__2 = *m;
  539. for (j = 1; j <= i__2; ++j) {
  540. if (i__ == j) {
  541. a[i__ + j * a_dim1] = 1.f;
  542. d__[i__ + j * d_dim1] = 1.f;
  543. } else if (i__ == j - 1) {
  544. a[i__ + j * a_dim1] = -1.f;
  545. d__[i__ + j * d_dim1] = 0.f;
  546. } else {
  547. a[i__ + j * a_dim1] = 0.f;
  548. d__[i__ + j * d_dim1] = 0.f;
  549. }
  550. /* L10: */
  551. }
  552. /* L20: */
  553. }
  554. i__1 = *n;
  555. for (i__ = 1; i__ <= i__1; ++i__) {
  556. i__2 = *n;
  557. for (j = 1; j <= i__2; ++j) {
  558. if (i__ == j) {
  559. b[i__ + j * b_dim1] = 1.f - *alpha;
  560. e[i__ + j * e_dim1] = 1.f;
  561. } else if (i__ == j - 1) {
  562. b[i__ + j * b_dim1] = 1.f;
  563. e[i__ + j * e_dim1] = 0.f;
  564. } else {
  565. b[i__ + j * b_dim1] = 0.f;
  566. e[i__ + j * e_dim1] = 0.f;
  567. }
  568. /* L30: */
  569. }
  570. /* L40: */
  571. }
  572. i__1 = *m;
  573. for (i__ = 1; i__ <= i__1; ++i__) {
  574. i__2 = *n;
  575. for (j = 1; j <= i__2; ++j) {
  576. r__[i__ + j * r_dim1] = (.5f - sin((real) (i__ / j))) * 20.f;
  577. l[i__ + j * l_dim1] = r__[i__ + j * r_dim1];
  578. /* L50: */
  579. }
  580. /* L60: */
  581. }
  582. } else if (*prtype == 2 || *prtype == 3) {
  583. i__1 = *m;
  584. for (i__ = 1; i__ <= i__1; ++i__) {
  585. i__2 = *m;
  586. for (j = 1; j <= i__2; ++j) {
  587. if (i__ <= j) {
  588. a[i__ + j * a_dim1] = (.5f - sin((real) i__)) * 2.f;
  589. d__[i__ + j * d_dim1] = (.5f - sin((real) (i__ * j))) *
  590. 2.f;
  591. } else {
  592. a[i__ + j * a_dim1] = 0.f;
  593. d__[i__ + j * d_dim1] = 0.f;
  594. }
  595. /* L70: */
  596. }
  597. /* L80: */
  598. }
  599. i__1 = *n;
  600. for (i__ = 1; i__ <= i__1; ++i__) {
  601. i__2 = *n;
  602. for (j = 1; j <= i__2; ++j) {
  603. if (i__ <= j) {
  604. b[i__ + j * b_dim1] = (.5f - sin((real) (i__ + j))) * 2.f;
  605. e[i__ + j * e_dim1] = (.5f - sin((real) j)) * 2.f;
  606. } else {
  607. b[i__ + j * b_dim1] = 0.f;
  608. e[i__ + j * e_dim1] = 0.f;
  609. }
  610. /* L90: */
  611. }
  612. /* L100: */
  613. }
  614. i__1 = *m;
  615. for (i__ = 1; i__ <= i__1; ++i__) {
  616. i__2 = *n;
  617. for (j = 1; j <= i__2; ++j) {
  618. r__[i__ + j * r_dim1] = (.5f - sin((real) (i__ * j))) * 20.f;
  619. l[i__ + j * l_dim1] = (.5f - sin((real) (i__ + j))) * 20.f;
  620. /* L110: */
  621. }
  622. /* L120: */
  623. }
  624. if (*prtype == 3) {
  625. if (*qblcka <= 1) {
  626. *qblcka = 2;
  627. }
  628. i__1 = *m - 1;
  629. i__2 = *qblcka;
  630. for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
  631. a[k + 1 + (k + 1) * a_dim1] = a[k + k * a_dim1];
  632. a[k + 1 + k * a_dim1] = -sin(a[k + (k + 1) * a_dim1]);
  633. /* L130: */
  634. }
  635. if (*qblckb <= 1) {
  636. *qblckb = 2;
  637. }
  638. i__2 = *n - 1;
  639. i__1 = *qblckb;
  640. for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) {
  641. b[k + 1 + (k + 1) * b_dim1] = b[k + k * b_dim1];
  642. b[k + 1 + k * b_dim1] = -sin(b[k + (k + 1) * b_dim1]);
  643. /* L140: */
  644. }
  645. }
  646. } else if (*prtype == 4) {
  647. i__1 = *m;
  648. for (i__ = 1; i__ <= i__1; ++i__) {
  649. i__2 = *m;
  650. for (j = 1; j <= i__2; ++j) {
  651. a[i__ + j * a_dim1] = (.5f - sin((real) (i__ * j))) * 20.f;
  652. d__[i__ + j * d_dim1] = (.5f - sin((real) (i__ + j))) * 2.f;
  653. /* L150: */
  654. }
  655. /* L160: */
  656. }
  657. i__1 = *n;
  658. for (i__ = 1; i__ <= i__1; ++i__) {
  659. i__2 = *n;
  660. for (j = 1; j <= i__2; ++j) {
  661. b[i__ + j * b_dim1] = (.5f - sin((real) (i__ + j))) * 20.f;
  662. e[i__ + j * e_dim1] = (.5f - sin((real) (i__ * j))) * 2.f;
  663. /* L170: */
  664. }
  665. /* L180: */
  666. }
  667. i__1 = *m;
  668. for (i__ = 1; i__ <= i__1; ++i__) {
  669. i__2 = *n;
  670. for (j = 1; j <= i__2; ++j) {
  671. r__[i__ + j * r_dim1] = (.5f - sin((real) (j / i__))) * 20.f;
  672. l[i__ + j * l_dim1] = (.5f - sin((real) (i__ * j))) * 2.f;
  673. /* L190: */
  674. }
  675. /* L200: */
  676. }
  677. } else if (*prtype >= 5) {
  678. reeps = 20.f / *alpha;
  679. imeps = -1.5f / *alpha;
  680. i__1 = *m;
  681. for (i__ = 1; i__ <= i__1; ++i__) {
  682. i__2 = *n;
  683. for (j = 1; j <= i__2; ++j) {
  684. r__[i__ + j * r_dim1] = (.5f - sin((real) (i__ * j))) * *
  685. alpha / 20.f;
  686. l[i__ + j * l_dim1] = (.5f - sin((real) (i__ + j))) * *alpha /
  687. 20.f;
  688. /* L210: */
  689. }
  690. /* L220: */
  691. }
  692. i__1 = *m;
  693. for (i__ = 1; i__ <= i__1; ++i__) {
  694. d__[i__ + i__ * d_dim1] = 1.f;
  695. /* L230: */
  696. }
  697. i__1 = *m;
  698. for (i__ = 1; i__ <= i__1; ++i__) {
  699. if (i__ <= 4) {
  700. a[i__ + i__ * a_dim1] = 1.f;
  701. if (i__ > 2) {
  702. a[i__ + i__ * a_dim1] = reeps + 1.f;
  703. }
  704. if (i__ % 2 != 0 && i__ < *m) {
  705. a[i__ + (i__ + 1) * a_dim1] = imeps;
  706. } else if (i__ > 1) {
  707. a[i__ + (i__ - 1) * a_dim1] = -imeps;
  708. }
  709. } else if (i__ <= 8) {
  710. if (i__ <= 6) {
  711. a[i__ + i__ * a_dim1] = reeps;
  712. } else {
  713. a[i__ + i__ * a_dim1] = -reeps;
  714. }
  715. if (i__ % 2 != 0 && i__ < *m) {
  716. a[i__ + (i__ + 1) * a_dim1] = 1.f;
  717. } else if (i__ > 1) {
  718. a[i__ + (i__ - 1) * a_dim1] = -1.f;
  719. }
  720. } else {
  721. a[i__ + i__ * a_dim1] = 1.f;
  722. if (i__ % 2 != 0 && i__ < *m) {
  723. a[i__ + (i__ + 1) * a_dim1] = imeps * 2;
  724. } else if (i__ > 1) {
  725. a[i__ + (i__ - 1) * a_dim1] = -imeps * 2;
  726. }
  727. }
  728. /* L240: */
  729. }
  730. i__1 = *n;
  731. for (i__ = 1; i__ <= i__1; ++i__) {
  732. e[i__ + i__ * e_dim1] = 1.f;
  733. if (i__ <= 4) {
  734. b[i__ + i__ * b_dim1] = -1.f;
  735. if (i__ > 2) {
  736. b[i__ + i__ * b_dim1] = 1.f - reeps;
  737. }
  738. if (i__ % 2 != 0 && i__ < *n) {
  739. b[i__ + (i__ + 1) * b_dim1] = imeps;
  740. } else if (i__ > 1) {
  741. b[i__ + (i__ - 1) * b_dim1] = -imeps;
  742. }
  743. } else if (i__ <= 8) {
  744. if (i__ <= 6) {
  745. b[i__ + i__ * b_dim1] = reeps;
  746. } else {
  747. b[i__ + i__ * b_dim1] = -reeps;
  748. }
  749. if (i__ % 2 != 0 && i__ < *n) {
  750. b[i__ + (i__ + 1) * b_dim1] = imeps + 1.f;
  751. } else if (i__ > 1) {
  752. b[i__ + (i__ - 1) * b_dim1] = -1.f - imeps;
  753. }
  754. } else {
  755. b[i__ + i__ * b_dim1] = 1.f - reeps;
  756. if (i__ % 2 != 0 && i__ < *n) {
  757. b[i__ + (i__ + 1) * b_dim1] = imeps * 2;
  758. } else if (i__ > 1) {
  759. b[i__ + (i__ - 1) * b_dim1] = -imeps * 2;
  760. }
  761. }
  762. /* L250: */
  763. }
  764. }
  765. /* Compute rhs (C, F) */
  766. sgemm_("N", "N", m, n, m, &c_b29, &a[a_offset], lda, &r__[r_offset], ldr,
  767. &c_b30, &c__[c_offset], ldc);
  768. sgemm_("N", "N", m, n, n, &c_b33, &l[l_offset], ldl, &b[b_offset], ldb, &
  769. c_b29, &c__[c_offset], ldc);
  770. sgemm_("N", "N", m, n, m, &c_b29, &d__[d_offset], ldd, &r__[r_offset],
  771. ldr, &c_b30, &f[f_offset], ldf);
  772. sgemm_("N", "N", m, n, n, &c_b33, &l[l_offset], ldl, &e[e_offset], lde, &
  773. c_b29, &f[f_offset], ldf);
  774. /* End of SLATM5 */
  775. return;
  776. } /* slatm5_ */