zdrot.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* zdrot.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 zdrot_(integer *n, doublecomplex *cx, integer *incx,
  14. doublecomplex *cy, integer *incy, doublereal *c__, doublereal *s)
  15. {
  16. /* System generated locals */
  17. integer i__1, i__2, i__3, i__4;
  18. doublecomplex z__1, z__2, z__3;
  19. /* Local variables */
  20. integer i__, ix, iy;
  21. doublecomplex ctemp;
  22. /* .. Scalar Arguments .. */
  23. /* .. */
  24. /* .. Array Arguments .. */
  25. /* .. */
  26. /* Purpose */
  27. /* ======= */
  28. /* Applies a plane rotation, where the cos and sin (c and s) are real */
  29. /* and the vectors cx and cy are complex. */
  30. /* jack dongarra, linpack, 3/11/78. */
  31. /* Arguments */
  32. /* ========== */
  33. /* N (input) INTEGER */
  34. /* On entry, N specifies the order of the vectors cx and cy. */
  35. /* N must be at least zero. */
  36. /* Unchanged on exit. */
  37. /* CX (input) COMPLEX*16 array, dimension at least */
  38. /* ( 1 + ( N - 1 )*abs( INCX ) ). */
  39. /* Before entry, the incremented array CX must contain the n */
  40. /* element vector cx. On exit, CX is overwritten by the updated */
  41. /* vector cx. */
  42. /* INCX (input) INTEGER */
  43. /* On entry, INCX specifies the increment for the elements of */
  44. /* CX. INCX must not be zero. */
  45. /* Unchanged on exit. */
  46. /* CY (input) COMPLEX*16 array, dimension at least */
  47. /* ( 1 + ( N - 1 )*abs( INCY ) ). */
  48. /* Before entry, the incremented array CY must contain the n */
  49. /* element vector cy. On exit, CY is overwritten by the updated */
  50. /* vector cy. */
  51. /* INCY (input) INTEGER */
  52. /* On entry, INCY specifies the increment for the elements of */
  53. /* CY. INCY must not be zero. */
  54. /* Unchanged on exit. */
  55. /* C (input) DOUBLE PRECISION */
  56. /* On entry, C specifies the cosine, cos. */
  57. /* Unchanged on exit. */
  58. /* S (input) DOUBLE PRECISION */
  59. /* On entry, S specifies the sine, sin. */
  60. /* Unchanged on exit. */
  61. /* ===================================================================== */
  62. /* .. Local Scalars .. */
  63. /* .. */
  64. /* .. Executable Statements .. */
  65. /* Parameter adjustments */
  66. --cy;
  67. --cx;
  68. /* Function Body */
  69. if (*n <= 0) {
  70. return 0;
  71. }
  72. if (*incx == 1 && *incy == 1) {
  73. goto L20;
  74. }
  75. /* code for unequal increments or equal increments not equal */
  76. /* to 1 */
  77. ix = 1;
  78. iy = 1;
  79. if (*incx < 0) {
  80. ix = (-(*n) + 1) * *incx + 1;
  81. }
  82. if (*incy < 0) {
  83. iy = (-(*n) + 1) * *incy + 1;
  84. }
  85. i__1 = *n;
  86. for (i__ = 1; i__ <= i__1; ++i__) {
  87. i__2 = ix;
  88. z__2.r = *c__ * cx[i__2].r, z__2.i = *c__ * cx[i__2].i;
  89. i__3 = iy;
  90. z__3.r = *s * cy[i__3].r, z__3.i = *s * cy[i__3].i;
  91. z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
  92. ctemp.r = z__1.r, ctemp.i = z__1.i;
  93. i__2 = iy;
  94. i__3 = iy;
  95. z__2.r = *c__ * cy[i__3].r, z__2.i = *c__ * cy[i__3].i;
  96. i__4 = ix;
  97. z__3.r = *s * cx[i__4].r, z__3.i = *s * cx[i__4].i;
  98. z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
  99. cy[i__2].r = z__1.r, cy[i__2].i = z__1.i;
  100. i__2 = ix;
  101. cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i;
  102. ix += *incx;
  103. iy += *incy;
  104. /* L10: */
  105. }
  106. return 0;
  107. /* code for both increments equal to 1 */
  108. L20:
  109. i__1 = *n;
  110. for (i__ = 1; i__ <= i__1; ++i__) {
  111. i__2 = i__;
  112. z__2.r = *c__ * cx[i__2].r, z__2.i = *c__ * cx[i__2].i;
  113. i__3 = i__;
  114. z__3.r = *s * cy[i__3].r, z__3.i = *s * cy[i__3].i;
  115. z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
  116. ctemp.r = z__1.r, ctemp.i = z__1.i;
  117. i__2 = i__;
  118. i__3 = i__;
  119. z__2.r = *c__ * cy[i__3].r, z__2.i = *c__ * cy[i__3].i;
  120. i__4 = i__;
  121. z__3.r = *s * cx[i__4].r, z__3.i = *s * cx[i__4].i;
  122. z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
  123. cy[i__2].r = z__1.r, cy[i__2].i = z__1.i;
  124. i__2 = i__;
  125. cx[i__2].r = ctemp.r, cx[i__2].i = ctemp.i;
  126. /* L30: */
  127. }
  128. return 0;
  129. } /* zdrot_ */