sint.f 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. *DECK SINT
  2. SUBROUTINE SINT (N, X, WSAVE)
  3. C***BEGIN PROLOGUE SINT
  4. C***PURPOSE Compute the sine transform of a real, odd sequence.
  5. C***LIBRARY SLATEC (FFTPACK)
  6. C***CATEGORY J1A3
  7. C***TYPE SINGLE PRECISION (SINT-S)
  8. C***KEYWORDS FFTPACK, FOURIER TRANSFORM
  9. C***AUTHOR Swarztrauber, P. N., (NCAR)
  10. C***DESCRIPTION
  11. C
  12. C Subroutine SINT computes the discrete Fourier sine transform
  13. C of an odd sequence X(I). The transform is defined below at
  14. C output parameter X.
  15. C
  16. C SINT is the unnormalized inverse of itself since a call of SINT
  17. C followed by another call of SINT will multiply the input sequence
  18. C X by 2*(N+1).
  19. C
  20. C The array WSAVE which is used by subroutine SINT must be
  21. C initialized by calling subroutine SINTI(N,WSAVE).
  22. C
  23. C Input Parameters
  24. C
  25. C N the length of the sequence to be transformed. The method
  26. C is most efficient when N+1 is the product of small primes.
  27. C
  28. C X an array which contains the sequence to be transformed
  29. C
  30. C
  31. C WSAVE a work array with dimension at least INT(3.5*N+16)
  32. C in the program that calls SINT. The WSAVE array must be
  33. C initialized by calling subroutine SINTI(N,WSAVE), and a
  34. C different WSAVE array must be used for each different
  35. C value of N. This initialization does not have to be
  36. C repeated so long as N remains unchanged. Thus subsequent
  37. C transforms can be obtained faster than the first.
  38. C
  39. C Output Parameters
  40. C
  41. C X For I=1,...,N
  42. C
  43. C X(I)= the sum from K=1 to K=N
  44. C
  45. C 2*X(K)*SIN(K*I*PI/(N+1))
  46. C
  47. C A call of SINT followed by another call of
  48. C SINT will multiply the sequence X by 2*(N+1).
  49. C Hence SINT is the unnormalized inverse
  50. C of itself.
  51. C
  52. C WSAVE contains initialization calculations which must not be
  53. C destroyed between calls of SINT.
  54. C
  55. C***REFERENCES P. N. Swarztrauber, Vectorizing the FFTs, in Parallel
  56. C Computations (G. Rodrigue, ed.), Academic Press,
  57. C 1982, pp. 51-83.
  58. C***ROUTINES CALLED RFFTF
  59. C***REVISION HISTORY (YYMMDD)
  60. C 790601 DATE WRITTEN
  61. C 830401 Modified to use SLATEC library source file format.
  62. C 860115 Modified by Ron Boisvert to adhere to Fortran 77 by
  63. C (a) changing dummy array size declarations (1) to (*),
  64. C (b) changing definition of variable SQRT3 by using
  65. C FORTRAN intrinsic function SQRT instead of a DATA
  66. C statement.
  67. C 881128 Modified by Dick Valent to meet prologue standards.
  68. C 891009 Removed unreferenced statement label. (WRB)
  69. C 891009 REVISION DATE from Version 3.2
  70. C 891214 Prologue converted to Version 4.0 format. (BAB)
  71. C 920501 Reformatted the REFERENCES section. (WRB)
  72. C***END PROLOGUE SINT
  73. DIMENSION X(*), WSAVE(*)
  74. C***FIRST EXECUTABLE STATEMENT SINT
  75. SQRT3 = SQRT(3.)
  76. IF (N-2) 101,102,103
  77. 101 X(1) = X(1)+X(1)
  78. RETURN
  79. 102 XH = SQRT3*(X(1)+X(2))
  80. X(2) = SQRT3*(X(1)-X(2))
  81. X(1) = XH
  82. RETURN
  83. 103 NP1 = N+1
  84. NS2 = N/2
  85. WSAVE(1) = 0.
  86. KW = NP1
  87. DO 104 K=1,NS2
  88. KW = KW+1
  89. KC = NP1-K
  90. T1 = X(K)-X(KC)
  91. T2 = WSAVE(KW)*(X(K)+X(KC))
  92. WSAVE(K+1) = T1+T2
  93. WSAVE(KC+1) = T2-T1
  94. 104 CONTINUE
  95. MODN = MOD(N,2)
  96. IF (MODN .NE. 0) WSAVE(NS2+2) = 4.*X(NS2+1)
  97. NF = NP1+NS2+1
  98. CALL RFFTF (NP1,WSAVE,WSAVE(NF))
  99. X(1) = .5*WSAVE(1)
  100. DO 105 I=3,N,2
  101. X(I-1) = -WSAVE(I)
  102. X(I) = X(I-2)+WSAVE(I-1)
  103. 105 CONTINUE
  104. IF (MODN .NE. 0) RETURN
  105. X(N) = -WSAVE(N+1)
  106. RETURN
  107. END