sdot.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* sdot.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. doublereal sdot_(integer *n, real *sx, integer *incx, real *sy, integer *incy)
  14. {
  15. /* System generated locals */
  16. integer i__1;
  17. real ret_val;
  18. /* Local variables */
  19. integer i__, m, ix, iy, mp1;
  20. real stemp;
  21. /* .. Scalar Arguments .. */
  22. /* .. */
  23. /* .. Array Arguments .. */
  24. /* .. */
  25. /* Purpose */
  26. /* ======= */
  27. /* forms the dot product of two vectors. */
  28. /* uses unrolled loops for increments equal to one. */
  29. /* jack dongarra, linpack, 3/11/78. */
  30. /* modified 12/3/93, array(1) declarations changed to array(*) */
  31. /* .. Local Scalars .. */
  32. /* .. */
  33. /* .. Intrinsic Functions .. */
  34. /* .. */
  35. /* Parameter adjustments */
  36. --sy;
  37. --sx;
  38. /* Function Body */
  39. stemp = 0.f;
  40. ret_val = 0.f;
  41. if (*n <= 0) {
  42. return ret_val;
  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. stemp += sx[ix] * sy[iy];
  60. ix += *incx;
  61. iy += *incy;
  62. /* L10: */
  63. }
  64. ret_val = stemp;
  65. return ret_val;
  66. /* code for both increments equal to 1 */
  67. /* clean-up loop */
  68. L20:
  69. m = *n % 5;
  70. if (m == 0) {
  71. goto L40;
  72. }
  73. i__1 = m;
  74. for (i__ = 1; i__ <= i__1; ++i__) {
  75. stemp += sx[i__] * sy[i__];
  76. /* L30: */
  77. }
  78. if (*n < 5) {
  79. goto L60;
  80. }
  81. L40:
  82. mp1 = m + 1;
  83. i__1 = *n;
  84. for (i__ = mp1; i__ <= i__1; i__ += 5) {
  85. stemp = stemp + sx[i__] * sy[i__] + sx[i__ + 1] * sy[i__ + 1] + sx[
  86. i__ + 2] * sy[i__ + 2] + sx[i__ + 3] * sy[i__ + 3] + sx[i__ +
  87. 4] * sy[i__ + 4];
  88. /* L50: */
  89. }
  90. L60:
  91. ret_val = stemp;
  92. return ret_val;
  93. } /* sdot_ */