You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sasum.f 2.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. *> \brief \b SASUM
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * REAL FUNCTION SASUM(N,SX,INCX)
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER INCX,N
  15. * ..
  16. * .. Array Arguments ..
  17. * REAL SX(*)
  18. * ..
  19. *
  20. *
  21. *> \par Purpose:
  22. * =============
  23. *>
  24. *> \verbatim
  25. *>
  26. *> SASUM takes the sum of the absolute values.
  27. *> uses unrolled loops for increment equal to one.
  28. *> \endverbatim
  29. *
  30. * Authors:
  31. * ========
  32. *
  33. *> \author Univ. of Tennessee
  34. *> \author Univ. of California Berkeley
  35. *> \author Univ. of Colorado Denver
  36. *> \author NAG Ltd.
  37. *
  38. *> \date November 2011
  39. *
  40. *> \ingroup single_blas_level1
  41. *
  42. *> \par Further Details:
  43. * =====================
  44. *>
  45. *> \verbatim
  46. *>
  47. *> jack dongarra, linpack, 3/11/78.
  48. *> modified 3/93 to return if incx .le. 0.
  49. *> modified 12/3/93, array(1) declarations changed to array(*)
  50. *> \endverbatim
  51. *>
  52. * =====================================================================
  53. REAL FUNCTION SASUM(N,SX,INCX)
  54. *
  55. * -- Reference BLAS level1 routine (version 3.4.0) --
  56. * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
  57. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  58. * November 2011
  59. *
  60. * .. Scalar Arguments ..
  61. INTEGER INCX,N
  62. * ..
  63. * .. Array Arguments ..
  64. REAL SX(*)
  65. * ..
  66. *
  67. * =====================================================================
  68. *
  69. * .. Local Scalars ..
  70. REAL STEMP
  71. INTEGER I,M,MP1,NINCX
  72. * ..
  73. * .. Intrinsic Functions ..
  74. INTRINSIC ABS,MOD
  75. * ..
  76. SASUM = 0.0e0
  77. STEMP = 0.0e0
  78. IF (N.LE.0 .OR. INCX.LE.0) RETURN
  79. IF (INCX.EQ.1) THEN
  80. * code for increment equal to 1
  81. *
  82. *
  83. * clean-up loop
  84. *
  85. M = MOD(N,6)
  86. IF (M.NE.0) THEN
  87. DO I = 1,M
  88. STEMP = STEMP + ABS(SX(I))
  89. END DO
  90. IF (N.LT.6) THEN
  91. SASUM = STEMP
  92. RETURN
  93. END IF
  94. END IF
  95. MP1 = M + 1
  96. DO I = MP1,N,6
  97. STEMP = STEMP + ABS(SX(I)) + ABS(SX(I+1)) +
  98. $ ABS(SX(I+2)) + ABS(SX(I+3)) +
  99. $ ABS(SX(I+4)) + ABS(SX(I+5))
  100. END DO
  101. ELSE
  102. *
  103. * code for increment not equal to 1
  104. *
  105. NINCX = N*INCX
  106. DO I = 1,NINCX,INCX
  107. STEMP = STEMP + ABS(SX(I))
  108. END DO
  109. END IF
  110. SASUM = STEMP
  111. RETURN
  112. END