dlagtm.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /* dlagtm.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_dlagtm_(char *trans, integer *n, integer *nrhs,
  14. doublereal *alpha, doublereal *dl, doublereal *d__, doublereal *du,
  15. doublereal *x, integer *ldx, doublereal *beta, doublereal *b, integer
  16. *ldb)
  17. {
  18. /* System generated locals */
  19. integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2;
  20. /* Local variables */
  21. integer i__, j;
  22. extern logical _starpu_lsame_(char *, char *);
  23. /* -- LAPACK auxiliary routine (version 3.2) -- */
  24. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  25. /* November 2006 */
  26. /* .. Scalar Arguments .. */
  27. /* .. */
  28. /* .. Array Arguments .. */
  29. /* .. */
  30. /* Purpose */
  31. /* ======= */
  32. /* DLAGTM performs a matrix-vector product of the form */
  33. /* B := alpha * A * X + beta * B */
  34. /* where A is a tridiagonal matrix of order N, B and X are N by NRHS */
  35. /* matrices, and alpha and beta are real scalars, each of which may be */
  36. /* 0., 1., or -1. */
  37. /* Arguments */
  38. /* ========= */
  39. /* TRANS (input) CHARACTER*1 */
  40. /* Specifies the operation applied to A. */
  41. /* = 'N': No transpose, B := alpha * A * X + beta * B */
  42. /* = 'T': Transpose, B := alpha * A'* X + beta * B */
  43. /* = 'C': Conjugate transpose = Transpose */
  44. /* N (input) INTEGER */
  45. /* The order of the matrix A. N >= 0. */
  46. /* NRHS (input) INTEGER */
  47. /* The number of right hand sides, i.e., the number of columns */
  48. /* of the matrices X and B. */
  49. /* ALPHA (input) DOUBLE PRECISION */
  50. /* The scalar alpha. ALPHA must be 0., 1., or -1.; otherwise, */
  51. /* it is assumed to be 0. */
  52. /* DL (input) DOUBLE PRECISION array, dimension (N-1) */
  53. /* The (n-1) sub-diagonal elements of T. */
  54. /* D (input) DOUBLE PRECISION array, dimension (N) */
  55. /* The diagonal elements of T. */
  56. /* DU (input) DOUBLE PRECISION array, dimension (N-1) */
  57. /* The (n-1) super-diagonal elements of T. */
  58. /* X (input) DOUBLE PRECISION array, dimension (LDX,NRHS) */
  59. /* The N by NRHS matrix X. */
  60. /* LDX (input) INTEGER */
  61. /* The leading dimension of the array X. LDX >= max(N,1). */
  62. /* BETA (input) DOUBLE PRECISION */
  63. /* The scalar beta. BETA must be 0., 1., or -1.; otherwise, */
  64. /* it is assumed to be 1. */
  65. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  66. /* On entry, the N by NRHS matrix B. */
  67. /* On exit, B is overwritten by the matrix expression */
  68. /* B := alpha * A * X + beta * B. */
  69. /* LDB (input) INTEGER */
  70. /* The leading dimension of the array B. LDB >= max(N,1). */
  71. /* ===================================================================== */
  72. /* .. Parameters .. */
  73. /* .. */
  74. /* .. Local Scalars .. */
  75. /* .. */
  76. /* .. External Functions .. */
  77. /* .. */
  78. /* .. Executable Statements .. */
  79. /* Parameter adjustments */
  80. --dl;
  81. --d__;
  82. --du;
  83. x_dim1 = *ldx;
  84. x_offset = 1 + x_dim1;
  85. x -= x_offset;
  86. b_dim1 = *ldb;
  87. b_offset = 1 + b_dim1;
  88. b -= b_offset;
  89. /* Function Body */
  90. if (*n == 0) {
  91. return 0;
  92. }
  93. /* Multiply B by BETA if BETA.NE.1. */
  94. if (*beta == 0.) {
  95. i__1 = *nrhs;
  96. for (j = 1; j <= i__1; ++j) {
  97. i__2 = *n;
  98. for (i__ = 1; i__ <= i__2; ++i__) {
  99. b[i__ + j * b_dim1] = 0.;
  100. /* L10: */
  101. }
  102. /* L20: */
  103. }
  104. } else if (*beta == -1.) {
  105. i__1 = *nrhs;
  106. for (j = 1; j <= i__1; ++j) {
  107. i__2 = *n;
  108. for (i__ = 1; i__ <= i__2; ++i__) {
  109. b[i__ + j * b_dim1] = -b[i__ + j * b_dim1];
  110. /* L30: */
  111. }
  112. /* L40: */
  113. }
  114. }
  115. if (*alpha == 1.) {
  116. if (_starpu_lsame_(trans, "N")) {
  117. /* Compute B := B + A*X */
  118. i__1 = *nrhs;
  119. for (j = 1; j <= i__1; ++j) {
  120. if (*n == 1) {
  121. b[j * b_dim1 + 1] += d__[1] * x[j * x_dim1 + 1];
  122. } else {
  123. b[j * b_dim1 + 1] = b[j * b_dim1 + 1] + d__[1] * x[j *
  124. x_dim1 + 1] + du[1] * x[j * x_dim1 + 2];
  125. b[*n + j * b_dim1] = b[*n + j * b_dim1] + dl[*n - 1] * x[*
  126. n - 1 + j * x_dim1] + d__[*n] * x[*n + j * x_dim1]
  127. ;
  128. i__2 = *n - 1;
  129. for (i__ = 2; i__ <= i__2; ++i__) {
  130. b[i__ + j * b_dim1] = b[i__ + j * b_dim1] + dl[i__ -
  131. 1] * x[i__ - 1 + j * x_dim1] + d__[i__] * x[
  132. i__ + j * x_dim1] + du[i__] * x[i__ + 1 + j *
  133. x_dim1];
  134. /* L50: */
  135. }
  136. }
  137. /* L60: */
  138. }
  139. } else {
  140. /* Compute B := B + A'*X */
  141. i__1 = *nrhs;
  142. for (j = 1; j <= i__1; ++j) {
  143. if (*n == 1) {
  144. b[j * b_dim1 + 1] += d__[1] * x[j * x_dim1 + 1];
  145. } else {
  146. b[j * b_dim1 + 1] = b[j * b_dim1 + 1] + d__[1] * x[j *
  147. x_dim1 + 1] + dl[1] * x[j * x_dim1 + 2];
  148. b[*n + j * b_dim1] = b[*n + j * b_dim1] + du[*n - 1] * x[*
  149. n - 1 + j * x_dim1] + d__[*n] * x[*n + j * x_dim1]
  150. ;
  151. i__2 = *n - 1;
  152. for (i__ = 2; i__ <= i__2; ++i__) {
  153. b[i__ + j * b_dim1] = b[i__ + j * b_dim1] + du[i__ -
  154. 1] * x[i__ - 1 + j * x_dim1] + d__[i__] * x[
  155. i__ + j * x_dim1] + dl[i__] * x[i__ + 1 + j *
  156. x_dim1];
  157. /* L70: */
  158. }
  159. }
  160. /* L80: */
  161. }
  162. }
  163. } else if (*alpha == -1.) {
  164. if (_starpu_lsame_(trans, "N")) {
  165. /* Compute B := B - A*X */
  166. i__1 = *nrhs;
  167. for (j = 1; j <= i__1; ++j) {
  168. if (*n == 1) {
  169. b[j * b_dim1 + 1] -= d__[1] * x[j * x_dim1 + 1];
  170. } else {
  171. b[j * b_dim1 + 1] = b[j * b_dim1 + 1] - d__[1] * x[j *
  172. x_dim1 + 1] - du[1] * x[j * x_dim1 + 2];
  173. b[*n + j * b_dim1] = b[*n + j * b_dim1] - dl[*n - 1] * x[*
  174. n - 1 + j * x_dim1] - d__[*n] * x[*n + j * x_dim1]
  175. ;
  176. i__2 = *n - 1;
  177. for (i__ = 2; i__ <= i__2; ++i__) {
  178. b[i__ + j * b_dim1] = b[i__ + j * b_dim1] - dl[i__ -
  179. 1] * x[i__ - 1 + j * x_dim1] - d__[i__] * x[
  180. i__ + j * x_dim1] - du[i__] * x[i__ + 1 + j *
  181. x_dim1];
  182. /* L90: */
  183. }
  184. }
  185. /* L100: */
  186. }
  187. } else {
  188. /* Compute B := B - A'*X */
  189. i__1 = *nrhs;
  190. for (j = 1; j <= i__1; ++j) {
  191. if (*n == 1) {
  192. b[j * b_dim1 + 1] -= d__[1] * x[j * x_dim1 + 1];
  193. } else {
  194. b[j * b_dim1 + 1] = b[j * b_dim1 + 1] - d__[1] * x[j *
  195. x_dim1 + 1] - dl[1] * x[j * x_dim1 + 2];
  196. b[*n + j * b_dim1] = b[*n + j * b_dim1] - du[*n - 1] * x[*
  197. n - 1 + j * x_dim1] - d__[*n] * x[*n + j * x_dim1]
  198. ;
  199. i__2 = *n - 1;
  200. for (i__ = 2; i__ <= i__2; ++i__) {
  201. b[i__ + j * b_dim1] = b[i__ + j * b_dim1] - du[i__ -
  202. 1] * x[i__ - 1 + j * x_dim1] - d__[i__] * x[
  203. i__ + j * x_dim1] - dl[i__] * x[i__ + 1 + j *
  204. x_dim1];
  205. /* L110: */
  206. }
  207. }
  208. /* L120: */
  209. }
  210. }
  211. }
  212. return 0;
  213. /* End of DLAGTM */
  214. } /* _starpu_dlagtm_ */