dla_geamv.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /* _starpu_dla_geamv.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_dla_geamv__(integer *trans, integer *m, integer *n,
  14. doublereal *alpha, doublereal *a, integer *lda, doublereal *x,
  15. integer *incx, doublereal *beta, doublereal *y, integer *incy)
  16. {
  17. /* System generated locals */
  18. integer a_dim1, a_offset, i__1, i__2;
  19. doublereal d__1;
  20. /* Builtin functions */
  21. double d_sign(doublereal *, doublereal *);
  22. /* Local variables */
  23. extern integer _starpu_ilatrans_(char *);
  24. integer i__, j;
  25. logical symb_zero__;
  26. integer iy, jx, kx, ky, info;
  27. doublereal temp;
  28. integer lenx, leny;
  29. doublereal safe1;
  30. extern doublereal _starpu_dlamch_(char *);
  31. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  32. /* -- LAPACK routine (version 3.2) -- */
  33. /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
  34. /* -- Jason Riedy of Univ. of California Berkeley. -- */
  35. /* -- November 2008 -- */
  36. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  37. /* -- Univ. of California Berkeley and NAG Ltd. -- */
  38. /* .. */
  39. /* .. Scalar Arguments .. */
  40. /* .. */
  41. /* .. Array Arguments .. */
  42. /* .. */
  43. /* Purpose */
  44. /* ======= */
  45. /* DLA_GEAMV performs one of the matrix-vector operations */
  46. /* y := alpha*abs(A)*abs(x) + beta*abs(y), */
  47. /* or y := alpha*abs(A)'*abs(x) + beta*abs(y), */
  48. /* where alpha and beta are scalars, x and y are vectors and A is an */
  49. /* m by n matrix. */
  50. /* This function is primarily used in calculating error bounds. */
  51. /* To protect against underflow during evaluation, components in */
  52. /* the resulting vector are perturbed away from zero by (N+1) */
  53. /* times the underflow threshold. To prevent unnecessarily large */
  54. /* errors for block-structure embedded in general matrices, */
  55. /* "symbolically" zero components are not perturbed. A zero */
  56. /* entry is considered "symbolic" if all multiplications involved */
  57. /* in computing that entry have at least one zero multiplicand. */
  58. /* Parameters */
  59. /* ========== */
  60. /* TRANS - INTEGER */
  61. /* On entry, TRANS specifies the operation to be performed as */
  62. /* follows: */
  63. /* BLAS_NO_TRANS y := alpha*abs(A)*abs(x) + beta*abs(y) */
  64. /* BLAS_TRANS y := alpha*abs(A')*abs(x) + beta*abs(y) */
  65. /* BLAS_CONJ_TRANS y := alpha*abs(A')*abs(x) + beta*abs(y) */
  66. /* Unchanged on exit. */
  67. /* M - INTEGER */
  68. /* On entry, M specifies the number of rows of the matrix A. */
  69. /* M must be at least zero. */
  70. /* Unchanged on exit. */
  71. /* N - INTEGER */
  72. /* On entry, N specifies the number of columns of the matrix A. */
  73. /* N must be at least zero. */
  74. /* Unchanged on exit. */
  75. /* ALPHA - DOUBLE PRECISION */
  76. /* On entry, ALPHA specifies the scalar alpha. */
  77. /* Unchanged on exit. */
  78. /* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ) */
  79. /* Before entry, the leading m by n part of the array A must */
  80. /* contain the matrix of coefficients. */
  81. /* Unchanged on exit. */
  82. /* LDA - INTEGER */
  83. /* On entry, LDA specifies the first dimension of A as declared */
  84. /* in the calling (sub) program. LDA must be at least */
  85. /* max( 1, m ). */
  86. /* Unchanged on exit. */
  87. /* X - DOUBLE PRECISION array of DIMENSION at least */
  88. /* ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n' */
  89. /* and at least */
  90. /* ( 1 + ( m - 1 )*abs( INCX ) ) otherwise. */
  91. /* Before entry, the incremented array X must contain the */
  92. /* vector x. */
  93. /* Unchanged on exit. */
  94. /* INCX - INTEGER */
  95. /* On entry, INCX specifies the increment for the elements of */
  96. /* X. INCX must not be zero. */
  97. /* Unchanged on exit. */
  98. /* BETA - DOUBLE PRECISION */
  99. /* On entry, BETA specifies the scalar beta. When BETA is */
  100. /* supplied as zero then Y need not be set on input. */
  101. /* Unchanged on exit. */
  102. /* Y - DOUBLE PRECISION */
  103. /* Array of DIMENSION at least */
  104. /* ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n' */
  105. /* and at least */
  106. /* ( 1 + ( n - 1 )*abs( INCY ) ) otherwise. */
  107. /* Before entry with BETA non-zero, the incremented array Y */
  108. /* must contain the vector y. On exit, Y is overwritten by the */
  109. /* updated vector y. */
  110. /* INCY - INTEGER */
  111. /* On entry, INCY specifies the increment for the elements of */
  112. /* Y. INCY must not be zero. */
  113. /* Unchanged on exit. */
  114. /* Level 2 Blas routine. */
  115. /* .. */
  116. /* .. Parameters .. */
  117. /* .. */
  118. /* .. Local Scalars .. */
  119. /* .. */
  120. /* .. External Subroutines .. */
  121. /* .. */
  122. /* .. External Functions .. */
  123. /* .. */
  124. /* .. Intrinsic Functions .. */
  125. /* .. */
  126. /* .. Executable Statements .. */
  127. /* Test the input parameters. */
  128. /* Parameter adjustments */
  129. a_dim1 = *lda;
  130. a_offset = 1 + a_dim1;
  131. a -= a_offset;
  132. --x;
  133. --y;
  134. /* Function Body */
  135. info = 0;
  136. if (! (*trans == _starpu_ilatrans_("N") || *trans == _starpu_ilatrans_("T") || *trans == _starpu_ilatrans_("C"))) {
  137. info = 1;
  138. } else if (*m < 0) {
  139. info = 2;
  140. } else if (*n < 0) {
  141. info = 3;
  142. } else if (*lda < max(1,*m)) {
  143. info = 6;
  144. } else if (*incx == 0) {
  145. info = 8;
  146. } else if (*incy == 0) {
  147. info = 11;
  148. }
  149. if (info != 0) {
  150. _starpu_xerbla_("DLA_GEAMV ", &info);
  151. return 0;
  152. }
  153. /* Quick return if possible. */
  154. if (*m == 0 || *n == 0 || *alpha == 0. && *beta == 1.) {
  155. return 0;
  156. }
  157. /* Set LENX and LENY, the lengths of the vectors x and y, and set */
  158. /* up the start points in X and Y. */
  159. if (*trans == _starpu_ilatrans_("N")) {
  160. lenx = *n;
  161. leny = *m;
  162. } else {
  163. lenx = *m;
  164. leny = *n;
  165. }
  166. if (*incx > 0) {
  167. kx = 1;
  168. } else {
  169. kx = 1 - (lenx - 1) * *incx;
  170. }
  171. if (*incy > 0) {
  172. ky = 1;
  173. } else {
  174. ky = 1 - (leny - 1) * *incy;
  175. }
  176. /* Set SAFE1 essentially to be the underflow threshold times the */
  177. /* number of additions in each row. */
  178. safe1 = _starpu_dlamch_("Safe minimum");
  179. safe1 = (*n + 1) * safe1;
  180. /* Form y := alpha*abs(A)*abs(x) + beta*abs(y). */
  181. /* The O(M*N) SYMB_ZERO tests could be replaced by O(N) queries to */
  182. /* the inexact flag. Still doesn't help change the iteration order */
  183. /* to per-column. */
  184. iy = ky;
  185. if (*incx == 1) {
  186. i__1 = leny;
  187. for (i__ = 1; i__ <= i__1; ++i__) {
  188. if (*beta == 0.) {
  189. symb_zero__ = TRUE_;
  190. y[iy] = 0.;
  191. } else if (y[iy] == 0.) {
  192. symb_zero__ = TRUE_;
  193. } else {
  194. symb_zero__ = FALSE_;
  195. y[iy] = *beta * (d__1 = y[iy], abs(d__1));
  196. }
  197. if (*alpha != 0.) {
  198. i__2 = lenx;
  199. for (j = 1; j <= i__2; ++j) {
  200. if (*trans == _starpu_ilatrans_("N")) {
  201. temp = (d__1 = a[i__ + j * a_dim1], abs(d__1));
  202. } else {
  203. temp = (d__1 = a[j + i__ * a_dim1], abs(d__1));
  204. }
  205. symb_zero__ = symb_zero__ && (x[j] == 0. || temp == 0.);
  206. y[iy] += *alpha * (d__1 = x[j], abs(d__1)) * temp;
  207. }
  208. }
  209. if (! symb_zero__) {
  210. y[iy] += d_sign(&safe1, &y[iy]);
  211. }
  212. iy += *incy;
  213. }
  214. } else {
  215. i__1 = leny;
  216. for (i__ = 1; i__ <= i__1; ++i__) {
  217. if (*beta == 0.) {
  218. symb_zero__ = TRUE_;
  219. y[iy] = 0.;
  220. } else if (y[iy] == 0.) {
  221. symb_zero__ = TRUE_;
  222. } else {
  223. symb_zero__ = FALSE_;
  224. y[iy] = *beta * (d__1 = y[iy], abs(d__1));
  225. }
  226. if (*alpha != 0.) {
  227. jx = kx;
  228. i__2 = lenx;
  229. for (j = 1; j <= i__2; ++j) {
  230. if (*trans == _starpu_ilatrans_("N")) {
  231. temp = (d__1 = a[i__ + j * a_dim1], abs(d__1));
  232. } else {
  233. temp = (d__1 = a[j + i__ * a_dim1], abs(d__1));
  234. }
  235. symb_zero__ = symb_zero__ && (x[jx] == 0. || temp == 0.);
  236. y[iy] += *alpha * (d__1 = x[jx], abs(d__1)) * temp;
  237. jx += *incx;
  238. }
  239. }
  240. if (! symb_zero__) {
  241. y[iy] += d_sign(&safe1, &y[iy]);
  242. }
  243. iy += *incy;
  244. }
  245. }
  246. return 0;
  247. /* End of DLA_GEAMV */
  248. } /* _starpu_dla_geamv__ */