1 subroutine cosq1b ( n, inc, x, lenx, wsave, lensav, work, lenwrk, ier )
3 !*****************************************************************************80
5 !! COSQ1B: real single precision backward cosine quarter wave transform, 1D.
9 ! COSQ1B computes the one-dimensional Fourier transform of a sequence
10 ! which is a cosine series with odd wave numbers. This transform is
11 ! referred to as the backward transform or Fourier synthesis, transforming
12 ! the sequence from spectral to physical space.
14 ! This transform is normalized since a call to COSQ1B followed
15 ! by a call to COSQ1F (or vice-versa) reproduces the original
16 ! array within roundoff error.
19 ! Copyright (C) 1995-2004, Scientific Computing Division,
20 ! University Corporation for Atmospheric Research
34 ! Vectorizing the Fast Fourier Transforms,
35 ! in Parallel Computations,
36 ! edited by G. Rodrigue,
37 ! Academic Press, 1982.
40 ! Fast Fourier Transform Algorithms for Vector Computers,
41 ! Parallel Computing, pages 45-63, 1984.
45 ! Input, integer ( kind = 4 ) N, the number of elements to be transformed
46 ! in the sequence. The transform is most efficient when N is a
47 ! product of small primes.
49 ! Input, integer ( kind = 4 ) INC, the increment between the locations,
50 ! in array R, of two consecutive elements within the sequence.
52 ! Input/output, real ( kind = 4 ) R(LENR); on input, containing the sequence
53 ! to be transformed, and on output, containing the transformed sequence.
55 ! Input, integer ( kind = 4 ) LENR, the dimension of the R array.
56 ! LENR must be at least INC*(N-1)+ 1.
58 ! Input, real ( kind = 4 ) WSAVE(LENSAV). WSAVE's contents must be
59 ! initialized with a call to COSQ1I before the first call to routine COSQ1F
60 ! or COSQ1B for a given transform length N. WSAVE's contents may be
61 ! re-used for subsequent calls to COSQ1F and COSQ1B with the same N.
63 ! Input, integer ( kind = 4 ) LENSAV, the dimension of the WSAVE array.
64 ! LENSAV must be at least 2*N + INT(LOG(REAL(N))) + 4.
66 ! Workspace, real ( kind = 4 ) WORK(LENWRK).
68 ! Input, integer ( kind = 4 ) LENWRK, the dimension of the WORK array.
69 ! LENWRK must be at least N.
71 ! Output, integer ( kind = 4 ) IER, error flag.
73 ! 1, input parameter LENR not big enough;
74 ! 2, input parameter LENSAV not big enough;
75 ! 3, input parameter LENWRK not big enough;
76 ! 20, input error returned by lower level routine.
80 integer ( kind = 4 ) inc
81 integer ( kind = 4 ) lensav
82 integer ( kind = 4 ) lenwrk
84 integer ( kind = 4 ) ier
85 integer ( kind = 4 ) ier1
86 integer ( kind = 4 ) lenx
87 integer ( kind = 4 ) n
88 real ( kind = 4 ) ssqrt2
89 real ( kind = 4 ) work(lenwrk)
90 real ( kind = 4 ) wsave(lensav)
91 real ( kind = 4 ) x(inc,*)
96 if ( lenx < inc * ( n - 1 ) + 1 ) then
98 call xerfft ( 'COSQ1B', 6 )
102 if ( lensav < 2 * n + int ( log ( real ( n, kind = 4 ) ) ) + 4 ) then
104 call xerfft ( 'COSQ1B', 8 )
108 if ( lenwrk < n ) then
110 call xerfft ( 'COSQ1B', 10 )
119 ssqrt2 = 1.0E+00 / sqrt ( 2.0E+00 )
121 x(1,2) = ssqrt2 * ( x(1,1) - x(1,2) )
126 call cosqb1 ( n, inc, x, wsave, work, ier1 )
128 if ( ier1 /= 0 ) then
130 call xerfft ( 'COSQ1B', -5 )