dlapmt.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* dlapmt.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_dlapmt_(logical *forwrd, integer *m, integer *n,
  14. doublereal *x, integer *ldx, integer *k)
  15. {
  16. /* System generated locals */
  17. integer x_dim1, x_offset, i__1, i__2;
  18. /* Local variables */
  19. integer i__, j, ii, in;
  20. doublereal temp;
  21. /* -- LAPACK auxiliary routine (version 3.2) -- */
  22. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  23. /* November 2006 */
  24. /* .. Scalar Arguments .. */
  25. /* .. */
  26. /* .. Array Arguments .. */
  27. /* .. */
  28. /* Purpose */
  29. /* ======= */
  30. /* DLAPMT rearranges the columns of the M by N matrix X as specified */
  31. /* by the permutation K(1),K(2),...,K(N) of the integers 1,...,N. */
  32. /* If FORWRD = .TRUE., forward permutation: */
  33. /* X(*,K(J)) is moved X(*,J) for J = 1,2,...,N. */
  34. /* If FORWRD = .FALSE., backward permutation: */
  35. /* X(*,J) is moved to X(*,K(J)) for J = 1,2,...,N. */
  36. /* Arguments */
  37. /* ========= */
  38. /* FORWRD (input) LOGICAL */
  39. /* = .TRUE., forward permutation */
  40. /* = .FALSE., backward permutation */
  41. /* M (input) INTEGER */
  42. /* The number of rows of the matrix X. M >= 0. */
  43. /* N (input) INTEGER */
  44. /* The number of columns of the matrix X. N >= 0. */
  45. /* X (input/output) DOUBLE PRECISION array, dimension (LDX,N) */
  46. /* On entry, the M by N matrix X. */
  47. /* On exit, X contains the permuted matrix X. */
  48. /* LDX (input) INTEGER */
  49. /* The leading dimension of the array X, LDX >= MAX(1,M). */
  50. /* K (input/output) INTEGER array, dimension (N) */
  51. /* On entry, K contains the permutation vector. K is used as */
  52. /* internal workspace, but reset to its original value on */
  53. /* output. */
  54. /* ===================================================================== */
  55. /* .. Local Scalars .. */
  56. /* .. */
  57. /* .. Executable Statements .. */
  58. /* Parameter adjustments */
  59. x_dim1 = *ldx;
  60. x_offset = 1 + x_dim1;
  61. x -= x_offset;
  62. --k;
  63. /* Function Body */
  64. if (*n <= 1) {
  65. return 0;
  66. }
  67. i__1 = *n;
  68. for (i__ = 1; i__ <= i__1; ++i__) {
  69. k[i__] = -k[i__];
  70. /* L10: */
  71. }
  72. if (*forwrd) {
  73. /* Forward permutation */
  74. i__1 = *n;
  75. for (i__ = 1; i__ <= i__1; ++i__) {
  76. if (k[i__] > 0) {
  77. goto L40;
  78. }
  79. j = i__;
  80. k[j] = -k[j];
  81. in = k[j];
  82. L20:
  83. if (k[in] > 0) {
  84. goto L40;
  85. }
  86. i__2 = *m;
  87. for (ii = 1; ii <= i__2; ++ii) {
  88. temp = x[ii + j * x_dim1];
  89. x[ii + j * x_dim1] = x[ii + in * x_dim1];
  90. x[ii + in * x_dim1] = temp;
  91. /* L30: */
  92. }
  93. k[in] = -k[in];
  94. j = in;
  95. in = k[in];
  96. goto L20;
  97. L40:
  98. /* L50: */
  99. ;
  100. }
  101. } else {
  102. /* Backward permutation */
  103. i__1 = *n;
  104. for (i__ = 1; i__ <= i__1; ++i__) {
  105. if (k[i__] > 0) {
  106. goto L80;
  107. }
  108. k[i__] = -k[i__];
  109. j = k[i__];
  110. L60:
  111. if (j == i__) {
  112. goto L80;
  113. }
  114. i__2 = *m;
  115. for (ii = 1; ii <= i__2; ++ii) {
  116. temp = x[ii + i__ * x_dim1];
  117. x[ii + i__ * x_dim1] = x[ii + j * x_dim1];
  118. x[ii + j * x_dim1] = temp;
  119. /* L70: */
  120. }
  121. k[j] = -k[j];
  122. j = k[j];
  123. goto L60;
  124. L80:
  125. /* L90: */
  126. ;
  127. }
  128. }
  129. return 0;
  130. /* End of DLAPMT */
  131. } /* _starpu_dlapmt_ */