ddot.c 2.3 KB

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