drotmg.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /* drotmg.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 drotmg_(doublereal *dd1, doublereal *dd2, doublereal *
  14. dx1, doublereal *dy1, doublereal *dparam)
  15. {
  16. /* Initialized data */
  17. static doublereal zero = 0.;
  18. static doublereal one = 1.;
  19. static doublereal two = 2.;
  20. static doublereal gam = 4096.;
  21. static doublereal gamsq = 16777216.;
  22. static doublereal rgamsq = 5.9604645e-8;
  23. /* Format strings */
  24. static char fmt_120[] = "";
  25. static char fmt_150[] = "";
  26. static char fmt_180[] = "";
  27. static char fmt_210[] = "";
  28. /* System generated locals */
  29. doublereal d__1;
  30. /* Local variables */
  31. doublereal du, dp1, dp2, dq1, dq2, dh11, dh12, dh21, dh22;
  32. integer igo;
  33. doublereal dflag, dtemp;
  34. /* Assigned format variables */
  35. static char *igo_fmt;
  36. /* .. Scalar Arguments .. */
  37. /* .. */
  38. /* .. Array Arguments .. */
  39. /* .. */
  40. /* Purpose */
  41. /* ======= */
  42. /* CONSTRUCT THE MODIFIED GIVENS TRANSFORMATION MATRIX H WHICH ZEROS */
  43. /* THE SECOND COMPONENT OF THE 2-VECTOR (DSQRT(DD1)*DX1,DSQRT(DD2)* */
  44. /* DY2)**T. */
  45. /* WITH DPARAM(1)=DFLAG, H HAS ONE OF THE FOLLOWING FORMS.. */
  46. /* DFLAG=-1.D0 DFLAG=0.D0 DFLAG=1.D0 DFLAG=-2.D0 */
  47. /* (DH11 DH12) (1.D0 DH12) (DH11 1.D0) (1.D0 0.D0) */
  48. /* H=( ) ( ) ( ) ( ) */
  49. /* (DH21 DH22), (DH21 1.D0), (-1.D0 DH22), (0.D0 1.D0). */
  50. /* LOCATIONS 2-4 OF DPARAM CONTAIN DH11, DH21, DH12, AND DH22 */
  51. /* RESPECTIVELY. (VALUES OF 1.D0, -1.D0, OR 0.D0 IMPLIED BY THE */
  52. /* VALUE OF DPARAM(1) ARE NOT STORED IN DPARAM.) */
  53. /* THE VALUES OF GAMSQ AND RGAMSQ SET IN THE DATA STATEMENT MAY BE */
  54. /* INEXACT. THIS IS OK AS THEY ARE ONLY USED FOR TESTING THE SIZE */
  55. /* OF DD1 AND DD2. ALL ACTUAL SCALING OF DATA IS DONE USING GAM. */
  56. /* Arguments */
  57. /* ========= */
  58. /* DD1 (input/output) DOUBLE PRECISION */
  59. /* DD2 (input/output) DOUBLE PRECISION */
  60. /* DX1 (input/output) DOUBLE PRECISION */
  61. /* DY1 (input) DOUBLE PRECISION */
  62. /* DPARAM (input/output) DOUBLE PRECISION array, dimension 5 */
  63. /* DPARAM(1)=DFLAG */
  64. /* DPARAM(2)=DH11 */
  65. /* DPARAM(3)=DH21 */
  66. /* DPARAM(4)=DH12 */
  67. /* DPARAM(5)=DH22 */
  68. /* ===================================================================== */
  69. /* .. Local Scalars .. */
  70. /* .. */
  71. /* .. Intrinsic Functions .. */
  72. /* .. */
  73. /* .. Data statements .. */
  74. /* Parameter adjustments */
  75. --dparam;
  76. /* Function Body */
  77. /* .. */
  78. if (! (*dd1 < zero)) {
  79. goto L10;
  80. }
  81. /* GO ZERO-H-D-AND-DX1.. */
  82. goto L60;
  83. L10:
  84. /* CASE-DD1-NONNEGATIVE */
  85. dp2 = *dd2 * *dy1;
  86. if (! (dp2 == zero)) {
  87. goto L20;
  88. }
  89. dflag = -two;
  90. goto L260;
  91. /* REGULAR-CASE.. */
  92. L20:
  93. dp1 = *dd1 * *dx1;
  94. dq2 = dp2 * *dy1;
  95. dq1 = dp1 * *dx1;
  96. if (! (abs(dq1) > abs(dq2))) {
  97. goto L40;
  98. }
  99. dh21 = -(*dy1) / *dx1;
  100. dh12 = dp2 / dp1;
  101. du = one - dh12 * dh21;
  102. if (! (du <= zero)) {
  103. goto L30;
  104. }
  105. /* GO ZERO-H-D-AND-DX1.. */
  106. goto L60;
  107. L30:
  108. dflag = zero;
  109. *dd1 /= du;
  110. *dd2 /= du;
  111. *dx1 *= du;
  112. /* GO SCALE-CHECK.. */
  113. goto L100;
  114. L40:
  115. if (! (dq2 < zero)) {
  116. goto L50;
  117. }
  118. /* GO ZERO-H-D-AND-DX1.. */
  119. goto L60;
  120. L50:
  121. dflag = one;
  122. dh11 = dp1 / dp2;
  123. dh22 = *dx1 / *dy1;
  124. du = one + dh11 * dh22;
  125. dtemp = *dd2 / du;
  126. *dd2 = *dd1 / du;
  127. *dd1 = dtemp;
  128. *dx1 = *dy1 * du;
  129. /* GO SCALE-CHECK */
  130. goto L100;
  131. /* PROCEDURE..ZERO-H-D-AND-DX1.. */
  132. L60:
  133. dflag = -one;
  134. dh11 = zero;
  135. dh12 = zero;
  136. dh21 = zero;
  137. dh22 = zero;
  138. *dd1 = zero;
  139. *dd2 = zero;
  140. *dx1 = zero;
  141. /* RETURN.. */
  142. goto L220;
  143. /* PROCEDURE..FIX-H.. */
  144. L70:
  145. if (! (dflag >= zero)) {
  146. goto L90;
  147. }
  148. if (! (dflag == zero)) {
  149. goto L80;
  150. }
  151. dh11 = one;
  152. dh22 = one;
  153. dflag = -one;
  154. goto L90;
  155. L80:
  156. dh21 = -one;
  157. dh12 = one;
  158. dflag = -one;
  159. L90:
  160. switch (igo) {
  161. case 0: goto L120;
  162. case 1: goto L150;
  163. case 2: goto L180;
  164. case 3: goto L210;
  165. }
  166. /* PROCEDURE..SCALE-CHECK */
  167. L100:
  168. L110:
  169. if (! (*dd1 <= rgamsq)) {
  170. goto L130;
  171. }
  172. if (*dd1 == zero) {
  173. goto L160;
  174. }
  175. igo = 0;
  176. igo_fmt = fmt_120;
  177. /* FIX-H.. */
  178. goto L70;
  179. L120:
  180. /* Computing 2nd power */
  181. d__1 = gam;
  182. *dd1 *= d__1 * d__1;
  183. *dx1 /= gam;
  184. dh11 /= gam;
  185. dh12 /= gam;
  186. goto L110;
  187. L130:
  188. L140:
  189. if (! (*dd1 >= gamsq)) {
  190. goto L160;
  191. }
  192. igo = 1;
  193. igo_fmt = fmt_150;
  194. /* FIX-H.. */
  195. goto L70;
  196. L150:
  197. /* Computing 2nd power */
  198. d__1 = gam;
  199. *dd1 /= d__1 * d__1;
  200. *dx1 *= gam;
  201. dh11 *= gam;
  202. dh12 *= gam;
  203. goto L140;
  204. L160:
  205. L170:
  206. if (! (abs(*dd2) <= rgamsq)) {
  207. goto L190;
  208. }
  209. if (*dd2 == zero) {
  210. goto L220;
  211. }
  212. igo = 2;
  213. igo_fmt = fmt_180;
  214. /* FIX-H.. */
  215. goto L70;
  216. L180:
  217. /* Computing 2nd power */
  218. d__1 = gam;
  219. *dd2 *= d__1 * d__1;
  220. dh21 /= gam;
  221. dh22 /= gam;
  222. goto L170;
  223. L190:
  224. L200:
  225. if (! (abs(*dd2) >= gamsq)) {
  226. goto L220;
  227. }
  228. igo = 3;
  229. igo_fmt = fmt_210;
  230. /* FIX-H.. */
  231. goto L70;
  232. L210:
  233. /* Computing 2nd power */
  234. d__1 = gam;
  235. *dd2 /= d__1 * d__1;
  236. dh21 *= gam;
  237. dh22 *= gam;
  238. goto L200;
  239. L220:
  240. if (dflag < 0.) {
  241. goto L250;
  242. } else if (dflag == 0) {
  243. goto L230;
  244. } else {
  245. goto L240;
  246. }
  247. L230:
  248. dparam[3] = dh21;
  249. dparam[4] = dh12;
  250. goto L260;
  251. L240:
  252. dparam[2] = dh11;
  253. dparam[5] = dh22;
  254. goto L260;
  255. L250:
  256. dparam[2] = dh11;
  257. dparam[3] = dh21;
  258. dparam[4] = dh12;
  259. dparam[5] = dh22;
  260. L260:
  261. dparam[1] = dflag;
  262. return 0;
  263. } /* drotmg_ */