cosqb.f 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. *DECK COSQB
  2. SUBROUTINE COSQB (N, X, WSAVE)
  3. C***BEGIN PROLOGUE COSQB
  4. C***PURPOSE Compute the unnormalized inverse cosine transform.
  5. C***LIBRARY SLATEC (FFTPACK)
  6. C***CATEGORY J1A3
  7. C***TYPE SINGLE PRECISION (COSQB-S)
  8. C***KEYWORDS FFTPACK, INVERSE COSINE FOURIER TRANSFORM
  9. C***AUTHOR Swarztrauber, P. N., (NCAR)
  10. C***DESCRIPTION
  11. C
  12. C Subroutine COSQB computes the fast Fourier transform of quarter
  13. C wave data. That is, COSQB computes a sequence from its
  14. C representation in terms of a cosine series with odd wave numbers.
  15. C The transform is defined below at output parameter X.
  16. C
  17. C COSQB is the unnormalized inverse of COSQF since a call of COSQB
  18. C followed by a call of COSQF will multiply the input sequence X
  19. C by 4*N.
  20. C
  21. C The array WSAVE which is used by subroutine COSQB 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 COSQB. 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)= the sum from K=1 to K=N of
  45. C
  46. C 2*X(K)*COS((2*K-1)*(I-1)*PI/(2*N))
  47. C
  48. C A call of COSQB followed by a call of
  49. C COSQF will multiply the sequence X by 4*N.
  50. C Therefore COSQF is the unnormalized inverse
  51. C of COSQB.
  52. C
  53. C WSAVE contains initialization calculations which must not
  54. C be destroyed between calls of COSQB or COSQF.
  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 COSQB1
  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 TSQRT2 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 COSQB
  73. DIMENSION X(*), WSAVE(*)
  74. C***FIRST EXECUTABLE STATEMENT COSQB
  75. TSQRT2 = 2.*SQRT(2.)
  76. IF (N-2) 101,102,103
  77. 101 X(1) = 4.*X(1)
  78. RETURN
  79. 102 X1 = 4.*(X(1)+X(2))
  80. X(2) = TSQRT2*(X(1)-X(2))
  81. X(1) = X1
  82. RETURN
  83. 103 CALL COSQB1 (N,X,WSAVE,WSAVE(N+1))
  84. RETURN
  85. END