dasum.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* dasum.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 dasum_(integer *n, doublereal *dx, integer *incx)
  14. {
  15. /* System generated locals */
  16. integer i__1, i__2;
  17. doublereal ret_val, d__1, d__2, d__3, d__4, d__5, d__6;
  18. /* Local variables */
  19. integer i__, m, mp1;
  20. doublereal dtemp;
  21. integer nincx;
  22. /* .. Scalar Arguments .. */
  23. /* .. */
  24. /* .. Array Arguments .. */
  25. /* .. */
  26. /* Purpose */
  27. /* ======= */
  28. /* takes the sum of the absolute values. */
  29. /* jack dongarra, linpack, 3/11/78. */
  30. /* modified 3/93 to return if incx .le. 0. */
  31. /* modified 12/3/93, array(1) declarations changed to array(*) */
  32. /* .. Local Scalars .. */
  33. /* .. */
  34. /* .. Intrinsic Functions .. */
  35. /* .. */
  36. /* Parameter adjustments */
  37. --dx;
  38. /* Function Body */
  39. ret_val = 0.;
  40. dtemp = 0.;
  41. if (*n <= 0 || *incx <= 0) {
  42. return ret_val;
  43. }
  44. if (*incx == 1) {
  45. goto L20;
  46. }
  47. /* code for increment not equal to 1 */
  48. nincx = *n * *incx;
  49. i__1 = nincx;
  50. i__2 = *incx;
  51. for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
  52. dtemp += (d__1 = dx[i__], abs(d__1));
  53. /* L10: */
  54. }
  55. ret_val = dtemp;
  56. return ret_val;
  57. /* code for increment equal to 1 */
  58. /* clean-up loop */
  59. L20:
  60. m = *n % 6;
  61. if (m == 0) {
  62. goto L40;
  63. }
  64. i__2 = m;
  65. for (i__ = 1; i__ <= i__2; ++i__) {
  66. dtemp += (d__1 = dx[i__], abs(d__1));
  67. /* L30: */
  68. }
  69. if (*n < 6) {
  70. goto L60;
  71. }
  72. L40:
  73. mp1 = m + 1;
  74. i__2 = *n;
  75. for (i__ = mp1; i__ <= i__2; i__ += 6) {
  76. dtemp = dtemp + (d__1 = dx[i__], abs(d__1)) + (d__2 = dx[i__ + 1],
  77. abs(d__2)) + (d__3 = dx[i__ + 2], abs(d__3)) + (d__4 = dx[i__
  78. + 3], abs(d__4)) + (d__5 = dx[i__ + 4], abs(d__5)) + (d__6 =
  79. dx[i__ + 5], abs(d__6));
  80. /* L50: */
  81. }
  82. L60:
  83. ret_val = dtemp;
  84. return ret_val;
  85. } /* dasum_ */