saxpy.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* saxpy.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 saxpy_(integer *n, real *sa, real *sx, integer *incx,
  14. real *sy, integer *incy)
  15. {
  16. /* System generated locals */
  17. integer i__1;
  18. /* Local variables */
  19. integer i__, m, ix, iy, mp1;
  20. /* .. Scalar Arguments .. */
  21. /* .. */
  22. /* .. Array Arguments .. */
  23. /* .. */
  24. /* Purpose */
  25. /* ======= */
  26. /* SAXPY constant times a vector plus a vector. */
  27. /* uses unrolled loop for increments equal to one. */
  28. /* jack dongarra, linpack, 3/11/78. */
  29. /* modified 12/3/93, array(1) declarations changed to array(*) */
  30. /* .. Local Scalars .. */
  31. /* .. */
  32. /* .. Intrinsic Functions .. */
  33. /* .. */
  34. /* Parameter adjustments */
  35. --sy;
  36. --sx;
  37. /* Function Body */
  38. if (*n <= 0) {
  39. return 0;
  40. }
  41. if (*sa == 0.f) {
  42. return 0;
  43. }
  44. if (*incx == 1 && *incy == 1) {
  45. goto L20;
  46. }
  47. /* code for unequal increments or equal increments */
  48. /* not equal to 1 */
  49. ix = 1;
  50. iy = 1;
  51. if (*incx < 0) {
  52. ix = (-(*n) + 1) * *incx + 1;
  53. }
  54. if (*incy < 0) {
  55. iy = (-(*n) + 1) * *incy + 1;
  56. }
  57. i__1 = *n;
  58. for (i__ = 1; i__ <= i__1; ++i__) {
  59. sy[iy] += *sa * sx[ix];
  60. ix += *incx;
  61. iy += *incy;
  62. /* L10: */
  63. }
  64. return 0;
  65. /* code for both increments equal to 1 */
  66. /* clean-up loop */
  67. L20:
  68. m = *n % 4;
  69. if (m == 0) {
  70. goto L40;
  71. }
  72. i__1 = m;
  73. for (i__ = 1; i__ <= i__1; ++i__) {
  74. sy[i__] += *sa * sx[i__];
  75. /* L30: */
  76. }
  77. if (*n < 4) {
  78. return 0;
  79. }
  80. L40:
  81. mp1 = m + 1;
  82. i__1 = *n;
  83. for (i__ = mp1; i__ <= i__1; i__ += 4) {
  84. sy[i__] += *sa * sx[i__];
  85. sy[i__ + 1] += *sa * sx[i__ + 1];
  86. sy[i__ + 2] += *sa * sx[i__ + 2];
  87. sy[i__ + 3] += *sa * sx[i__ + 3];
  88. /* L50: */
  89. }
  90. return 0;
  91. } /* saxpy_ */