dlasr.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /* dlasr.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 _starpu_dlasr_(char *side, char *pivot, char *direct, integer *m,
  14. integer *n, doublereal *c__, doublereal *s, doublereal *a, integer *
  15. lda)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, i__1, i__2;
  19. /* Local variables */
  20. integer i__, j, info;
  21. doublereal temp;
  22. extern logical _starpu_lsame_(char *, char *);
  23. doublereal ctemp, stemp;
  24. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  25. /* -- LAPACK auxiliary routine (version 3.2) -- */
  26. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  27. /* November 2006 */
  28. /* .. Scalar Arguments .. */
  29. /* .. */
  30. /* .. Array Arguments .. */
  31. /* .. */
  32. /* Purpose */
  33. /* ======= */
  34. /* DLASR applies a sequence of plane rotations to a real matrix A, */
  35. /* from either the left or the right. */
  36. /* When SIDE = 'L', the transformation takes the form */
  37. /* A := P*A */
  38. /* and when SIDE = 'R', the transformation takes the form */
  39. /* A := A*P**T */
  40. /* where P is an orthogonal matrix consisting of a sequence of z plane */
  41. /* rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R', */
  42. /* and P**T is the transpose of P. */
  43. /* When DIRECT = 'F' (Forward sequence), then */
  44. /* P = P(z-1) * ... * P(2) * P(1) */
  45. /* and when DIRECT = 'B' (Backward sequence), then */
  46. /* P = P(1) * P(2) * ... * P(z-1) */
  47. /* where P(k) is a plane rotation matrix defined by the 2-by-2 rotation */
  48. /* R(k) = ( c(k) s(k) ) */
  49. /* = ( -s(k) c(k) ). */
  50. /* When PIVOT = 'V' (Variable pivot), the rotation is performed */
  51. /* for the plane (k,k+1), i.e., P(k) has the form */
  52. /* P(k) = ( 1 ) */
  53. /* ( ... ) */
  54. /* ( 1 ) */
  55. /* ( c(k) s(k) ) */
  56. /* ( -s(k) c(k) ) */
  57. /* ( 1 ) */
  58. /* ( ... ) */
  59. /* ( 1 ) */
  60. /* where R(k) appears as a rank-2 modification to the identity matrix in */
  61. /* rows and columns k and k+1. */
  62. /* When PIVOT = 'T' (Top pivot), the rotation is performed for the */
  63. /* plane (1,k+1), so P(k) has the form */
  64. /* P(k) = ( c(k) s(k) ) */
  65. /* ( 1 ) */
  66. /* ( ... ) */
  67. /* ( 1 ) */
  68. /* ( -s(k) c(k) ) */
  69. /* ( 1 ) */
  70. /* ( ... ) */
  71. /* ( 1 ) */
  72. /* where R(k) appears in rows and columns 1 and k+1. */
  73. /* Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is */
  74. /* performed for the plane (k,z), giving P(k) the form */
  75. /* P(k) = ( 1 ) */
  76. /* ( ... ) */
  77. /* ( 1 ) */
  78. /* ( c(k) s(k) ) */
  79. /* ( 1 ) */
  80. /* ( ... ) */
  81. /* ( 1 ) */
  82. /* ( -s(k) c(k) ) */
  83. /* where R(k) appears in rows and columns k and z. The rotations are */
  84. /* performed without ever forming P(k) explicitly. */
  85. /* Arguments */
  86. /* ========= */
  87. /* SIDE (input) CHARACTER*1 */
  88. /* Specifies whether the plane rotation matrix P is applied to */
  89. /* A on the left or the right. */
  90. /* = 'L': Left, compute A := P*A */
  91. /* = 'R': Right, compute A:= A*P**T */
  92. /* PIVOT (input) CHARACTER*1 */
  93. /* Specifies the plane for which P(k) is a plane rotation */
  94. /* matrix. */
  95. /* = 'V': Variable pivot, the plane (k,k+1) */
  96. /* = 'T': Top pivot, the plane (1,k+1) */
  97. /* = 'B': Bottom pivot, the plane (k,z) */
  98. /* DIRECT (input) CHARACTER*1 */
  99. /* Specifies whether P is a forward or backward sequence of */
  100. /* plane rotations. */
  101. /* = 'F': Forward, P = P(z-1)*...*P(2)*P(1) */
  102. /* = 'B': Backward, P = P(1)*P(2)*...*P(z-1) */
  103. /* M (input) INTEGER */
  104. /* The number of rows of the matrix A. If m <= 1, an immediate */
  105. /* return is effected. */
  106. /* N (input) INTEGER */
  107. /* The number of columns of the matrix A. If n <= 1, an */
  108. /* immediate return is effected. */
  109. /* C (input) DOUBLE PRECISION array, dimension */
  110. /* (M-1) if SIDE = 'L' */
  111. /* (N-1) if SIDE = 'R' */
  112. /* The cosines c(k) of the plane rotations. */
  113. /* S (input) DOUBLE PRECISION array, dimension */
  114. /* (M-1) if SIDE = 'L' */
  115. /* (N-1) if SIDE = 'R' */
  116. /* The sines s(k) of the plane rotations. The 2-by-2 plane */
  117. /* rotation part of the matrix P(k), R(k), has the form */
  118. /* R(k) = ( c(k) s(k) ) */
  119. /* ( -s(k) c(k) ). */
  120. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  121. /* The M-by-N matrix A. On exit, A is overwritten by P*A if */
  122. /* SIDE = 'R' or by A*P**T if SIDE = 'L'. */
  123. /* LDA (input) INTEGER */
  124. /* The leading dimension of the array A. LDA >= max(1,M). */
  125. /* ===================================================================== */
  126. /* .. Parameters .. */
  127. /* .. */
  128. /* .. Local Scalars .. */
  129. /* .. */
  130. /* .. External Functions .. */
  131. /* .. */
  132. /* .. External Subroutines .. */
  133. /* .. */
  134. /* .. Intrinsic Functions .. */
  135. /* .. */
  136. /* .. Executable Statements .. */
  137. /* Test the input parameters */
  138. /* Parameter adjustments */
  139. --c__;
  140. --s;
  141. a_dim1 = *lda;
  142. a_offset = 1 + a_dim1;
  143. a -= a_offset;
  144. /* Function Body */
  145. info = 0;
  146. if (! (_starpu_lsame_(side, "L") || _starpu_lsame_(side, "R"))) {
  147. info = 1;
  148. } else if (! (_starpu_lsame_(pivot, "V") || _starpu_lsame_(pivot,
  149. "T") || _starpu_lsame_(pivot, "B"))) {
  150. info = 2;
  151. } else if (! (_starpu_lsame_(direct, "F") || _starpu_lsame_(direct,
  152. "B"))) {
  153. info = 3;
  154. } else if (*m < 0) {
  155. info = 4;
  156. } else if (*n < 0) {
  157. info = 5;
  158. } else if (*lda < max(1,*m)) {
  159. info = 9;
  160. }
  161. if (info != 0) {
  162. _starpu_xerbla_("DLASR ", &info);
  163. return 0;
  164. }
  165. /* Quick return if possible */
  166. if (*m == 0 || *n == 0) {
  167. return 0;
  168. }
  169. if (_starpu_lsame_(side, "L")) {
  170. /* Form P * A */
  171. if (_starpu_lsame_(pivot, "V")) {
  172. if (_starpu_lsame_(direct, "F")) {
  173. i__1 = *m - 1;
  174. for (j = 1; j <= i__1; ++j) {
  175. ctemp = c__[j];
  176. stemp = s[j];
  177. if (ctemp != 1. || stemp != 0.) {
  178. i__2 = *n;
  179. for (i__ = 1; i__ <= i__2; ++i__) {
  180. temp = a[j + 1 + i__ * a_dim1];
  181. a[j + 1 + i__ * a_dim1] = ctemp * temp - stemp *
  182. a[j + i__ * a_dim1];
  183. a[j + i__ * a_dim1] = stemp * temp + ctemp * a[j
  184. + i__ * a_dim1];
  185. /* L10: */
  186. }
  187. }
  188. /* L20: */
  189. }
  190. } else if (_starpu_lsame_(direct, "B")) {
  191. for (j = *m - 1; j >= 1; --j) {
  192. ctemp = c__[j];
  193. stemp = s[j];
  194. if (ctemp != 1. || stemp != 0.) {
  195. i__1 = *n;
  196. for (i__ = 1; i__ <= i__1; ++i__) {
  197. temp = a[j + 1 + i__ * a_dim1];
  198. a[j + 1 + i__ * a_dim1] = ctemp * temp - stemp *
  199. a[j + i__ * a_dim1];
  200. a[j + i__ * a_dim1] = stemp * temp + ctemp * a[j
  201. + i__ * a_dim1];
  202. /* L30: */
  203. }
  204. }
  205. /* L40: */
  206. }
  207. }
  208. } else if (_starpu_lsame_(pivot, "T")) {
  209. if (_starpu_lsame_(direct, "F")) {
  210. i__1 = *m;
  211. for (j = 2; j <= i__1; ++j) {
  212. ctemp = c__[j - 1];
  213. stemp = s[j - 1];
  214. if (ctemp != 1. || stemp != 0.) {
  215. i__2 = *n;
  216. for (i__ = 1; i__ <= i__2; ++i__) {
  217. temp = a[j + i__ * a_dim1];
  218. a[j + i__ * a_dim1] = ctemp * temp - stemp * a[
  219. i__ * a_dim1 + 1];
  220. a[i__ * a_dim1 + 1] = stemp * temp + ctemp * a[
  221. i__ * a_dim1 + 1];
  222. /* L50: */
  223. }
  224. }
  225. /* L60: */
  226. }
  227. } else if (_starpu_lsame_(direct, "B")) {
  228. for (j = *m; j >= 2; --j) {
  229. ctemp = c__[j - 1];
  230. stemp = s[j - 1];
  231. if (ctemp != 1. || stemp != 0.) {
  232. i__1 = *n;
  233. for (i__ = 1; i__ <= i__1; ++i__) {
  234. temp = a[j + i__ * a_dim1];
  235. a[j + i__ * a_dim1] = ctemp * temp - stemp * a[
  236. i__ * a_dim1 + 1];
  237. a[i__ * a_dim1 + 1] = stemp * temp + ctemp * a[
  238. i__ * a_dim1 + 1];
  239. /* L70: */
  240. }
  241. }
  242. /* L80: */
  243. }
  244. }
  245. } else if (_starpu_lsame_(pivot, "B")) {
  246. if (_starpu_lsame_(direct, "F")) {
  247. i__1 = *m - 1;
  248. for (j = 1; j <= i__1; ++j) {
  249. ctemp = c__[j];
  250. stemp = s[j];
  251. if (ctemp != 1. || stemp != 0.) {
  252. i__2 = *n;
  253. for (i__ = 1; i__ <= i__2; ++i__) {
  254. temp = a[j + i__ * a_dim1];
  255. a[j + i__ * a_dim1] = stemp * a[*m + i__ * a_dim1]
  256. + ctemp * temp;
  257. a[*m + i__ * a_dim1] = ctemp * a[*m + i__ *
  258. a_dim1] - stemp * temp;
  259. /* L90: */
  260. }
  261. }
  262. /* L100: */
  263. }
  264. } else if (_starpu_lsame_(direct, "B")) {
  265. for (j = *m - 1; j >= 1; --j) {
  266. ctemp = c__[j];
  267. stemp = s[j];
  268. if (ctemp != 1. || stemp != 0.) {
  269. i__1 = *n;
  270. for (i__ = 1; i__ <= i__1; ++i__) {
  271. temp = a[j + i__ * a_dim1];
  272. a[j + i__ * a_dim1] = stemp * a[*m + i__ * a_dim1]
  273. + ctemp * temp;
  274. a[*m + i__ * a_dim1] = ctemp * a[*m + i__ *
  275. a_dim1] - stemp * temp;
  276. /* L110: */
  277. }
  278. }
  279. /* L120: */
  280. }
  281. }
  282. }
  283. } else if (_starpu_lsame_(side, "R")) {
  284. /* Form A * P' */
  285. if (_starpu_lsame_(pivot, "V")) {
  286. if (_starpu_lsame_(direct, "F")) {
  287. i__1 = *n - 1;
  288. for (j = 1; j <= i__1; ++j) {
  289. ctemp = c__[j];
  290. stemp = s[j];
  291. if (ctemp != 1. || stemp != 0.) {
  292. i__2 = *m;
  293. for (i__ = 1; i__ <= i__2; ++i__) {
  294. temp = a[i__ + (j + 1) * a_dim1];
  295. a[i__ + (j + 1) * a_dim1] = ctemp * temp - stemp *
  296. a[i__ + j * a_dim1];
  297. a[i__ + j * a_dim1] = stemp * temp + ctemp * a[
  298. i__ + j * a_dim1];
  299. /* L130: */
  300. }
  301. }
  302. /* L140: */
  303. }
  304. } else if (_starpu_lsame_(direct, "B")) {
  305. for (j = *n - 1; j >= 1; --j) {
  306. ctemp = c__[j];
  307. stemp = s[j];
  308. if (ctemp != 1. || stemp != 0.) {
  309. i__1 = *m;
  310. for (i__ = 1; i__ <= i__1; ++i__) {
  311. temp = a[i__ + (j + 1) * a_dim1];
  312. a[i__ + (j + 1) * a_dim1] = ctemp * temp - stemp *
  313. a[i__ + j * a_dim1];
  314. a[i__ + j * a_dim1] = stemp * temp + ctemp * a[
  315. i__ + j * a_dim1];
  316. /* L150: */
  317. }
  318. }
  319. /* L160: */
  320. }
  321. }
  322. } else if (_starpu_lsame_(pivot, "T")) {
  323. if (_starpu_lsame_(direct, "F")) {
  324. i__1 = *n;
  325. for (j = 2; j <= i__1; ++j) {
  326. ctemp = c__[j - 1];
  327. stemp = s[j - 1];
  328. if (ctemp != 1. || stemp != 0.) {
  329. i__2 = *m;
  330. for (i__ = 1; i__ <= i__2; ++i__) {
  331. temp = a[i__ + j * a_dim1];
  332. a[i__ + j * a_dim1] = ctemp * temp - stemp * a[
  333. i__ + a_dim1];
  334. a[i__ + a_dim1] = stemp * temp + ctemp * a[i__ +
  335. a_dim1];
  336. /* L170: */
  337. }
  338. }
  339. /* L180: */
  340. }
  341. } else if (_starpu_lsame_(direct, "B")) {
  342. for (j = *n; j >= 2; --j) {
  343. ctemp = c__[j - 1];
  344. stemp = s[j - 1];
  345. if (ctemp != 1. || stemp != 0.) {
  346. i__1 = *m;
  347. for (i__ = 1; i__ <= i__1; ++i__) {
  348. temp = a[i__ + j * a_dim1];
  349. a[i__ + j * a_dim1] = ctemp * temp - stemp * a[
  350. i__ + a_dim1];
  351. a[i__ + a_dim1] = stemp * temp + ctemp * a[i__ +
  352. a_dim1];
  353. /* L190: */
  354. }
  355. }
  356. /* L200: */
  357. }
  358. }
  359. } else if (_starpu_lsame_(pivot, "B")) {
  360. if (_starpu_lsame_(direct, "F")) {
  361. i__1 = *n - 1;
  362. for (j = 1; j <= i__1; ++j) {
  363. ctemp = c__[j];
  364. stemp = s[j];
  365. if (ctemp != 1. || stemp != 0.) {
  366. i__2 = *m;
  367. for (i__ = 1; i__ <= i__2; ++i__) {
  368. temp = a[i__ + j * a_dim1];
  369. a[i__ + j * a_dim1] = stemp * a[i__ + *n * a_dim1]
  370. + ctemp * temp;
  371. a[i__ + *n * a_dim1] = ctemp * a[i__ + *n *
  372. a_dim1] - stemp * temp;
  373. /* L210: */
  374. }
  375. }
  376. /* L220: */
  377. }
  378. } else if (_starpu_lsame_(direct, "B")) {
  379. for (j = *n - 1; j >= 1; --j) {
  380. ctemp = c__[j];
  381. stemp = s[j];
  382. if (ctemp != 1. || stemp != 0.) {
  383. i__1 = *m;
  384. for (i__ = 1; i__ <= i__1; ++i__) {
  385. temp = a[i__ + j * a_dim1];
  386. a[i__ + j * a_dim1] = stemp * a[i__ + *n * a_dim1]
  387. + ctemp * temp;
  388. a[i__ + *n * a_dim1] = ctemp * a[i__ + *n *
  389. a_dim1] - stemp * temp;
  390. /* L230: */
  391. }
  392. }
  393. /* L240: */
  394. }
  395. }
  396. }
  397. }
  398. return 0;
  399. /* End of DLASR */
  400. } /* _starpu_dlasr_ */