dtfttr.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. /* dtfttr.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Subroutine */ int _starpu_dtfttr_(char *transr, char *uplo, integer *n, doublereal
  14. *arf, doublereal *a, integer *lda, integer *info)
  15. {
  16. /* System generated locals */
  17. integer a_dim1, a_offset, i__1, i__2;
  18. /* Local variables */
  19. integer i__, j, k, l, n1, n2, ij, nt, nx2, np1x2;
  20. logical normaltransr;
  21. extern logical _starpu_lsame_(char *, char *);
  22. logical lower;
  23. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  24. logical nisodd;
  25. /* -- LAPACK routine (version 3.2) -- */
  26. /* -- Contributed by Fred Gustavson of the IBM Watson Research Center -- */
  27. /* -- November 2008 -- */
  28. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  29. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  30. /* .. Scalar Arguments .. */
  31. /* .. */
  32. /* .. Array Arguments .. */
  33. /* .. */
  34. /* Purpose */
  35. /* ======= */
  36. /* DTFTTR copies a triangular matrix A from rectangular full packed */
  37. /* format (TF) to standard full format (TR). */
  38. /* Arguments */
  39. /* ========= */
  40. /* TRANSR (input) CHARACTER */
  41. /* = 'N': ARF is in Normal format; */
  42. /* = 'T': ARF is in Transpose format. */
  43. /* UPLO (input) CHARACTER */
  44. /* = 'U': A is upper triangular; */
  45. /* = 'L': A is lower triangular. */
  46. /* N (input) INTEGER */
  47. /* The order of the matrices ARF and A. N >= 0. */
  48. /* ARF (input) DOUBLE PRECISION array, dimension (N*(N+1)/2). */
  49. /* On entry, the upper (if UPLO = 'U') or lower (if UPLO = 'L') */
  50. /* matrix A in RFP format. See the "Notes" below for more */
  51. /* details. */
  52. /* A (output) DOUBLE PRECISION array, dimension (LDA,N) */
  53. /* On exit, the triangular matrix A. If UPLO = 'U', the */
  54. /* leading N-by-N upper triangular part of the array A contains */
  55. /* the upper triangular matrix, and the strictly lower */
  56. /* triangular part of A is not referenced. If UPLO = 'L', the */
  57. /* leading N-by-N lower triangular part of the array A contains */
  58. /* the lower triangular matrix, and the strictly upper */
  59. /* triangular part of A is not referenced. */
  60. /* LDA (input) INTEGER */
  61. /* The leading dimension of the array A. LDA >= max(1,N). */
  62. /* INFO (output) INTEGER */
  63. /* = 0: successful exit */
  64. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  65. /* Notes */
  66. /* ===== */
  67. /* We first consider Rectangular Full Packed (RFP) Format when N is */
  68. /* even. We give an example where N = 6. */
  69. /* AP is Upper AP is Lower */
  70. /* 00 01 02 03 04 05 00 */
  71. /* 11 12 13 14 15 10 11 */
  72. /* 22 23 24 25 20 21 22 */
  73. /* 33 34 35 30 31 32 33 */
  74. /* 44 45 40 41 42 43 44 */
  75. /* 55 50 51 52 53 54 55 */
  76. /* Let TRANSR = 'N'. RFP holds AP as follows: */
  77. /* For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
  78. /* three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
  79. /* the transpose of the first three columns of AP upper. */
  80. /* For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
  81. /* three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
  82. /* the transpose of the last three columns of AP lower. */
  83. /* This covers the case N even and TRANSR = 'N'. */
  84. /* RFP A RFP A */
  85. /* 03 04 05 33 43 53 */
  86. /* 13 14 15 00 44 54 */
  87. /* 23 24 25 10 11 55 */
  88. /* 33 34 35 20 21 22 */
  89. /* 00 44 45 30 31 32 */
  90. /* 01 11 55 40 41 42 */
  91. /* 02 12 22 50 51 52 */
  92. /* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
  93. /* transpose of RFP A above. One therefore gets: */
  94. /* RFP A RFP A */
  95. /* 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */
  96. /* 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */
  97. /* 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */
  98. /* We first consider Rectangular Full Packed (RFP) Format when N is */
  99. /* odd. We give an example where N = 5. */
  100. /* AP is Upper AP is Lower */
  101. /* 00 01 02 03 04 00 */
  102. /* 11 12 13 14 10 11 */
  103. /* 22 23 24 20 21 22 */
  104. /* 33 34 30 31 32 33 */
  105. /* 44 40 41 42 43 44 */
  106. /* Let TRANSR = 'N'. RFP holds AP as follows: */
  107. /* For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
  108. /* three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
  109. /* the transpose of the first two columns of AP upper. */
  110. /* For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
  111. /* three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
  112. /* the transpose of the last two columns of AP lower. */
  113. /* This covers the case N odd and TRANSR = 'N'. */
  114. /* RFP A RFP A */
  115. /* 02 03 04 00 33 43 */
  116. /* 12 13 14 10 11 44 */
  117. /* 22 23 24 20 21 22 */
  118. /* 00 33 34 30 31 32 */
  119. /* 01 11 44 40 41 42 */
  120. /* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
  121. /* transpose of RFP A above. One therefore gets: */
  122. /* RFP A RFP A */
  123. /* 02 12 22 00 01 00 10 20 30 40 50 */
  124. /* 03 13 23 33 11 33 11 21 31 41 51 */
  125. /* 04 14 24 34 44 43 44 22 32 42 52 */
  126. /* Reference */
  127. /* ========= */
  128. /* ===================================================================== */
  129. /* .. */
  130. /* .. Local Scalars .. */
  131. /* .. */
  132. /* .. External Functions .. */
  133. /* .. */
  134. /* .. External Subroutines .. */
  135. /* .. */
  136. /* .. Intrinsic Functions .. */
  137. /* .. */
  138. /* .. Executable Statements .. */
  139. /* Test the input parameters. */
  140. /* Parameter adjustments */
  141. a_dim1 = *lda - 1 - 0 + 1;
  142. a_offset = 0 + a_dim1 * 0;
  143. a -= a_offset;
  144. /* Function Body */
  145. *info = 0;
  146. normaltransr = _starpu_lsame_(transr, "N");
  147. lower = _starpu_lsame_(uplo, "L");
  148. if (! normaltransr && ! _starpu_lsame_(transr, "T")) {
  149. *info = -1;
  150. } else if (! lower && ! _starpu_lsame_(uplo, "U")) {
  151. *info = -2;
  152. } else if (*n < 0) {
  153. *info = -3;
  154. } else if (*lda < max(1,*n)) {
  155. *info = -6;
  156. }
  157. if (*info != 0) {
  158. i__1 = -(*info);
  159. _starpu_xerbla_("DTFTTR", &i__1);
  160. return 0;
  161. }
  162. /* Quick return if possible */
  163. if (*n <= 1) {
  164. if (*n == 1) {
  165. a[0] = arf[0];
  166. }
  167. return 0;
  168. }
  169. /* Size of array ARF(0:nt-1) */
  170. nt = *n * (*n + 1) / 2;
  171. /* set N1 and N2 depending on LOWER: for N even N1=N2=K */
  172. if (lower) {
  173. n2 = *n / 2;
  174. n1 = *n - n2;
  175. } else {
  176. n1 = *n / 2;
  177. n2 = *n - n1;
  178. }
  179. /* If N is odd, set NISODD = .TRUE., LDA=N+1 and A is (N+1)--by--K2. */
  180. /* If N is even, set K = N/2 and NISODD = .FALSE., LDA=N and A is */
  181. /* N--by--(N+1)/2. */
  182. if (*n % 2 == 0) {
  183. k = *n / 2;
  184. nisodd = FALSE_;
  185. if (! lower) {
  186. np1x2 = *n + *n + 2;
  187. }
  188. } else {
  189. nisodd = TRUE_;
  190. if (! lower) {
  191. nx2 = *n + *n;
  192. }
  193. }
  194. if (nisodd) {
  195. /* N is odd */
  196. if (normaltransr) {
  197. /* N is odd and TRANSR = 'N' */
  198. if (lower) {
  199. /* N is odd, TRANSR = 'N', and UPLO = 'L' */
  200. ij = 0;
  201. i__1 = n2;
  202. for (j = 0; j <= i__1; ++j) {
  203. i__2 = n2 + j;
  204. for (i__ = n1; i__ <= i__2; ++i__) {
  205. a[n2 + j + i__ * a_dim1] = arf[ij];
  206. ++ij;
  207. }
  208. i__2 = *n - 1;
  209. for (i__ = j; i__ <= i__2; ++i__) {
  210. a[i__ + j * a_dim1] = arf[ij];
  211. ++ij;
  212. }
  213. }
  214. } else {
  215. /* N is odd, TRANSR = 'N', and UPLO = 'U' */
  216. ij = nt - *n;
  217. i__1 = n1;
  218. for (j = *n - 1; j >= i__1; --j) {
  219. i__2 = j;
  220. for (i__ = 0; i__ <= i__2; ++i__) {
  221. a[i__ + j * a_dim1] = arf[ij];
  222. ++ij;
  223. }
  224. i__2 = n1 - 1;
  225. for (l = j - n1; l <= i__2; ++l) {
  226. a[j - n1 + l * a_dim1] = arf[ij];
  227. ++ij;
  228. }
  229. ij -= nx2;
  230. }
  231. }
  232. } else {
  233. /* N is odd and TRANSR = 'T' */
  234. if (lower) {
  235. /* N is odd, TRANSR = 'T', and UPLO = 'L' */
  236. ij = 0;
  237. i__1 = n2 - 1;
  238. for (j = 0; j <= i__1; ++j) {
  239. i__2 = j;
  240. for (i__ = 0; i__ <= i__2; ++i__) {
  241. a[j + i__ * a_dim1] = arf[ij];
  242. ++ij;
  243. }
  244. i__2 = *n - 1;
  245. for (i__ = n1 + j; i__ <= i__2; ++i__) {
  246. a[i__ + (n1 + j) * a_dim1] = arf[ij];
  247. ++ij;
  248. }
  249. }
  250. i__1 = *n - 1;
  251. for (j = n2; j <= i__1; ++j) {
  252. i__2 = n1 - 1;
  253. for (i__ = 0; i__ <= i__2; ++i__) {
  254. a[j + i__ * a_dim1] = arf[ij];
  255. ++ij;
  256. }
  257. }
  258. } else {
  259. /* N is odd, TRANSR = 'T', and UPLO = 'U' */
  260. ij = 0;
  261. i__1 = n1;
  262. for (j = 0; j <= i__1; ++j) {
  263. i__2 = *n - 1;
  264. for (i__ = n1; i__ <= i__2; ++i__) {
  265. a[j + i__ * a_dim1] = arf[ij];
  266. ++ij;
  267. }
  268. }
  269. i__1 = n1 - 1;
  270. for (j = 0; j <= i__1; ++j) {
  271. i__2 = j;
  272. for (i__ = 0; i__ <= i__2; ++i__) {
  273. a[i__ + j * a_dim1] = arf[ij];
  274. ++ij;
  275. }
  276. i__2 = *n - 1;
  277. for (l = n2 + j; l <= i__2; ++l) {
  278. a[n2 + j + l * a_dim1] = arf[ij];
  279. ++ij;
  280. }
  281. }
  282. }
  283. }
  284. } else {
  285. /* N is even */
  286. if (normaltransr) {
  287. /* N is even and TRANSR = 'N' */
  288. if (lower) {
  289. /* N is even, TRANSR = 'N', and UPLO = 'L' */
  290. ij = 0;
  291. i__1 = k - 1;
  292. for (j = 0; j <= i__1; ++j) {
  293. i__2 = k + j;
  294. for (i__ = k; i__ <= i__2; ++i__) {
  295. a[k + j + i__ * a_dim1] = arf[ij];
  296. ++ij;
  297. }
  298. i__2 = *n - 1;
  299. for (i__ = j; i__ <= i__2; ++i__) {
  300. a[i__ + j * a_dim1] = arf[ij];
  301. ++ij;
  302. }
  303. }
  304. } else {
  305. /* N is even, TRANSR = 'N', and UPLO = 'U' */
  306. ij = nt - *n - 1;
  307. i__1 = k;
  308. for (j = *n - 1; j >= i__1; --j) {
  309. i__2 = j;
  310. for (i__ = 0; i__ <= i__2; ++i__) {
  311. a[i__ + j * a_dim1] = arf[ij];
  312. ++ij;
  313. }
  314. i__2 = k - 1;
  315. for (l = j - k; l <= i__2; ++l) {
  316. a[j - k + l * a_dim1] = arf[ij];
  317. ++ij;
  318. }
  319. ij -= np1x2;
  320. }
  321. }
  322. } else {
  323. /* N is even and TRANSR = 'T' */
  324. if (lower) {
  325. /* N is even, TRANSR = 'T', and UPLO = 'L' */
  326. ij = 0;
  327. j = k;
  328. i__1 = *n - 1;
  329. for (i__ = k; i__ <= i__1; ++i__) {
  330. a[i__ + j * a_dim1] = arf[ij];
  331. ++ij;
  332. }
  333. i__1 = k - 2;
  334. for (j = 0; j <= i__1; ++j) {
  335. i__2 = j;
  336. for (i__ = 0; i__ <= i__2; ++i__) {
  337. a[j + i__ * a_dim1] = arf[ij];
  338. ++ij;
  339. }
  340. i__2 = *n - 1;
  341. for (i__ = k + 1 + j; i__ <= i__2; ++i__) {
  342. a[i__ + (k + 1 + j) * a_dim1] = arf[ij];
  343. ++ij;
  344. }
  345. }
  346. i__1 = *n - 1;
  347. for (j = k - 1; j <= i__1; ++j) {
  348. i__2 = k - 1;
  349. for (i__ = 0; i__ <= i__2; ++i__) {
  350. a[j + i__ * a_dim1] = arf[ij];
  351. ++ij;
  352. }
  353. }
  354. } else {
  355. /* N is even, TRANSR = 'T', and UPLO = 'U' */
  356. ij = 0;
  357. i__1 = k;
  358. for (j = 0; j <= i__1; ++j) {
  359. i__2 = *n - 1;
  360. for (i__ = k; i__ <= i__2; ++i__) {
  361. a[j + i__ * a_dim1] = arf[ij];
  362. ++ij;
  363. }
  364. }
  365. i__1 = k - 2;
  366. for (j = 0; j <= i__1; ++j) {
  367. i__2 = j;
  368. for (i__ = 0; i__ <= i__2; ++i__) {
  369. a[i__ + j * a_dim1] = arf[ij];
  370. ++ij;
  371. }
  372. i__2 = *n - 1;
  373. for (l = k + 1 + j; l <= i__2; ++l) {
  374. a[k + 1 + j + l * a_dim1] = arf[ij];
  375. ++ij;
  376. }
  377. }
  378. /* Note that here, on exit of the loop, J = K-1 */
  379. i__1 = j;
  380. for (i__ = 0; i__ <= i__1; ++i__) {
  381. a[i__ + j * a_dim1] = arf[ij];
  382. ++ij;
  383. }
  384. }
  385. }
  386. }
  387. return 0;
  388. /* End of DTFTTR */
  389. } /* _starpu_dtfttr_ */