dla_gbamv.c 9.2 KB

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