drotm.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /* drotm.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 drotm_(integer *n, doublereal *dx, integer *incx,
  14. doublereal *dy, integer *incy, doublereal *dparam)
  15. {
  16. /* Initialized data */
  17. static doublereal zero = 0.;
  18. static doublereal two = 2.;
  19. /* System generated locals */
  20. integer i__1, i__2;
  21. /* Local variables */
  22. integer i__;
  23. doublereal w, z__;
  24. integer kx, ky;
  25. doublereal dh11, dh12, dh21, dh22, dflag;
  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. /* (DX**T) , WHERE **T INDICATES TRANSPOSE. THE ELEMENTS OF DX ARE IN */
  35. /* (DY**T) */
  36. /* DX(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 LY AND INCY. */
  38. /* WITH DPARAM(1)=DFLAG, H HAS ONE OF THE FOLLOWING FORMS.. */
  39. /* DFLAG=-1.D0 DFLAG=0.D0 DFLAG=1.D0 DFLAG=-2.D0 */
  40. /* (DH11 DH12) (1.D0 DH12) (DH11 1.D0) (1.D0 0.D0) */
  41. /* H=( ) ( ) ( ) ( ) */
  42. /* (DH21 DH22), (DH21 1.D0), (-1.D0 DH22), (0.D0 1.D0). */
  43. /* SEE DROTMG FOR A DESCRIPTION OF DATA STORAGE IN DPARAM. */
  44. /* Arguments */
  45. /* ========= */
  46. /* N (input) INTEGER */
  47. /* number of elements in input vector(s) */
  48. /* DX (input/output) DOUBLE PRECISION array, dimension N */
  49. /* double precision vector with N elements */
  50. /* INCX (input) INTEGER */
  51. /* storage spacing between elements of DX */
  52. /* DY (input/output) DOUBLE PRECISION array, dimension N */
  53. /* double precision vector with N elements */
  54. /* INCY (input) INTEGER */
  55. /* storage spacing between elements of DY */
  56. /* DPARAM (input/output) DOUBLE PRECISION array, dimension 5 */
  57. /* DPARAM(1)=DFLAG */
  58. /* DPARAM(2)=DH11 */
  59. /* DPARAM(3)=DH21 */
  60. /* DPARAM(4)=DH12 */
  61. /* DPARAM(5)=DH22 */
  62. /* ===================================================================== */
  63. /* .. Local Scalars .. */
  64. /* .. */
  65. /* .. Data statements .. */
  66. /* Parameter adjustments */
  67. --dparam;
  68. --dy;
  69. --dx;
  70. /* Function Body */
  71. /* .. */
  72. dflag = dparam[1];
  73. if (*n <= 0 || dflag + two == zero) {
  74. goto L140;
  75. }
  76. if (! (*incx == *incy && *incx > 0)) {
  77. goto L70;
  78. }
  79. nsteps = *n * *incx;
  80. if (dflag < 0.) {
  81. goto L50;
  82. } else if (dflag == 0) {
  83. goto L10;
  84. } else {
  85. goto L30;
  86. }
  87. L10:
  88. dh12 = dparam[4];
  89. dh21 = dparam[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 = dx[i__];
  94. z__ = dy[i__];
  95. dx[i__] = w + z__ * dh12;
  96. dy[i__] = w * dh21 + z__;
  97. /* L20: */
  98. }
  99. goto L140;
  100. L30:
  101. dh11 = dparam[2];
  102. dh22 = dparam[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 = dx[i__];
  107. z__ = dy[i__];
  108. dx[i__] = w * dh11 + z__;
  109. dy[i__] = -w + dh22 * z__;
  110. /* L40: */
  111. }
  112. goto L140;
  113. L50:
  114. dh11 = dparam[2];
  115. dh12 = dparam[4];
  116. dh21 = dparam[3];
  117. dh22 = dparam[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 = dx[i__];
  122. z__ = dy[i__];
  123. dx[i__] = w * dh11 + z__ * dh12;
  124. dy[i__] = w * dh21 + z__ * dh22;
  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 (dflag < 0.) {
  138. goto L120;
  139. } else if (dflag == 0) {
  140. goto L80;
  141. } else {
  142. goto L100;
  143. }
  144. L80:
  145. dh12 = dparam[4];
  146. dh21 = dparam[3];
  147. i__2 = *n;
  148. for (i__ = 1; i__ <= i__2; ++i__) {
  149. w = dx[kx];
  150. z__ = dy[ky];
  151. dx[kx] = w + z__ * dh12;
  152. dy[ky] = w * dh21 + z__;
  153. kx += *incx;
  154. ky += *incy;
  155. /* L90: */
  156. }
  157. goto L140;
  158. L100:
  159. dh11 = dparam[2];
  160. dh22 = dparam[5];
  161. i__2 = *n;
  162. for (i__ = 1; i__ <= i__2; ++i__) {
  163. w = dx[kx];
  164. z__ = dy[ky];
  165. dx[kx] = w * dh11 + z__;
  166. dy[ky] = -w + dh22 * z__;
  167. kx += *incx;
  168. ky += *incy;
  169. /* L110: */
  170. }
  171. goto L140;
  172. L120:
  173. dh11 = dparam[2];
  174. dh12 = dparam[4];
  175. dh21 = dparam[3];
  176. dh22 = dparam[5];
  177. i__2 = *n;
  178. for (i__ = 1; i__ <= i__2; ++i__) {
  179. w = dx[kx];
  180. z__ = dy[ky];
  181. dx[kx] = w * dh11 + z__ * dh12;
  182. dy[ky] = w * dh21 + z__ * dh22;
  183. kx += *incx;
  184. ky += *incy;
  185. /* L130: */
  186. }
  187. L140:
  188. return 0;
  189. } /* drotm_ */