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.

ctrttf.c 28 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. /* f2c.h -- Standard Fortran to C header file */
  2. /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
  3. - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */
  4. #ifndef F2C_INCLUDE
  5. #define F2C_INCLUDE
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10. #include <complex.h>
  11. #ifdef complex
  12. #undef complex
  13. #endif
  14. #ifdef I
  15. #undef I
  16. #endif
  17. #if defined(_WIN64)
  18. typedef long long BLASLONG;
  19. typedef unsigned long long BLASULONG;
  20. #else
  21. typedef long BLASLONG;
  22. typedef unsigned long BLASULONG;
  23. #endif
  24. #ifdef LAPACK_ILP64
  25. typedef BLASLONG blasint;
  26. #if defined(_WIN64)
  27. #define blasabs(x) llabs(x)
  28. #else
  29. #define blasabs(x) labs(x)
  30. #endif
  31. #else
  32. typedef int blasint;
  33. #define blasabs(x) abs(x)
  34. #endif
  35. typedef blasint integer;
  36. typedef unsigned int uinteger;
  37. typedef char *address;
  38. typedef short int shortint;
  39. typedef float real;
  40. typedef double doublereal;
  41. typedef struct { real r, i; } complex;
  42. typedef struct { doublereal r, i; } doublecomplex;
  43. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  44. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  46. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  47. #define pCf(z) (*_pCf(z))
  48. #define pCd(z) (*_pCd(z))
  49. typedef int logical;
  50. typedef short int shortlogical;
  51. typedef char logical1;
  52. typedef char integer1;
  53. #define TRUE_ (1)
  54. #define FALSE_ (0)
  55. /* Extern is for use with -E */
  56. #ifndef Extern
  57. #define Extern extern
  58. #endif
  59. /* I/O stuff */
  60. typedef int flag;
  61. typedef int ftnlen;
  62. typedef int ftnint;
  63. /*external read, write*/
  64. typedef struct
  65. { flag cierr;
  66. ftnint ciunit;
  67. flag ciend;
  68. char *cifmt;
  69. ftnint cirec;
  70. } cilist;
  71. /*internal read, write*/
  72. typedef struct
  73. { flag icierr;
  74. char *iciunit;
  75. flag iciend;
  76. char *icifmt;
  77. ftnint icirlen;
  78. ftnint icirnum;
  79. } icilist;
  80. /*open*/
  81. typedef struct
  82. { flag oerr;
  83. ftnint ounit;
  84. char *ofnm;
  85. ftnlen ofnmlen;
  86. char *osta;
  87. char *oacc;
  88. char *ofm;
  89. ftnint orl;
  90. char *oblnk;
  91. } olist;
  92. /*close*/
  93. typedef struct
  94. { flag cerr;
  95. ftnint cunit;
  96. char *csta;
  97. } cllist;
  98. /*rewind, backspace, endfile*/
  99. typedef struct
  100. { flag aerr;
  101. ftnint aunit;
  102. } alist;
  103. /* inquire */
  104. typedef struct
  105. { flag inerr;
  106. ftnint inunit;
  107. char *infile;
  108. ftnlen infilen;
  109. ftnint *inex; /*parameters in standard's order*/
  110. ftnint *inopen;
  111. ftnint *innum;
  112. ftnint *innamed;
  113. char *inname;
  114. ftnlen innamlen;
  115. char *inacc;
  116. ftnlen inacclen;
  117. char *inseq;
  118. ftnlen inseqlen;
  119. char *indir;
  120. ftnlen indirlen;
  121. char *infmt;
  122. ftnlen infmtlen;
  123. char *inform;
  124. ftnint informlen;
  125. char *inunf;
  126. ftnlen inunflen;
  127. ftnint *inrecl;
  128. ftnint *innrec;
  129. char *inblank;
  130. ftnlen inblanklen;
  131. } inlist;
  132. #define VOID void
  133. union Multitype { /* for multiple entry points */
  134. integer1 g;
  135. shortint h;
  136. integer i;
  137. /* longint j; */
  138. real r;
  139. doublereal d;
  140. complex c;
  141. doublecomplex z;
  142. };
  143. typedef union Multitype Multitype;
  144. struct Vardesc { /* for Namelist */
  145. char *name;
  146. char *addr;
  147. ftnlen *dims;
  148. int type;
  149. };
  150. typedef struct Vardesc Vardesc;
  151. struct Namelist {
  152. char *name;
  153. Vardesc **vars;
  154. int nvars;
  155. };
  156. typedef struct Namelist Namelist;
  157. #define abs(x) ((x) >= 0 ? (x) : -(x))
  158. #define dabs(x) (fabs(x))
  159. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  160. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  161. #define dmin(a,b) (f2cmin(a,b))
  162. #define dmax(a,b) (f2cmax(a,b))
  163. #define bit_test(a,b) ((a) >> (b) & 1)
  164. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  165. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  166. #define abort_() { sig_die("Fortran abort routine called", 1); }
  167. #define c_abs(z) (cabsf(Cf(z)))
  168. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  169. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  170. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  171. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  172. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  173. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  174. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  175. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  176. #define d_abs(x) (fabs(*(x)))
  177. #define d_acos(x) (acos(*(x)))
  178. #define d_asin(x) (asin(*(x)))
  179. #define d_atan(x) (atan(*(x)))
  180. #define d_atn2(x, y) (atan2(*(x),*(y)))
  181. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  182. #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); }
  183. #define d_cos(x) (cos(*(x)))
  184. #define d_cosh(x) (cosh(*(x)))
  185. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  186. #define d_exp(x) (exp(*(x)))
  187. #define d_imag(z) (cimag(Cd(z)))
  188. #define r_imag(z) (cimag(Cf(z)))
  189. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  190. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  191. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  192. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  193. #define d_log(x) (log(*(x)))
  194. #define d_mod(x, y) (fmod(*(x), *(y)))
  195. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  196. #define d_nint(x) u_nint(*(x))
  197. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  198. #define d_sign(a,b) u_sign(*(a),*(b))
  199. #define r_sign(a,b) u_sign(*(a),*(b))
  200. #define d_sin(x) (sin(*(x)))
  201. #define d_sinh(x) (sinh(*(x)))
  202. #define d_sqrt(x) (sqrt(*(x)))
  203. #define d_tan(x) (tan(*(x)))
  204. #define d_tanh(x) (tanh(*(x)))
  205. #define i_abs(x) abs(*(x))
  206. #define i_dnnt(x) ((integer)u_nint(*(x)))
  207. #define i_len(s, n) (n)
  208. #define i_nint(x) ((integer)u_nint(*(x)))
  209. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  210. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  211. #define pow_si(B,E) spow_ui(*(B),*(E))
  212. #define pow_ri(B,E) spow_ui(*(B),*(E))
  213. #define pow_di(B,E) dpow_ui(*(B),*(E))
  214. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  215. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  216. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  217. #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++ = ' '; }
  218. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  219. #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]; }
  220. #define sig_die(s, kill) { exit(1); }
  221. #define s_stop(s, n) {exit(0);}
  222. static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
  223. #define z_abs(z) (cabs(Cd(z)))
  224. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  225. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  226. #define myexit_() break;
  227. #define mycycle() continue;
  228. #define myceiling(w) {ceil(w)}
  229. #define myhuge(w) {HUGE_VAL}
  230. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  231. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  232. /* procedure parameter types for -A and -C++ */
  233. #define F2C_proc_par_types 1
  234. #ifdef __cplusplus
  235. typedef logical (*L_fp)(...);
  236. #else
  237. typedef logical (*L_fp)();
  238. #endif
  239. static float spow_ui(float x, integer n) {
  240. float pow=1.0; unsigned long int u;
  241. if(n != 0) {
  242. if(n < 0) n = -n, x = 1/x;
  243. for(u = n; ; ) {
  244. if(u & 01) pow *= x;
  245. if(u >>= 1) x *= x;
  246. else break;
  247. }
  248. }
  249. return pow;
  250. }
  251. static double dpow_ui(double x, integer n) {
  252. double pow=1.0; unsigned long int u;
  253. if(n != 0) {
  254. if(n < 0) n = -n, x = 1/x;
  255. for(u = n; ; ) {
  256. if(u & 01) pow *= x;
  257. if(u >>= 1) x *= x;
  258. else break;
  259. }
  260. }
  261. return pow;
  262. }
  263. static _Complex float cpow_ui(_Complex float x, integer n) {
  264. _Complex float pow=1.0; unsigned long int u;
  265. if(n != 0) {
  266. if(n < 0) n = -n, x = 1/x;
  267. for(u = n; ; ) {
  268. if(u & 01) pow *= x;
  269. if(u >>= 1) x *= x;
  270. else break;
  271. }
  272. }
  273. return pow;
  274. }
  275. static _Complex double zpow_ui(_Complex double x, integer n) {
  276. _Complex double pow=1.0; unsigned long int u;
  277. if(n != 0) {
  278. if(n < 0) n = -n, x = 1/x;
  279. for(u = n; ; ) {
  280. if(u & 01) pow *= x;
  281. if(u >>= 1) x *= x;
  282. else break;
  283. }
  284. }
  285. return pow;
  286. }
  287. static integer pow_ii(integer x, integer n) {
  288. integer pow; unsigned long int u;
  289. if (n <= 0) {
  290. if (n == 0 || x == 1) pow = 1;
  291. else if (x != -1) pow = x == 0 ? 1/x : 0;
  292. else n = -n;
  293. }
  294. if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
  295. u = n;
  296. for(pow = 1; ; ) {
  297. if(u & 01) pow *= x;
  298. if(u >>= 1) x *= x;
  299. else break;
  300. }
  301. }
  302. return pow;
  303. }
  304. static integer dmaxloc_(double *w, integer s, integer e, integer *n)
  305. {
  306. double m; integer i, mi;
  307. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  308. if (w[i-1]>m) mi=i ,m=w[i-1];
  309. return mi-s+1;
  310. }
  311. static integer smaxloc_(float *w, integer s, integer e, integer *n)
  312. {
  313. float m; integer i, mi;
  314. for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
  315. if (w[i-1]>m) mi=i ,m=w[i-1];
  316. return mi-s+1;
  317. }
  318. static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  319. integer n = *n_, incx = *incx_, incy = *incy_, i;
  320. _Complex float zdotc = 0.0;
  321. if (incx == 1 && incy == 1) {
  322. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  323. zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
  324. }
  325. } else {
  326. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  327. zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
  328. }
  329. }
  330. pCf(z) = zdotc;
  331. }
  332. static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  333. integer n = *n_, incx = *incx_, incy = *incy_, i;
  334. _Complex double zdotc = 0.0;
  335. if (incx == 1 && incy == 1) {
  336. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  337. zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
  338. }
  339. } else {
  340. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  341. zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
  342. }
  343. }
  344. pCd(z) = zdotc;
  345. }
  346. static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
  347. integer n = *n_, incx = *incx_, incy = *incy_, i;
  348. _Complex float zdotc = 0.0;
  349. if (incx == 1 && incy == 1) {
  350. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  351. zdotc += Cf(&x[i]) * Cf(&y[i]);
  352. }
  353. } else {
  354. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  355. zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
  356. }
  357. }
  358. pCf(z) = zdotc;
  359. }
  360. static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
  361. integer n = *n_, incx = *incx_, incy = *incy_, i;
  362. _Complex double zdotc = 0.0;
  363. if (incx == 1 && incy == 1) {
  364. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  365. zdotc += Cd(&x[i]) * Cd(&y[i]);
  366. }
  367. } else {
  368. for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
  369. zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
  370. }
  371. }
  372. pCd(z) = zdotc;
  373. }
  374. #endif
  375. /* -- translated by f2c (version 20000121).
  376. You must link the resulting object file with the libraries:
  377. -lf2c -lm (in that order)
  378. */
  379. /* > \brief \b CTRTTF copies a triangular matrix from the standard full format (TR) to the rectangular full pa
  380. cked format (TF). */
  381. /* =========== DOCUMENTATION =========== */
  382. /* Online html documentation available at */
  383. /* http://www.netlib.org/lapack/explore-html/ */
  384. /* > \htmlonly */
  385. /* > Download CTRTTF + dependencies */
  386. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctrttf.
  387. f"> */
  388. /* > [TGZ]</a> */
  389. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctrttf.
  390. f"> */
  391. /* > [ZIP]</a> */
  392. /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctrttf.
  393. f"> */
  394. /* > [TXT]</a> */
  395. /* > \endhtmlonly */
  396. /* Definition: */
  397. /* =========== */
  398. /* SUBROUTINE CTRTTF( TRANSR, UPLO, N, A, LDA, ARF, INFO ) */
  399. /* CHARACTER TRANSR, UPLO */
  400. /* INTEGER INFO, N, LDA */
  401. /* COMPLEX A( 0: LDA-1, 0: * ), ARF( 0: * ) */
  402. /* > \par Purpose: */
  403. /* ============= */
  404. /* > */
  405. /* > \verbatim */
  406. /* > */
  407. /* > CTRTTF copies a triangular matrix A from standard full format (TR) */
  408. /* > to rectangular full packed format (TF) . */
  409. /* > \endverbatim */
  410. /* Arguments: */
  411. /* ========== */
  412. /* > \param[in] TRANSR */
  413. /* > \verbatim */
  414. /* > TRANSR is CHARACTER*1 */
  415. /* > = 'N': ARF in Normal mode is wanted; */
  416. /* > = 'C': ARF in Conjugate Transpose mode is wanted; */
  417. /* > \endverbatim */
  418. /* > */
  419. /* > \param[in] UPLO */
  420. /* > \verbatim */
  421. /* > UPLO is CHARACTER*1 */
  422. /* > = 'U': A is upper triangular; */
  423. /* > = 'L': A is lower triangular. */
  424. /* > \endverbatim */
  425. /* > */
  426. /* > \param[in] N */
  427. /* > \verbatim */
  428. /* > N is INTEGER */
  429. /* > The order of the matrix A. N >= 0. */
  430. /* > \endverbatim */
  431. /* > */
  432. /* > \param[in] A */
  433. /* > \verbatim */
  434. /* > A is COMPLEX array, dimension ( LDA, N ) */
  435. /* > On entry, the triangular matrix A. If UPLO = 'U', the */
  436. /* > leading N-by-N upper triangular part of the array A contains */
  437. /* > the upper triangular matrix, and the strictly lower */
  438. /* > triangular part of A is not referenced. If UPLO = 'L', the */
  439. /* > leading N-by-N lower triangular part of the array A contains */
  440. /* > the lower triangular matrix, and the strictly upper */
  441. /* > triangular part of A is not referenced. */
  442. /* > \endverbatim */
  443. /* > */
  444. /* > \param[in] LDA */
  445. /* > \verbatim */
  446. /* > LDA is INTEGER */
  447. /* > The leading dimension of the matrix A. LDA >= f2cmax(1,N). */
  448. /* > \endverbatim */
  449. /* > */
  450. /* > \param[out] ARF */
  451. /* > \verbatim */
  452. /* > ARF is COMPLEX array, dimension ( N*(N+1)/2 ), */
  453. /* > On exit, the upper or lower triangular matrix A stored in */
  454. /* > RFP format. For a further discussion see Notes below. */
  455. /* > \endverbatim */
  456. /* > */
  457. /* > \param[out] INFO */
  458. /* > \verbatim */
  459. /* > INFO is INTEGER */
  460. /* > = 0: successful exit */
  461. /* > < 0: if INFO = -i, the i-th argument had an illegal value */
  462. /* > \endverbatim */
  463. /* Authors: */
  464. /* ======== */
  465. /* > \author Univ. of Tennessee */
  466. /* > \author Univ. of California Berkeley */
  467. /* > \author Univ. of Colorado Denver */
  468. /* > \author NAG Ltd. */
  469. /* > \date June 2016 */
  470. /* > \ingroup complexOTHERcomputational */
  471. /* > \par Further Details: */
  472. /* ===================== */
  473. /* > */
  474. /* > \verbatim */
  475. /* > */
  476. /* > We first consider Standard Packed Format when N is even. */
  477. /* > We give an example where N = 6. */
  478. /* > */
  479. /* > AP is Upper AP is Lower */
  480. /* > */
  481. /* > 00 01 02 03 04 05 00 */
  482. /* > 11 12 13 14 15 10 11 */
  483. /* > 22 23 24 25 20 21 22 */
  484. /* > 33 34 35 30 31 32 33 */
  485. /* > 44 45 40 41 42 43 44 */
  486. /* > 55 50 51 52 53 54 55 */
  487. /* > */
  488. /* > */
  489. /* > Let TRANSR = 'N'. RFP holds AP as follows: */
  490. /* > For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
  491. /* > three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
  492. /* > conjugate-transpose of the first three columns of AP upper. */
  493. /* > For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
  494. /* > three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
  495. /* > conjugate-transpose of the last three columns of AP lower. */
  496. /* > To denote conjugate we place -- above the element. This covers the */
  497. /* > case N even and TRANSR = 'N'. */
  498. /* > */
  499. /* > RFP A RFP A */
  500. /* > */
  501. /* > -- -- -- */
  502. /* > 03 04 05 33 43 53 */
  503. /* > -- -- */
  504. /* > 13 14 15 00 44 54 */
  505. /* > -- */
  506. /* > 23 24 25 10 11 55 */
  507. /* > */
  508. /* > 33 34 35 20 21 22 */
  509. /* > -- */
  510. /* > 00 44 45 30 31 32 */
  511. /* > -- -- */
  512. /* > 01 11 55 40 41 42 */
  513. /* > -- -- -- */
  514. /* > 02 12 22 50 51 52 */
  515. /* > */
  516. /* > Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
  517. /* > transpose of RFP A above. One therefore gets: */
  518. /* > */
  519. /* > */
  520. /* > RFP A RFP A */
  521. /* > */
  522. /* > -- -- -- -- -- -- -- -- -- -- */
  523. /* > 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */
  524. /* > -- -- -- -- -- -- -- -- -- -- */
  525. /* > 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */
  526. /* > -- -- -- -- -- -- -- -- -- -- */
  527. /* > 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */
  528. /* > */
  529. /* > */
  530. /* > We next consider Standard Packed Format when N is odd. */
  531. /* > We give an example where N = 5. */
  532. /* > */
  533. /* > AP is Upper AP is Lower */
  534. /* > */
  535. /* > 00 01 02 03 04 00 */
  536. /* > 11 12 13 14 10 11 */
  537. /* > 22 23 24 20 21 22 */
  538. /* > 33 34 30 31 32 33 */
  539. /* > 44 40 41 42 43 44 */
  540. /* > */
  541. /* > */
  542. /* > Let TRANSR = 'N'. RFP holds AP as follows: */
  543. /* > For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
  544. /* > three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
  545. /* > conjugate-transpose of the first two columns of AP upper. */
  546. /* > For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
  547. /* > three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
  548. /* > conjugate-transpose of the last two columns of AP lower. */
  549. /* > To denote conjugate we place -- above the element. This covers the */
  550. /* > case N odd and TRANSR = 'N'. */
  551. /* > */
  552. /* > RFP A RFP A */
  553. /* > */
  554. /* > -- -- */
  555. /* > 02 03 04 00 33 43 */
  556. /* > -- */
  557. /* > 12 13 14 10 11 44 */
  558. /* > */
  559. /* > 22 23 24 20 21 22 */
  560. /* > -- */
  561. /* > 00 33 34 30 31 32 */
  562. /* > -- -- */
  563. /* > 01 11 44 40 41 42 */
  564. /* > */
  565. /* > Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate- */
  566. /* > transpose of RFP A above. One therefore gets: */
  567. /* > */
  568. /* > */
  569. /* > RFP A RFP A */
  570. /* > */
  571. /* > -- -- -- -- -- -- -- -- -- */
  572. /* > 02 12 22 00 01 00 10 20 30 40 50 */
  573. /* > -- -- -- -- -- -- -- -- -- */
  574. /* > 03 13 23 33 11 33 11 21 31 41 51 */
  575. /* > -- -- -- -- -- -- -- -- -- */
  576. /* > 04 14 24 34 44 43 44 22 32 42 52 */
  577. /* > \endverbatim */
  578. /* > */
  579. /* ===================================================================== */
  580. /* Subroutine */ int ctrttf_(char *transr, char *uplo, integer *n, complex *a,
  581. integer *lda, complex *arf, integer *info)
  582. {
  583. /* System generated locals */
  584. integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
  585. complex q__1;
  586. /* Local variables */
  587. integer np1x2, i__, j, k, l;
  588. logical normaltransr;
  589. extern logical lsame_(char *, char *);
  590. logical lower;
  591. integer n1, n2, ij, nt;
  592. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  593. logical nisodd;
  594. integer nx2;
  595. /* -- LAPACK computational routine (version 3.7.0) -- */
  596. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  597. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  598. /* June 2016 */
  599. /* ===================================================================== */
  600. /* Test the input parameters. */
  601. /* Parameter adjustments */
  602. a_dim1 = *lda - 1 - 0 + 1;
  603. a_offset = 0 + a_dim1 * 0;
  604. a -= a_offset;
  605. /* Function Body */
  606. *info = 0;
  607. normaltransr = lsame_(transr, "N");
  608. lower = lsame_(uplo, "L");
  609. if (! normaltransr && ! lsame_(transr, "C")) {
  610. *info = -1;
  611. } else if (! lower && ! lsame_(uplo, "U")) {
  612. *info = -2;
  613. } else if (*n < 0) {
  614. *info = -3;
  615. } else if (*lda < f2cmax(1,*n)) {
  616. *info = -5;
  617. }
  618. if (*info != 0) {
  619. i__1 = -(*info);
  620. xerbla_("CTRTTF", &i__1, (ftnlen)6);
  621. return 0;
  622. }
  623. /* Quick return if possible */
  624. if (*n <= 1) {
  625. if (*n == 1) {
  626. if (normaltransr) {
  627. arf[0].r = a[0].r, arf[0].i = a[0].i;
  628. } else {
  629. r_cnjg(&q__1, a);
  630. arf[0].r = q__1.r, arf[0].i = q__1.i;
  631. }
  632. }
  633. return 0;
  634. }
  635. /* Size of array ARF(1:2,0:nt-1) */
  636. nt = *n * (*n + 1) / 2;
  637. /* set N1 and N2 depending on LOWER: for N even N1=N2=K */
  638. if (lower) {
  639. n2 = *n / 2;
  640. n1 = *n - n2;
  641. } else {
  642. n1 = *n / 2;
  643. n2 = *n - n1;
  644. }
  645. /* If N is odd, set NISODD = .TRUE., LDA=N+1 and A is (N+1)--by--K2. */
  646. /* If N is even, set K = N/2 and NISODD = .FALSE., LDA=N and A is */
  647. /* N--by--(N+1)/2. */
  648. if (*n % 2 == 0) {
  649. k = *n / 2;
  650. nisodd = FALSE_;
  651. if (! lower) {
  652. np1x2 = *n + *n + 2;
  653. }
  654. } else {
  655. nisodd = TRUE_;
  656. if (! lower) {
  657. nx2 = *n + *n;
  658. }
  659. }
  660. if (nisodd) {
  661. /* N is odd */
  662. if (normaltransr) {
  663. /* N is odd and TRANSR = 'N' */
  664. if (lower) {
  665. /* SRPA for LOWER, NORMAL and N is odd ( a(0:n-1,0:n1-1) ) */
  666. /* T1 -> a(0,0), T2 -> a(0,1), S -> a(n1,0) */
  667. /* T1 -> a(0), T2 -> a(n), S -> a(n1); lda=n */
  668. ij = 0;
  669. i__1 = n2;
  670. for (j = 0; j <= i__1; ++j) {
  671. i__2 = n2 + j;
  672. for (i__ = n1; i__ <= i__2; ++i__) {
  673. i__3 = ij;
  674. r_cnjg(&q__1, &a[n2 + j + i__ * a_dim1]);
  675. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  676. ++ij;
  677. }
  678. i__2 = *n - 1;
  679. for (i__ = j; i__ <= i__2; ++i__) {
  680. i__3 = ij;
  681. i__4 = i__ + j * a_dim1;
  682. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  683. ++ij;
  684. }
  685. }
  686. } else {
  687. /* SRPA for UPPER, NORMAL and N is odd ( a(0:n-1,0:n2-1) */
  688. /* T1 -> a(n1+1,0), T2 -> a(n1,0), S -> a(0,0) */
  689. /* T1 -> a(n2), T2 -> a(n1), S -> a(0); lda=n */
  690. ij = nt - *n;
  691. i__1 = n1;
  692. for (j = *n - 1; j >= i__1; --j) {
  693. i__2 = j;
  694. for (i__ = 0; i__ <= i__2; ++i__) {
  695. i__3 = ij;
  696. i__4 = i__ + j * a_dim1;
  697. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  698. ++ij;
  699. }
  700. i__2 = n1 - 1;
  701. for (l = j - n1; l <= i__2; ++l) {
  702. i__3 = ij;
  703. r_cnjg(&q__1, &a[j - n1 + l * a_dim1]);
  704. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  705. ++ij;
  706. }
  707. ij -= nx2;
  708. }
  709. }
  710. } else {
  711. /* N is odd and TRANSR = 'C' */
  712. if (lower) {
  713. /* SRPA for LOWER, TRANSPOSE and N is odd */
  714. /* T1 -> A(0,0) , T2 -> A(1,0) , S -> A(0,n1) */
  715. /* T1 -> A(0+0) , T2 -> A(1+0) , S -> A(0+n1*n1); lda=n1 */
  716. ij = 0;
  717. i__1 = n2 - 1;
  718. for (j = 0; j <= i__1; ++j) {
  719. i__2 = j;
  720. for (i__ = 0; i__ <= i__2; ++i__) {
  721. i__3 = ij;
  722. r_cnjg(&q__1, &a[j + i__ * a_dim1]);
  723. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  724. ++ij;
  725. }
  726. i__2 = *n - 1;
  727. for (i__ = n1 + j; i__ <= i__2; ++i__) {
  728. i__3 = ij;
  729. i__4 = i__ + (n1 + j) * a_dim1;
  730. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  731. ++ij;
  732. }
  733. }
  734. i__1 = *n - 1;
  735. for (j = n2; j <= i__1; ++j) {
  736. i__2 = n1 - 1;
  737. for (i__ = 0; i__ <= i__2; ++i__) {
  738. i__3 = ij;
  739. r_cnjg(&q__1, &a[j + i__ * a_dim1]);
  740. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  741. ++ij;
  742. }
  743. }
  744. } else {
  745. /* SRPA for UPPER, TRANSPOSE and N is odd */
  746. /* T1 -> A(0,n1+1), T2 -> A(0,n1), S -> A(0,0) */
  747. /* T1 -> A(n2*n2), T2 -> A(n1*n2), S -> A(0); lda=n2 */
  748. ij = 0;
  749. i__1 = n1;
  750. for (j = 0; j <= i__1; ++j) {
  751. i__2 = *n - 1;
  752. for (i__ = n1; i__ <= i__2; ++i__) {
  753. i__3 = ij;
  754. r_cnjg(&q__1, &a[j + i__ * a_dim1]);
  755. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  756. ++ij;
  757. }
  758. }
  759. i__1 = n1 - 1;
  760. for (j = 0; j <= i__1; ++j) {
  761. i__2 = j;
  762. for (i__ = 0; i__ <= i__2; ++i__) {
  763. i__3 = ij;
  764. i__4 = i__ + j * a_dim1;
  765. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  766. ++ij;
  767. }
  768. i__2 = *n - 1;
  769. for (l = n2 + j; l <= i__2; ++l) {
  770. i__3 = ij;
  771. r_cnjg(&q__1, &a[n2 + j + l * a_dim1]);
  772. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  773. ++ij;
  774. }
  775. }
  776. }
  777. }
  778. } else {
  779. /* N is even */
  780. if (normaltransr) {
  781. /* N is even and TRANSR = 'N' */
  782. if (lower) {
  783. /* SRPA for LOWER, NORMAL, and N is even ( a(0:n,0:k-1) ) */
  784. /* T1 -> a(1,0), T2 -> a(0,0), S -> a(k+1,0) */
  785. /* T1 -> a(1), T2 -> a(0), S -> a(k+1); lda=n+1 */
  786. ij = 0;
  787. i__1 = k - 1;
  788. for (j = 0; j <= i__1; ++j) {
  789. i__2 = k + j;
  790. for (i__ = k; i__ <= i__2; ++i__) {
  791. i__3 = ij;
  792. r_cnjg(&q__1, &a[k + j + i__ * a_dim1]);
  793. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  794. ++ij;
  795. }
  796. i__2 = *n - 1;
  797. for (i__ = j; i__ <= i__2; ++i__) {
  798. i__3 = ij;
  799. i__4 = i__ + j * a_dim1;
  800. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  801. ++ij;
  802. }
  803. }
  804. } else {
  805. /* SRPA for UPPER, NORMAL, and N is even ( a(0:n,0:k-1) ) */
  806. /* T1 -> a(k+1,0) , T2 -> a(k,0), S -> a(0,0) */
  807. /* T1 -> a(k+1), T2 -> a(k), S -> a(0); lda=n+1 */
  808. ij = nt - *n - 1;
  809. i__1 = k;
  810. for (j = *n - 1; j >= i__1; --j) {
  811. i__2 = j;
  812. for (i__ = 0; i__ <= i__2; ++i__) {
  813. i__3 = ij;
  814. i__4 = i__ + j * a_dim1;
  815. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  816. ++ij;
  817. }
  818. i__2 = k - 1;
  819. for (l = j - k; l <= i__2; ++l) {
  820. i__3 = ij;
  821. r_cnjg(&q__1, &a[j - k + l * a_dim1]);
  822. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  823. ++ij;
  824. }
  825. ij -= np1x2;
  826. }
  827. }
  828. } else {
  829. /* N is even and TRANSR = 'C' */
  830. if (lower) {
  831. /* SRPA for LOWER, TRANSPOSE and N is even (see paper, A=B) */
  832. /* T1 -> A(0,1) , T2 -> A(0,0) , S -> A(0,k+1) : */
  833. /* T1 -> A(0+k) , T2 -> A(0+0) , S -> A(0+k*(k+1)); lda=k */
  834. ij = 0;
  835. j = k;
  836. i__1 = *n - 1;
  837. for (i__ = k; i__ <= i__1; ++i__) {
  838. i__2 = ij;
  839. i__3 = i__ + j * a_dim1;
  840. arf[i__2].r = a[i__3].r, arf[i__2].i = a[i__3].i;
  841. ++ij;
  842. }
  843. i__1 = k - 2;
  844. for (j = 0; j <= i__1; ++j) {
  845. i__2 = j;
  846. for (i__ = 0; i__ <= i__2; ++i__) {
  847. i__3 = ij;
  848. r_cnjg(&q__1, &a[j + i__ * a_dim1]);
  849. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  850. ++ij;
  851. }
  852. i__2 = *n - 1;
  853. for (i__ = k + 1 + j; i__ <= i__2; ++i__) {
  854. i__3 = ij;
  855. i__4 = i__ + (k + 1 + j) * a_dim1;
  856. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  857. ++ij;
  858. }
  859. }
  860. i__1 = *n - 1;
  861. for (j = k - 1; j <= i__1; ++j) {
  862. i__2 = k - 1;
  863. for (i__ = 0; i__ <= i__2; ++i__) {
  864. i__3 = ij;
  865. r_cnjg(&q__1, &a[j + i__ * a_dim1]);
  866. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  867. ++ij;
  868. }
  869. }
  870. } else {
  871. /* SRPA for UPPER, TRANSPOSE and N is even (see paper, A=B) */
  872. /* T1 -> A(0,k+1) , T2 -> A(0,k) , S -> A(0,0) */
  873. /* T1 -> A(0+k*(k+1)) , T2 -> A(0+k*k) , S -> A(0+0)); lda=k */
  874. ij = 0;
  875. i__1 = k;
  876. for (j = 0; j <= i__1; ++j) {
  877. i__2 = *n - 1;
  878. for (i__ = k; i__ <= i__2; ++i__) {
  879. i__3 = ij;
  880. r_cnjg(&q__1, &a[j + i__ * a_dim1]);
  881. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  882. ++ij;
  883. }
  884. }
  885. i__1 = k - 2;
  886. for (j = 0; j <= i__1; ++j) {
  887. i__2 = j;
  888. for (i__ = 0; i__ <= i__2; ++i__) {
  889. i__3 = ij;
  890. i__4 = i__ + j * a_dim1;
  891. arf[i__3].r = a[i__4].r, arf[i__3].i = a[i__4].i;
  892. ++ij;
  893. }
  894. i__2 = *n - 1;
  895. for (l = k + 1 + j; l <= i__2; ++l) {
  896. i__3 = ij;
  897. r_cnjg(&q__1, &a[k + 1 + j + l * a_dim1]);
  898. arf[i__3].r = q__1.r, arf[i__3].i = q__1.i;
  899. ++ij;
  900. }
  901. }
  902. /* Note that here J = K-1 */
  903. i__1 = j;
  904. for (i__ = 0; i__ <= i__1; ++i__) {
  905. i__2 = ij;
  906. i__3 = i__ + j * a_dim1;
  907. arf[i__2].r = a[i__3].r, arf[i__2].i = a[i__3].i;
  908. ++ij;
  909. }
  910. }
  911. }
  912. }
  913. return 0;
  914. /* End of CTRTTF */
  915. } /* ctrttf_ */