cscal.f 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. *DECK CSCAL
  2. SUBROUTINE CSCAL (N, CA, CX, INCX)
  3. C***BEGIN PROLOGUE CSCAL
  4. C***PURPOSE Multiply a vector by a constant.
  5. C***LIBRARY SLATEC (BLAS)
  6. C***CATEGORY D1A6
  7. C***TYPE COMPLEX (SSCAL-S, DSCAL-D, CSCAL-C)
  8. C***KEYWORDS BLAS, LINEAR ALGEBRA, SCALE, 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 scale factor
  21. C CX complex vector with N elements
  22. C INCX storage spacing between elements of CX
  23. C
  24. C --Output--
  25. C CX complex result (unchanged if N .LE. 0)
  26. C
  27. C Replace complex CX by complex CA*CX.
  28. C For I = 0 to N-1, replace CX(IX+I*INCX) with CA*CX(IX+I*INCX),
  29. C where IX = 1 if INCX .GE. 0, else IX = 1+(1-N)*INCX.
  30. C
  31. C***REFERENCES C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
  32. C Krogh, Basic linear algebra subprograms for Fortran
  33. C usage, Algorithm No. 539, Transactions on Mathematical
  34. C Software 5, 3 (September 1979), pp. 308-323.
  35. C***ROUTINES CALLED (NONE)
  36. C***REVISION HISTORY (YYMMDD)
  37. C 791001 DATE WRITTEN
  38. C 890831 Modified array declarations. (WRB)
  39. C 890831 REVISION DATE from Version 3.2
  40. C 891214 Prologue converted to Version 4.0 format. (BAB)
  41. C 900821 Modified to correct problem with a negative increment.
  42. C (WRB)
  43. C 920501 Reformatted the REFERENCES section. (WRB)
  44. C***END PROLOGUE CSCAL
  45. COMPLEX CA, CX(*)
  46. INTEGER I, INCX, IX, N
  47. C***FIRST EXECUTABLE STATEMENT CSCAL
  48. IF (N .LE. 0) RETURN
  49. C
  50. IF (INCX .EQ. 1) GOTO 20
  51. C
  52. C Code for increment not equal to 1.
  53. C
  54. IX = 1
  55. IF (INCX .LT. 0) IX = (-N+1)*INCX + 1
  56. DO 10 I = 1,N
  57. CX(IX) = CA*CX(IX)
  58. IX = IX + INCX
  59. 10 CONTINUE
  60. RETURN
  61. C
  62. C Code for increment equal to 1.
  63. C
  64. 20 DO 30 I = 1,N
  65. CX(I) = CA*CX(I)
  66. 30 CONTINUE
  67. RETURN
  68. END