cdcdot.f 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. *DECK CDCDOT
  2. COMPLEX FUNCTION CDCDOT (N, CB, CX, INCX, CY, INCY)
  3. C***BEGIN PROLOGUE CDCDOT
  4. C***PURPOSE Compute the inner product of two vectors with extended
  5. C precision accumulation.
  6. C***LIBRARY SLATEC (BLAS)
  7. C***CATEGORY D1A4
  8. C***TYPE COMPLEX (SDSDOT-S, CDCDOT-C)
  9. C***KEYWORDS BLAS, DOT PRODUCT, INNER PRODUCT, LINEAR ALGEBRA, VECTOR
  10. C***AUTHOR Lawson, C. L., (JPL)
  11. C Hanson, R. J., (SNLA)
  12. C Kincaid, D. R., (U. of Texas)
  13. C Krogh, F. T., (JPL)
  14. C***DESCRIPTION
  15. C
  16. C B L A S Subprogram
  17. C Description of Parameters
  18. C
  19. C --Input--
  20. C N number of elements in input vector(s)
  21. C CB complex scalar to be added to inner product
  22. C CX complex vector with N elements
  23. C INCX storage spacing between elements of CX
  24. C CY complex vector with N elements
  25. C INCY storage spacing between elements of CY
  26. C
  27. C --Output--
  28. C CDCDOT complex dot product (CB if N .LE. 0)
  29. C
  30. C Returns complex result with dot product accumulated in D.P.
  31. C CDCDOT = CB + sum for I = 0 to N-1 of CX(LX+I*INCY)*CY(LY+I*INCY)
  32. C where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is
  33. C defined in a similar way using INCY.
  34. C
  35. C***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
  36. C Krogh, Basic linear algebra subprograms for Fortran
  37. C usage, Algorithm No. 539, Transactions on Mathematical
  38. C Software 5, 3 (September 1979), pp. 308-323.
  39. C***ROUTINES CALLED (NONE)
  40. C***REVISION HISTORY (YYMMDD)
  41. C 791001 DATE WRITTEN
  42. C 890531 Changed all specific intrinsics to generic. (WRB)
  43. C 890531 REVISION DATE from Version 3.2
  44. C 891214 Prologue converted to Version 4.0 format. (BAB)
  45. C 920310 Corrected definition of LX in DESCRIPTION. (WRB)
  46. C 920501 Reformatted the REFERENCES section. (WRB)
  47. C***END PROLOGUE CDCDOT
  48. INTEGER N, INCX, INCY, I, KX, KY
  49. COMPLEX CX(*), CY(*), CB
  50. DOUBLE PRECISION DSDOTR, DSDOTI, DT1, DT2, DT3, DT4
  51. C***FIRST EXECUTABLE STATEMENT CDCDOT
  52. DSDOTR = DBLE(REAL(CB))
  53. DSDOTI = DBLE(AIMAG(CB))
  54. IF (N .LE. 0) GO TO 10
  55. KX = 1
  56. KY = 1
  57. IF(INCX.LT.0) KX = 1+(1-N)*INCX
  58. IF(INCY.LT.0) KY = 1+(1-N)*INCY
  59. DO 5 I = 1,N
  60. DT1 = DBLE(REAL(CX(KX)))
  61. DT2 = DBLE(REAL(CY(KY)))
  62. DT3 = DBLE(AIMAG(CX(KX)))
  63. DT4 = DBLE(AIMAG(CY(KY)))
  64. DSDOTR = DSDOTR+(DT1*DT2)-(DT3*DT4)
  65. DSDOTI = DSDOTI+(DT1*DT4)+(DT3*DT2)
  66. KX = KX+INCX
  67. KY = KY+INCY
  68. 5 CONTINUE
  69. 10 CDCDOT = CMPLX(REAL(DSDOTR),REAL(DSDOTI))
  70. RETURN
  71. END