cosqf.f 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. *DECK COSQF
  2. SUBROUTINE COSQF (N, X, WSAVE)
  3. C***BEGIN PROLOGUE COSQF
  4. C***PURPOSE Compute the forward cosine transform with odd wave numbers.
  5. C***LIBRARY SLATEC (FFTPACK)
  6. C***CATEGORY J1A3
  7. C***TYPE SINGLE PRECISION (COSQF-S)
  8. C***KEYWORDS COSINE FOURIER TRANSFORM, FFTPACK
  9. C***AUTHOR Swarztrauber, P. N., (NCAR)
  10. C***DESCRIPTION
  11. C
  12. C Subroutine COSQF computes the fast Fourier transform of quarter
  13. C wave data. That is, COSQF computes the coefficients in a cosine
  14. C series representation with only odd wave numbers. The transform
  15. C is defined below at Output Parameter X
  16. C
  17. C COSQF is the unnormalized inverse of COSQB since a call of COSQF
  18. C followed by a call of COSQB will multiply the input sequence X
  19. C by 4*N.
  20. C
  21. C The array WSAVE which is used by subroutine COSQF must be
  22. C initialized by calling subroutine COSQI(N,WSAVE).
  23. C
  24. C
  25. C Input Parameters
  26. C
  27. C N the length of the array X to be transformed. The method
  28. C is most efficient when N is a product of small primes.
  29. C
  30. C X an array which contains the sequence to be transformed
  31. C
  32. C WSAVE a work array which must be dimensioned at least 3*N+15
  33. C in the program that calls COSQF. The WSAVE array must be
  34. C initialized by calling subroutine COSQI(N,WSAVE), and a
  35. C different WSAVE array must be used for each different
  36. C value of N. This initialization does not have to be
  37. C repeated so long as N remains unchanged. Thus subsequent
  38. C transforms can be obtained faster than the first.
  39. C
  40. C Output Parameters
  41. C
  42. C X For I=1,...,N
  43. C
  44. C X(I) = X(1) plus the sum from K=2 to K=N of
  45. C
  46. C 2*X(K)*COS((2*I-1)*(K-1)*PI/(2*N))
  47. C
  48. C A call of COSQF followed by a call of
  49. C COSQB will multiply the sequence X by 4*N.
  50. C Therefore COSQB is the unnormalized inverse
  51. C of COSQF.
  52. C
  53. C WSAVE contains initialization calculations which must not
  54. C be destroyed between calls of COSQF or COSQB.
  55. C
  56. C***REFERENCES P. N. Swarztrauber, Vectorizing the FFTs, in Parallel
  57. C Computations (G. Rodrigue, ed.), Academic Press,
  58. C 1982, pp. 51-83.
  59. C***ROUTINES CALLED COSQF1
  60. C***REVISION HISTORY (YYMMDD)
  61. C 790601 DATE WRITTEN
  62. C 830401 Modified to use SLATEC library source file format.
  63. C 860115 Modified by Ron Boisvert to adhere to Fortran 77 by
  64. C (a) changing dummy array size declarations (1) to (*),
  65. C (b) changing definition of variable SQRT2 by using
  66. C FORTRAN intrinsic function SQRT instead of a DATA
  67. C statement.
  68. C 861211 REVISION DATE from Version 3.2
  69. C 881128 Modified by Dick Valent to meet prologue standards.
  70. C 891214 Prologue converted to Version 4.0 format. (BAB)
  71. C 920501 Reformatted the REFERENCES section. (WRB)
  72. C***END PROLOGUE COSQF
  73. DIMENSION X(*), WSAVE(*)
  74. C***FIRST EXECUTABLE STATEMENT COSQF
  75. SQRT2 = SQRT(2.)
  76. IF (N-2) 102,101,103
  77. 101 TSQX = SQRT2*X(2)
  78. X(2) = X(1)-TSQX
  79. X(1) = X(1)+TSQX
  80. 102 RETURN
  81. 103 CALL COSQF1 (N,X,WSAVE,WSAVE(N+1))
  82. RETURN
  83. END