cdotc.f 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. *DECK CDOTC
  2. COMPLEX FUNCTION CDOTC (N, CX, INCX, CY, INCY)
  3. C***BEGIN PROLOGUE CDOTC
  4. C***PURPOSE Dot product of two complex vectors using the complex
  5. C conjugate of the first vector.
  6. C***LIBRARY SLATEC (BLAS)
  7. C***CATEGORY D1A4
  8. C***TYPE COMPLEX (CDOTC-C)
  9. C***KEYWORDS BLAS, 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 CX complex vector with N elements
  22. C INCX storage spacing between elements of CX
  23. C CY complex vector with N elements
  24. C INCY storage spacing between elements of CY
  25. C
  26. C --Output--
  27. C CDOTC complex result (zero if N .LE. 0)
  28. C
  29. C Returns the dot product of complex CX and CY, using CONJUGATE(CX)
  30. C CDOTC = SUM for I = 0 to N-1 of CONJ(CX(LX+I*INCX))*CY(LY+I*INCY),
  31. C where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is
  32. C defined in a similar way using INCY.
  33. C
  34. C***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
  35. C Krogh, Basic linear algebra subprograms for Fortran
  36. C usage, Algorithm No. 539, Transactions on Mathematical
  37. C Software 5, 3 (September 1979), pp. 308-323.
  38. C***ROUTINES CALLED (NONE)
  39. C***REVISION HISTORY (YYMMDD)
  40. C 791001 DATE WRITTEN
  41. C 890831 Modified array declarations. (WRB)
  42. C 890831 REVISION DATE from Version 3.2
  43. C 891214 Prologue converted to Version 4.0 format. (BAB)
  44. C 920310 Corrected definition of LX in DESCRIPTION. (WRB)
  45. C 920501 Reformatted the REFERENCES section. (WRB)
  46. C***END PROLOGUE CDOTC
  47. COMPLEX CX(*),CY(*)
  48. C***FIRST EXECUTABLE STATEMENT CDOTC
  49. CDOTC = (0.0,0.0)
  50. IF (N .LE. 0) RETURN
  51. IF (INCX.EQ.INCY .AND. INCX.GT.0) GO TO 20
  52. C
  53. C Code for unequal or nonpositive increments.
  54. C
  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 10 I = 1,N
  60. CDOTC = CDOTC + CONJG(CX(KX))*CY(KY)
  61. KX = KX + INCX
  62. KY = KY + INCY
  63. 10 CONTINUE
  64. RETURN
  65. C
  66. C Code for equal, positive increments.
  67. C
  68. 20 NS = N*INCX
  69. DO 30 I = 1,NS,INCX
  70. CDOTC = CDOTC + CONJG(CX(I))*CY(I)
  71. 30 CONTINUE
  72. RETURN
  73. END