dcdot.f 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. *DECK DCDOT
  2. SUBROUTINE DCDOT (N, FM, CX, INCX, CY, INCY, DCR, DCI)
  3. C***BEGIN PROLOGUE DCDOT
  4. C***PURPOSE Compute the inner product of two vectors with extended
  5. C precision accumulation and result.
  6. C***LIBRARY SLATEC (BLAS)
  7. C***CATEGORY D1A4
  8. C***TYPE COMPLEX (DSDOT-D, DCDOT-C)
  9. C***KEYWORDS BLAS, COMPLEX VECTORS, DOT PRODUCT, INNER PRODUCT,
  10. C LINEAR ALGEBRA, VECTOR
  11. C***AUTHOR (UNKNOWN)
  12. C***DESCRIPTION
  13. C
  14. C Compute the dot product of 2 complex vectors, CX and CY, e.g.
  15. C CX DOT CY, or, CXconjugate DOT CY. The real and imaginary
  16. C parts of CX and CY are converted to double precision, the dot
  17. C product accumulation is done in double precision and the output
  18. C is given as 2 double precision numbers, corresponding to the real
  19. C and imaginary part of the result.
  20. C Input
  21. C N: Number of complex components of CX and CY.
  22. C FM: =+1.0 compute CX DOT CY.
  23. C =-1.0 compute CXconjugate DOT CY.
  24. C CX(N):
  25. C CY(N): Complex arrays of length N.
  26. C INCX:(Integer) Spacing of elements of CX to use
  27. C INCY:(Integer) Spacing of elements of CY to use.
  28. C Output
  29. C DCR:(Double Precision) Real part of dot product.
  30. C DCI:(Double Precision) Imaginary part of dot product.
  31. C
  32. C***REFERENCES (NONE)
  33. C***ROUTINES CALLED (NONE)
  34. C***REVISION HISTORY (YYMMDD)
  35. C 790101 DATE WRITTEN
  36. C 890831 Modified array declarations. (WRB)
  37. C 890831 REVISION DATE from Version 3.2
  38. C 891214 Prologue converted to Version 4.0 format. (BAB)
  39. C***END PROLOGUE DCDOT
  40. INTEGER I, INCX, INCY, KX, KY, N
  41. COMPLEX CX(*), CY(*)
  42. DOUBLE PRECISION DCR, DCI, DT1, DT2, DT3, DT4, FM
  43. C***FIRST EXECUTABLE STATEMENT DCDOT
  44. DCR = 0.0D0
  45. DCI = 0.0D0
  46. IF (N .LE. 0) GO TO 20
  47. C
  48. KX = 1
  49. KY = 1
  50. IF (INCX .LT. 0) KX = 1+(1-N)*INCX
  51. IF (INCY .LT. 0) KY = 1+(1-N)*INCY
  52. DO 10 I = 1,N
  53. DT1 = DBLE(REAL(CX(KX)))
  54. DT2 = DBLE(REAL(CY(KY)))
  55. DT3 = DBLE(AIMAG(CX(KX)))
  56. DT4 = DBLE(AIMAG(CY(KY)))
  57. DCR = DCR+(DT1*DT2)-FM*(DT3*DT4)
  58. DCI = DCI+(DT1*DT4)+FM*(DT3*DT2)
  59. KX = KX+INCX
  60. KY = KY+INCY
  61. 10 CONTINUE
  62. 20 RETURN
  63. END