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.

dsdot.f 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. *> \brief \b DSDOT
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * DOUBLE PRECISION FUNCTION DSDOT(N,SX,INCX,SY,INCY)
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER INCX,INCY,N
  15. * ..
  16. * .. Array Arguments ..
  17. * REAL SX(*),SY(*)
  18. * ..
  19. *
  20. * AUTHORS
  21. * =======
  22. * Lawson, C. L., (JPL), Hanson, R. J., (SNLA),
  23. * Kincaid, D. R., (U. of Texas), Krogh, F. T., (JPL)
  24. *
  25. *
  26. *> \par Purpose:
  27. * =============
  28. *>
  29. *> \verbatim
  30. *>
  31. *> Compute the inner product of two vectors with extended
  32. *> precision accumulation and result.
  33. *>
  34. *> Returns D.P. dot product accumulated in D.P., for S.P. SX and SY
  35. *> DSDOT = sum for I = 0 to N-1 of SX(LX+I*INCX) * SY(LY+I*INCY),
  36. *> where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is
  37. *> defined in a similar way using INCY.
  38. *> \endverbatim
  39. *
  40. * Arguments:
  41. * ==========
  42. *
  43. *> \param[in] N
  44. *> \verbatim
  45. *> N is INTEGER
  46. *> number of elements in input vector(s)
  47. *> \endverbatim
  48. *>
  49. *> \param[in] SX
  50. *> \verbatim
  51. *> SX is REAL array, dimension(N)
  52. *> single precision vector with N elements
  53. *> \endverbatim
  54. *>
  55. *> \param[in] INCX
  56. *> \verbatim
  57. *> INCX is INTEGER
  58. *> storage spacing between elements of SX
  59. *> \endverbatim
  60. *>
  61. *> \param[in] SY
  62. *> \verbatim
  63. *> SY is REAL array, dimension(N)
  64. *> single precision vector with N elements
  65. *> \endverbatim
  66. *>
  67. *> \param[in] INCY
  68. *> \verbatim
  69. *> INCY is INTEGER
  70. *> storage spacing between elements of SY
  71. *> \endverbatim
  72. *>
  73. *> \result DSDOT
  74. *> \verbatim
  75. *> DSDOT is DOUBLE PRECISION
  76. *> DSDOT double precision dot product (zero if N.LE.0)
  77. *> \endverbatim
  78. *
  79. * Authors:
  80. * ========
  81. *
  82. *> \author Univ. of Tennessee
  83. *> \author Univ. of California Berkeley
  84. *> \author Univ. of Colorado Denver
  85. *> \author NAG Ltd.
  86. *
  87. *> \date December 2016
  88. *
  89. *> \ingroup double_blas_level1
  90. *
  91. *> \par Further Details:
  92. * =====================
  93. *>
  94. *> \verbatim
  95. *> \endverbatim
  96. *
  97. *> \par References:
  98. * ================
  99. *>
  100. *> \verbatim
  101. *>
  102. *>
  103. *> C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
  104. *> Krogh, Basic linear algebra subprograms for Fortran
  105. *> usage, Algorithm No. 539, Transactions on Mathematical
  106. *> Software 5, 3 (September 1979), pp. 308-323.
  107. *>
  108. *> REVISION HISTORY (YYMMDD)
  109. *>
  110. *> 791001 DATE WRITTEN
  111. *> 890831 Modified array declarations. (WRB)
  112. *> 890831 REVISION DATE from Version 3.2
  113. *> 891214 Prologue converted to Version 4.0 format. (BAB)
  114. *> 920310 Corrected definition of LX in DESCRIPTION. (WRB)
  115. *> 920501 Reformatted the REFERENCES section. (WRB)
  116. *> 070118 Reformat to LAPACK style (JL)
  117. *> \endverbatim
  118. *>
  119. * =====================================================================
  120. DOUBLE PRECISION FUNCTION DSDOT(N,SX,INCX,SY,INCY)
  121. *
  122. * -- Reference BLAS level1 routine (version 3.7.0) --
  123. * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
  124. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  125. * December 2016
  126. *
  127. * .. Scalar Arguments ..
  128. INTEGER INCX,INCY,N
  129. * ..
  130. * .. Array Arguments ..
  131. REAL SX(*),SY(*)
  132. * ..
  133. *
  134. * Authors:
  135. * ========
  136. * Lawson, C. L., (JPL), Hanson, R. J., (SNLA),
  137. * Kincaid, D. R., (U. of Texas), Krogh, F. T., (JPL)
  138. *
  139. * =====================================================================
  140. *
  141. * .. Local Scalars ..
  142. INTEGER I,KX,KY,NS
  143. * ..
  144. * .. Intrinsic Functions ..
  145. INTRINSIC DBLE
  146. * ..
  147. DSDOT = 0.0D0
  148. IF (N.LE.0) RETURN
  149. IF (INCX.EQ.INCY .AND. INCX.GT.0) THEN
  150. *
  151. * Code for equal, positive, non-unit increments.
  152. *
  153. NS = N*INCX
  154. DO I = 1,NS,INCX
  155. DSDOT = DSDOT + DBLE(SX(I))*DBLE(SY(I))
  156. END DO
  157. ELSE
  158. *
  159. * Code for unequal or nonpositive increments.
  160. *
  161. KX = 1
  162. KY = 1
  163. IF (INCX.LT.0) KX = 1 + (1-N)*INCX
  164. IF (INCY.LT.0) KY = 1 + (1-N)*INCY
  165. DO I = 1,N
  166. DSDOT = DSDOT + DBLE(SX(KX))*DBLE(SY(KY))
  167. KX = KX + INCX
  168. KY = KY + INCY
  169. END DO
  170. END IF
  171. RETURN
  172. END