dswap.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* dswap.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 dswap_(integer *n, doublereal *dx, integer *incx,
  14. doublereal *dy, integer *incy)
  15. {
  16. /* System generated locals */
  17. integer i__1;
  18. /* Local variables */
  19. integer i__, m, ix, iy, mp1;
  20. doublereal dtemp;
  21. /* .. Scalar Arguments .. */
  22. /* .. */
  23. /* .. Array Arguments .. */
  24. /* .. */
  25. /* Purpose */
  26. /* ======= */
  27. /* interchanges two vectors. */
  28. /* uses unrolled loops for increments equal one. */
  29. /* jack dongarra, linpack, 3/11/78. */
  30. /* modified 12/3/93, array(1) declarations changed to array(*) */
  31. /* .. Local Scalars .. */
  32. /* .. */
  33. /* .. Intrinsic Functions .. */
  34. /* .. */
  35. /* Parameter adjustments */
  36. --dy;
  37. --dx;
  38. /* Function Body */
  39. if (*n <= 0) {
  40. return 0;
  41. }
  42. if (*incx == 1 && *incy == 1) {
  43. goto L20;
  44. }
  45. /* code for unequal increments or equal increments not equal */
  46. /* to 1 */
  47. ix = 1;
  48. iy = 1;
  49. if (*incx < 0) {
  50. ix = (-(*n) + 1) * *incx + 1;
  51. }
  52. if (*incy < 0) {
  53. iy = (-(*n) + 1) * *incy + 1;
  54. }
  55. i__1 = *n;
  56. for (i__ = 1; i__ <= i__1; ++i__) {
  57. dtemp = dx[ix];
  58. dx[ix] = dy[iy];
  59. dy[iy] = dtemp;
  60. ix += *incx;
  61. iy += *incy;
  62. /* L10: */
  63. }
  64. return 0;
  65. /* code for both increments equal to 1 */
  66. /* clean-up loop */
  67. L20:
  68. m = *n % 3;
  69. if (m == 0) {
  70. goto L40;
  71. }
  72. i__1 = m;
  73. for (i__ = 1; i__ <= i__1; ++i__) {
  74. dtemp = dx[i__];
  75. dx[i__] = dy[i__];
  76. dy[i__] = dtemp;
  77. /* L30: */
  78. }
  79. if (*n < 3) {
  80. return 0;
  81. }
  82. L40:
  83. mp1 = m + 1;
  84. i__1 = *n;
  85. for (i__ = mp1; i__ <= i__1; i__ += 3) {
  86. dtemp = dx[i__];
  87. dx[i__] = dy[i__];
  88. dy[i__] = dtemp;
  89. dtemp = dx[i__ + 1];
  90. dx[i__ + 1] = dy[i__ + 1];
  91. dy[i__ + 1] = dtemp;
  92. dtemp = dx[i__ + 2];
  93. dx[i__ + 2] = dy[i__ + 2];
  94. dy[i__ + 2] = dtemp;
  95. /* L50: */
  96. }
  97. return 0;
  98. } /* dswap_ */