srotm.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /* srotm.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 srotm_(integer *n, real *sx, integer *incx, real *sy,
  14. integer *incy, real *sparam)
  15. {
  16. /* Initialized data */
  17. static real zero = 0.f;
  18. static real two = 2.f;
  19. /* System generated locals */
  20. integer i__1, i__2;
  21. /* Local variables */
  22. integer i__;
  23. real w, z__;
  24. integer kx, ky;
  25. real sh11, sh12, sh21, sh22, sflag;
  26. integer nsteps;
  27. /* .. Scalar Arguments .. */
  28. /* .. */
  29. /* .. Array Arguments .. */
  30. /* .. */
  31. /* Purpose */
  32. /* ======= */
  33. /* APPLY THE MODIFIED GIVENS TRANSFORMATION, H, TO THE 2 BY N MATRIX */
  34. /* (SX**T) , WHERE **T INDICATES TRANSPOSE. THE ELEMENTS OF SX ARE IN */
  35. /* (DX**T) */
  36. /* SX(LX+I*INCX), I = 0 TO N-1, WHERE LX = 1 IF INCX .GE. 0, ELSE */
  37. /* LX = (-INCX)*N, AND SIMILARLY FOR SY USING USING LY AND INCY. */
  38. /* WITH SPARAM(1)=SFLAG, H HAS ONE OF THE FOLLOWING FORMS.. */
  39. /* SFLAG=-1.E0 SFLAG=0.E0 SFLAG=1.E0 SFLAG=-2.E0 */
  40. /* (SH11 SH12) (1.E0 SH12) (SH11 1.E0) (1.E0 0.E0) */
  41. /* H=( ) ( ) ( ) ( ) */
  42. /* (SH21 SH22), (SH21 1.E0), (-1.E0 SH22), (0.E0 1.E0). */
  43. /* SEE SROTMG FOR A DESCRIPTION OF DATA STORAGE IN SPARAM. */
  44. /* Arguments */
  45. /* ========= */
  46. /* N (input) INTEGER */
  47. /* number of elements in input vector(s) */
  48. /* SX (input/output) REAL array, dimension N */
  49. /* double precision vector with N elements */
  50. /* INCX (input) INTEGER */
  51. /* storage spacing between elements of SX */
  52. /* SY (input/output) REAL array, dimension N */
  53. /* double precision vector with N elements */
  54. /* INCY (input) INTEGER */
  55. /* storage spacing between elements of SY */
  56. /* SPARAM (input/output) REAL array, dimension 5 */
  57. /* SPARAM(1)=SFLAG */
  58. /* SPARAM(2)=SH11 */
  59. /* SPARAM(3)=SH21 */
  60. /* SPARAM(4)=SH12 */
  61. /* SPARAM(5)=SH22 */
  62. /* ===================================================================== */
  63. /* .. Local Scalars .. */
  64. /* .. */
  65. /* .. Data statements .. */
  66. /* Parameter adjustments */
  67. --sparam;
  68. --sy;
  69. --sx;
  70. /* Function Body */
  71. /* .. */
  72. sflag = sparam[1];
  73. if (*n <= 0 || sflag + two == zero) {
  74. goto L140;
  75. }
  76. if (! (*incx == *incy && *incx > 0)) {
  77. goto L70;
  78. }
  79. nsteps = *n * *incx;
  80. if (sflag < 0.f) {
  81. goto L50;
  82. } else if (sflag == 0) {
  83. goto L10;
  84. } else {
  85. goto L30;
  86. }
  87. L10:
  88. sh12 = sparam[4];
  89. sh21 = sparam[3];
  90. i__1 = nsteps;
  91. i__2 = *incx;
  92. for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  93. w = sx[i__];
  94. z__ = sy[i__];
  95. sx[i__] = w + z__ * sh12;
  96. sy[i__] = w * sh21 + z__;
  97. /* L20: */
  98. }
  99. goto L140;
  100. L30:
  101. sh11 = sparam[2];
  102. sh22 = sparam[5];
  103. i__2 = nsteps;
  104. i__1 = *incx;
  105. for (i__ = 1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) {
  106. w = sx[i__];
  107. z__ = sy[i__];
  108. sx[i__] = w * sh11 + z__;
  109. sy[i__] = -w + sh22 * z__;
  110. /* L40: */
  111. }
  112. goto L140;
  113. L50:
  114. sh11 = sparam[2];
  115. sh12 = sparam[4];
  116. sh21 = sparam[3];
  117. sh22 = sparam[5];
  118. i__1 = nsteps;
  119. i__2 = *incx;
  120. for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  121. w = sx[i__];
  122. z__ = sy[i__];
  123. sx[i__] = w * sh11 + z__ * sh12;
  124. sy[i__] = w * sh21 + z__ * sh22;
  125. /* L60: */
  126. }
  127. goto L140;
  128. L70:
  129. kx = 1;
  130. ky = 1;
  131. if (*incx < 0) {
  132. kx = (1 - *n) * *incx + 1;
  133. }
  134. if (*incy < 0) {
  135. ky = (1 - *n) * *incy + 1;
  136. }
  137. if (sflag < 0.f) {
  138. goto L120;
  139. } else if (sflag == 0) {
  140. goto L80;
  141. } else {
  142. goto L100;
  143. }
  144. L80:
  145. sh12 = sparam[4];
  146. sh21 = sparam[3];
  147. i__2 = *n;
  148. for (i__ = 1; i__ <= i__2; ++i__) {
  149. w = sx[kx];
  150. z__ = sy[ky];
  151. sx[kx] = w + z__ * sh12;
  152. sy[ky] = w * sh21 + z__;
  153. kx += *incx;
  154. ky += *incy;
  155. /* L90: */
  156. }
  157. goto L140;
  158. L100:
  159. sh11 = sparam[2];
  160. sh22 = sparam[5];
  161. i__2 = *n;
  162. for (i__ = 1; i__ <= i__2; ++i__) {
  163. w = sx[kx];
  164. z__ = sy[ky];
  165. sx[kx] = w * sh11 + z__;
  166. sy[ky] = -w + sh22 * z__;
  167. kx += *incx;
  168. ky += *incy;
  169. /* L110: */
  170. }
  171. goto L140;
  172. L120:
  173. sh11 = sparam[2];
  174. sh12 = sparam[4];
  175. sh21 = sparam[3];
  176. sh22 = sparam[5];
  177. i__2 = *n;
  178. for (i__ = 1; i__ <= i__2; ++i__) {
  179. w = sx[kx];
  180. z__ = sy[ky];
  181. sx[kx] = w * sh11 + z__ * sh12;
  182. sy[ky] = w * sh21 + z__ * sh22;
  183. kx += *incx;
  184. ky += *incy;
  185. /* L130: */
  186. }
  187. L140:
  188. return 0;
  189. } /* srotm_ */