srotmg.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /* srotmg.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 srotmg_(real *sd1, real *sd2, real *sx1, real *sy1, real
  14. *sparam)
  15. {
  16. /* Initialized data */
  17. static real zero = 0.f;
  18. static real one = 1.f;
  19. static real two = 2.f;
  20. static real gam = 4096.f;
  21. static real gamsq = 16777200.f;
  22. static real rgamsq = 5.96046e-8f;
  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. real r__1;
  30. /* Local variables */
  31. real su, sp1, sp2, sq1, sq2, sh11, sh12, sh21, sh22;
  32. integer igo;
  33. real sflag, stemp;
  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 (SQRT(SD1)*SX1,SQRT(SD2)* */
  44. /* SY2)**T. */
  45. /* WITH SPARAM(1)=SFLAG, H HAS ONE OF THE FOLLOWING FORMS.. */
  46. /* SFLAG=-1.E0 SFLAG=0.E0 SFLAG=1.E0 SFLAG=-2.E0 */
  47. /* (SH11 SH12) (1.E0 SH12) (SH11 1.E0) (1.E0 0.E0) */
  48. /* H=( ) ( ) ( ) ( ) */
  49. /* (SH21 SH22), (SH21 1.E0), (-1.E0 SH22), (0.E0 1.E0). */
  50. /* LOCATIONS 2-4 OF SPARAM CONTAIN SH11,SH21,SH12, AND SH22 */
  51. /* RESPECTIVELY. (VALUES OF 1.E0, -1.E0, OR 0.E0 IMPLIED BY THE */
  52. /* VALUE OF SPARAM(1) ARE NOT STORED IN SPARAM.) */
  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 SD1 AND SD2. ALL ACTUAL SCALING OF DATA IS DONE USING GAM. */
  56. /* Arguments */
  57. /* ========= */
  58. /* SD1 (input/output) REAL */
  59. /* SD2 (input/output) REAL */
  60. /* SX1 (input/output) REAL */
  61. /* SY1 (input) REAL */
  62. /* SPARAM (input/output) REAL array, dimension 5 */
  63. /* SPARAM(1)=SFLAG */
  64. /* SPARAM(2)=SH11 */
  65. /* SPARAM(3)=SH21 */
  66. /* SPARAM(4)=SH12 */
  67. /* SPARAM(5)=SH22 */
  68. /* ===================================================================== */
  69. /* .. Local Scalars .. */
  70. /* .. */
  71. /* .. Intrinsic Functions .. */
  72. /* .. */
  73. /* .. Data statements .. */
  74. /* Parameter adjustments */
  75. --sparam;
  76. /* Function Body */
  77. /* .. */
  78. if (! (*sd1 < zero)) {
  79. goto L10;
  80. }
  81. /* GO ZERO-H-D-AND-SX1.. */
  82. goto L60;
  83. L10:
  84. /* CASE-SD1-NONNEGATIVE */
  85. sp2 = *sd2 * *sy1;
  86. if (! (sp2 == zero)) {
  87. goto L20;
  88. }
  89. sflag = -two;
  90. goto L260;
  91. /* REGULAR-CASE.. */
  92. L20:
  93. sp1 = *sd1 * *sx1;
  94. sq2 = sp2 * *sy1;
  95. sq1 = sp1 * *sx1;
  96. if (! (dabs(sq1) > dabs(sq2))) {
  97. goto L40;
  98. }
  99. sh21 = -(*sy1) / *sx1;
  100. sh12 = sp2 / sp1;
  101. su = one - sh12 * sh21;
  102. if (! (su <= zero)) {
  103. goto L30;
  104. }
  105. /* GO ZERO-H-D-AND-SX1.. */
  106. goto L60;
  107. L30:
  108. sflag = zero;
  109. *sd1 /= su;
  110. *sd2 /= su;
  111. *sx1 *= su;
  112. /* GO SCALE-CHECK.. */
  113. goto L100;
  114. L40:
  115. if (! (sq2 < zero)) {
  116. goto L50;
  117. }
  118. /* GO ZERO-H-D-AND-SX1.. */
  119. goto L60;
  120. L50:
  121. sflag = one;
  122. sh11 = sp1 / sp2;
  123. sh22 = *sx1 / *sy1;
  124. su = one + sh11 * sh22;
  125. stemp = *sd2 / su;
  126. *sd2 = *sd1 / su;
  127. *sd1 = stemp;
  128. *sx1 = *sy1 * su;
  129. /* GO SCALE-CHECK */
  130. goto L100;
  131. /* PROCEDURE..ZERO-H-D-AND-SX1.. */
  132. L60:
  133. sflag = -one;
  134. sh11 = zero;
  135. sh12 = zero;
  136. sh21 = zero;
  137. sh22 = zero;
  138. *sd1 = zero;
  139. *sd2 = zero;
  140. *sx1 = zero;
  141. /* RETURN.. */
  142. goto L220;
  143. /* PROCEDURE..FIX-H.. */
  144. L70:
  145. if (! (sflag >= zero)) {
  146. goto L90;
  147. }
  148. if (! (sflag == zero)) {
  149. goto L80;
  150. }
  151. sh11 = one;
  152. sh22 = one;
  153. sflag = -one;
  154. goto L90;
  155. L80:
  156. sh21 = -one;
  157. sh12 = one;
  158. sflag = -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 (! (*sd1 <= rgamsq)) {
  170. goto L130;
  171. }
  172. if (*sd1 == 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. r__1 = gam;
  182. *sd1 *= r__1 * r__1;
  183. *sx1 /= gam;
  184. sh11 /= gam;
  185. sh12 /= gam;
  186. goto L110;
  187. L130:
  188. L140:
  189. if (! (*sd1 >= 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. r__1 = gam;
  199. *sd1 /= r__1 * r__1;
  200. *sx1 *= gam;
  201. sh11 *= gam;
  202. sh12 *= gam;
  203. goto L140;
  204. L160:
  205. L170:
  206. if (! (dabs(*sd2) <= rgamsq)) {
  207. goto L190;
  208. }
  209. if (*sd2 == 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. r__1 = gam;
  219. *sd2 *= r__1 * r__1;
  220. sh21 /= gam;
  221. sh22 /= gam;
  222. goto L170;
  223. L190:
  224. L200:
  225. if (! (dabs(*sd2) >= 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. r__1 = gam;
  235. *sd2 /= r__1 * r__1;
  236. sh21 *= gam;
  237. sh22 *= gam;
  238. goto L200;
  239. L220:
  240. if (sflag < 0.f) {
  241. goto L250;
  242. } else if (sflag == 0) {
  243. goto L230;
  244. } else {
  245. goto L240;
  246. }
  247. L230:
  248. sparam[3] = sh21;
  249. sparam[4] = sh12;
  250. goto L260;
  251. L240:
  252. sparam[2] = sh11;
  253. sparam[5] = sh22;
  254. goto L260;
  255. L250:
  256. sparam[2] = sh11;
  257. sparam[3] = sh21;
  258. sparam[4] = sh12;
  259. sparam[5] = sh22;
  260. L260:
  261. sparam[1] = sflag;
  262. return 0;
  263. } /* srotmg_ */