caxpy.f 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. *DECK CAXPY
  2. SUBROUTINE CAXPY (N, CA, CX, INCX, CY, INCY)
  3. C***BEGIN PROLOGUE CAXPY
  4. C***PURPOSE Compute a constant times a vector plus a vector.
  5. C***LIBRARY SLATEC (BLAS)
  6. C***CATEGORY D1A7
  7. C***TYPE COMPLEX (SAXPY-S, DAXPY-D, CAXPY-C)
  8. C***KEYWORDS BLAS, LINEAR ALGEBRA, TRIAD, VECTOR
  9. C***AUTHOR Lawson, C. L., (JPL)
  10. C Hanson, R. J., (SNLA)
  11. C Kincaid, D. R., (U. of Texas)
  12. C Krogh, F. T., (JPL)
  13. C***DESCRIPTION
  14. C
  15. C B L A S Subprogram
  16. C Description of Parameters
  17. C
  18. C --Input--
  19. C N number of elements in input vector(s)
  20. C CA complex scalar multiplier
  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 CY complex result (unchanged if N .LE. 0)
  28. C
  29. C Overwrite complex CY with complex CA*CX + CY.
  30. C For I = 0 to N-1, replace CY(LY+I*INCY) with CA*CX(LX+I*INCX) +
  31. C 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 861211 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 920801 Removed variable CANORM. (RWC, WRB)
  47. C***END PROLOGUE CAXPY
  48. COMPLEX CX(*), CY(*), CA
  49. C***FIRST EXECUTABLE STATEMENT CAXPY
  50. IF (N.LE.0 .OR. CA.EQ.(0.0E0,0.0E0)) 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. CY(KY) = CY(KY) + CA*CX(KX)
  61. KX = KX + INCX
  62. KY = KY + INCY
  63. 10 CONTINUE
  64. RETURN
  65. C
  66. C Code for equal, positive, non-unit increments.
  67. C
  68. 20 NS = N*INCX
  69. DO 30 I = 1,NS,INCX
  70. CY(I) = CA*CX(I) + CY(I)
  71. 30 CONTINUE
  72. RETURN
  73. END