ccopy.f 2.2 KB

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