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

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