casacore
Loading...
Searching...
No Matches
FFTPack.h
Go to the documentation of this file.
1// # FFTPack.h: C++ wrapper functions for Fortran FFTPACK code
2// # Copyright (C) 1993,1994,1995,1997,1999,2000,2001
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef SCIMATH_FFTPACK_H
27#define SCIMATH_FFTPACK_H
28
29#include <casacore/casa/aips.h>
30
31// # The SGI compiler with -LANG:std has some trouble including both Complexfwd.h
32// # and Complex.h so we bypass the problem by include Complex.h only.
33#if defined(AIPS_USE_NEW_SGI)
34#include <casacore/casa/BasicSL/Complex.h>
35#else
36#include <casacore/casa/BasicSL/Complexfwd.h>
37#endif
38
39#warning \
40 "FFTPack is deprecated and will be removed in a future version of casacore. Please use FFTW."
41
42namespace casacore { // # NAMESPACE CASACORE - BEGIN
43
44// <summary>C++ interface to the Fortran FFTPACK library</summary>
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
46// </reviewed>
47// <synopsis>
48// The static functions in this class are C++ wrappers to the Fortran FFTPACK
49// library. This library contains functions that perform fast Fourier
50// transforms (FFT's) and related transforms.
51
52// An additional purpose of these definitions is to overload the functions so
53// that C++ users can access the functions in either fftpak (single precision)
54// or dfftpack (double precision) with identical function names.
55
56// These routines only do one-dimensional transforms with the first element of
57// the array being the "origin" of the transform. The <linkto
58// class="FFTServer">FFTServer</linkto> class uses some of these functions to
59// implement multi-dimensional transforms with the origin of the transform
60// either at the centre or the first element of the Array.
61
62// You must initialise the work array <src>wsave</src> before using the forward
63// transform (function with a suffix of f) or the backward transform (with a
64// suffix of b).
65
66// The transforms done by the functions in this class can be categorised as
67// follows:
68// <ul>
69// <li> Complex to Complex Transforms<br>
70// Done by the cttfi, cfftf & cfftb functions
71// <li> Real to Complex Transforms<br>
72// Done by the rffti, rfftf & rfftb functions. A simpler interface is
73// provided by the ezffti, ezfftf & ezfftb functions. The 'ez' functions
74// do not destroy the input array and provide the result in a slightly
75// less packed format. They are available in single precision only and
76// internally use the rfft functions.
77// <li> Sine Transforms<br>
78// Done by the sinti & sint functions. As the sine transform is its own
79// inverse there is no need for any distinction between forward and
80// backward transforms.
81// <li> Cosine Transforms<br>
82// Done by the costi & cost functions. As the cosine transform is its own
83// inverse there is no need for any distinction between forward and
84// backward transforms.
85// <li> Sine quarter wave Transforms<br>
86// Done by the sinqi, sinqf & sinqb functions.
87// <li> Cosine quarter wave Transforms<br>
88// Done by the cosqi, cosqf & cosqb functions.
89// </ul>
90
91// <note role=warning>
92// These functions assume that it is possible to convert between Casacore numeric
93// types and those used by Fortran. That it is possible to convert between
94// Float & float, Double & double and Int & int.
95// </note>
96
97// <note role=warning>
98// These function also assume that a Complex array is stored as pairs of
99// floating point numbers, with no intervening gaps, and with the real
100// component first ie., <src>[re0,im0,re1,im1, ...]</src> so that the following
101// type casts work,
102// <srcblock>
103// Complex* complexPtr;
104// Float* floatPtr = (Float* ) complexPtr;
105// </srcblock>
106// and allow a Complex number to be accessed as a pair of real numbers. If this
107// assumption is bad then float Arrays will have to generated by copying the
108// complex ones. When compiled in debug mode mode the functions that require
109// this assumption will throw an exception (AipsError) if this assumption is
110// bad. Ultimately this assumption about Complex<->Float Array conversion
111// should be put somewhere central like Array2Math.cc.
112// </note>
113
114// </synopsis>
115
116class FFTPack {
117 public:
118 // cffti initializes the array wsave which is used in both <src>cfftf</src> and
119 // <src>cfftb</src>. The prime factorization of n together with a tabulation of
120 // the trigonometric functions are computed and stored in wsave.
121 //
122 // Input parameter:
123 // <dl compact>
124 // <dt><b>n</b>
125 // <dd> The length of the sequence to be transformed
126 // </dl>
127 // Output parameter:
128 // <dl compact>
129 // <dt><b>wsave</b>
130 // <dd> A work array which must be dimensioned at least 4*n+15
131 // The same work array can be used for both cfftf and cfftb
132 // as long as n remains unchanged. Different wsave arrays
133 // are required for different values of n. The contents of
134 // wsave must not be changed between calls of cfftf or cfftb.
135 // </dl>
136 // <group>
137 static void cffti(Int n, Float* wsave);
138 static void cffti(Int n, Double* wsave);
139 // Here is the doc from FFTPack 5.1
140 // You can convert the linguo from fortran to C/C++
141 /* Input Arguments
142
143 L Integer number of elements to be transformed in the first
144 dimension. The transform is most efficient when L is a
145 product of small primes.
146
147
148 M Integer number of elements to be transformed in the second
149 dimension. The transform is most efficient when M is a
150 product of small primes.
151
152 LENSAV Integer dimension of WSAVE array. LENSAV must be at least
153 2*(L+M) + INT(LOG(REAL(L))/LOG(2.)) + INT(LOG(REAL(M))/LOG(2.)) + 8.
154
155
156 Output Arguments
157
158 WSAVE Real work array with dimension LENSAV, containing the
159 prime factors of L and M, and also containing certain
160 trigonometric values which will be used in routines
161 CFFT2B or CFFT2F.
162
163
164 WSAVE Real work array with dimension LENSAV. The WSAVE array
165 must be initialized with a call to subroutine CFFT2I before
166 the first call to CFFT2B or CFFT2F, and thereafter whenever
167 the values of L, M or the contents of array WSAVE change.
168 Using different WSAVE arrays for different transform lengths
169 or types in the same program may reduce computation costs
170 because the array contents can be re-used.
171
172
173 IER Integer error return
174 = 0 successful exit
175 = 2 input parameter LENSAV not big enough
176 = 20 input error returned by lower level routine
177 */
178
179 static void cfft2i(const Int& n, const Int& m, Float*& wsave, const Int& lensav, Int& ier);
180 // </group>
181
182 // cfftf computes the forward complex discrete Fourier
183 // transform (the Fourier analysis). Equivalently, cfftf computes
184 // the Fourier coefficients of a complex periodic sequence.
185 // the transform is defined below at output parameter c.
186 //
187 // The transform is not normalized. To obtain a normalized transform
188 // the output must be divided by n. Otherwise a call of cfftf
189 // followed by a call of cfftb will multiply the sequence by n.
190 //
191 // The array wsave which is used by <src>cfftf</src> must be
192 // initialized by calling <src>cffti(n,wsave)</src>.
193 //
194 // Input parameters:
195 // <dl compact>
196 // <dt><b>n</b>
197 // <dd> The length of the complex sequence c. The method is
198 // more efficient when n is the product of small primes.
199 // <dt><b>c</b>
200 // <dd> A complex array of length n which contains the sequence to be
201 // transformed.
202 // <dt><b>wsave</b>
203 // <dd> A real work array which must be dimensioned at least 4n+15
204 // by the program that calls cfftf. The wsave array must be
205 // initialized by calling <src>cffti(n,wsave)</src> and a
206 // different wsave array must be used for each different
207 // value of n. This initialization does not have to be
208 // repeated so long as n remains unchanged thus subsequent
209 // transforms can be obtained faster than the first.
210 // The same wsave array can be used by cfftf and cfftb.
211 // </dl>
212 // Output parameters:
213 // <dl compact>
214 // <dt><b>c</b>
215 // <dd> for j=1,...,n<br>
216 // c(j)=the sum from k=1,...,n of<br>
217 // c(k)*exp(-i*(j-1)*(k-1)*2*pi/n)<br>
218 // where i=sqrt(-1)<br>
219 // <dt><b>wsave</b>
220 // <dd> Contains initialization calculations which must not be
221 // destroyed between calls of cfftf or cfftb
222 // </dl>
223 // <group>
224 static void cfftf(Int n, Complex* c, Float* wsave);
225 static void cfftf(Int n, DComplex* c, Double* wsave);
226
227 // Description from FFTPack 5.1
228 /*
229 Input Arguments
230
231
232 LDIM Integer first dimension of two-dimensional complex array C.
233
234
235 L Integer number of elements to be transformed in the first
236 dimension of the two-dimensional complex array C. The value
237 of L must be less than or equal to that of LDIM. The
238 transform is most efficient when L is a product of small
239 primes.
240
241
242 M Integer number of elements to be transformed in the second
243 dimension of the two-dimensional complex array C. The
244 transform is most efficient when M is a product of small
245 primes.
246
247 C Complex array of two dimensions containing the (L,M) subarray
248 to be transformed. C's first dimension is LDIM, its second
249 dimension must be at least M.
250
251 WSAVE Real work array with dimension LENSAV. WSAVE's contents
252 must be initialized with a call to subroutine CFFT2I before
253 the first call to routine CFFT2F or CFFT2B with transform
254 lengths L and M. WSAVE's contents may be re-used for
255 subsequent calls to CFFT2F and CFFT2B having those same
256 transform lengths.
257
258
259
260 LENSAV Integer dimension of WSAVE array. LENSAV must be at least
261 2*(L+M) + INT(LOG(REAL(L))/LOG(2.)) + INT(LOG(REAL(M))/LOG(2.)) + 8.
262
263
264 WORK Real work array.
265
266
267 LENWRK Integer dimension of WORK array. LENWRK must be at least
268 2*L*M.
269 */
270 static void cfft2f(const Int& ldim, const Int& L, const Int& M, Complex*& C, Float*& WSAVE,
271 const Int& LENSAV, Float*& WORK, const Int& LENWRK, Int& IER);
272 // </group>
273
274 // cfftb computes the backward complex discrete Fourier
275 // transform (the Fourier synthesis). Equivalently, cfftb computes
276 // a complex periodic sequence from its Fourier coefficients.
277 // The transform is defined below with output parameter c.
278 //
279 // A call of cfftf followed by a call of cfftb will multiply the
280 // sequence by n.
281 //
282 // The array wsave which is used by <src>cfftb</src> must be
283 // initialized by calling <src>cffti(n,wsave)</src>.
284 //
285 // Input parameters:
286 // <dl compact>
287 // <dt><b>n</b>
288 // <dd> The length of the complex sequence c. The method is
289 // more efficient when n is the product of small primes.
290 // <dt><b>c</b>
291 // <dd> A complex array of length n which contains the sequence to be
292 // transformed.
293 // <dt><b>wsave</b>
294 // <dd> A real work array which must be dimensioned at least 4n+15
295 // in the program that calls cfftb. The wsave array must be
296 // initialized by calling <src>cffti(n,wsave)</src>
297 // and a different wsave array must be used for each different
298 // value of n. This initialization does not have to be
299 // repeated so long as n remains unchanged thus subsequent
300 // transforms can be obtained faster than the first.
301 // The same wsave array can be used by cfftf and cfftb.
302 // </dl>
303 // Output parameters:
304 // <dl compact>
305 // <dt><b>c</b>
306 // <dd> for j=1,...,n<br>
307 // c(j)=the sum from k=1,...,n of<br>
308 // c(k)*exp(i*(j-1)*(k-1)*2*pi/n)<br>
309
310 // <dt><b>wsave</b>
311 // <dd> Contains initialization calculations which must not be
312 // destroyed between calls of cfftf or cfftb
313 // </dl>
314 // <group>
315 static void cfftb(Int n, Complex* c, Float* wsave);
316 static void cfftb(Int n, DComplex* c, Double* wsave);
317
318 // Documentation from FFTPack 5.1
319 /*
320 Input Arguments
321
322 LDIM Integer first dimension of two-dimensional complex array C.
323
324
325 L Integer number of elements to be transformed in the first
326 dimension of the two-dimensional complex array C. The value
327 of L must be less than or equal to that of LDIM. The
328 transform is most efficient when L is a product of small
329 primes.
330
331
332 M Integer number of elements to be transformed in the second
333 dimension of the two-dimensional complex array C. The
334 transform is most efficient when M is a product of small
335 primes.
336
337 C Complex array of two dimensions containing the (L,M) subarray
338 to be transformed. C's first dimension is LDIM, its second
339 dimension must be at least M.
340
341
342 WSAVE Real work array with dimension LENSAV. WSAVE's contents
343 must be initialized with a call to subroutine CFFT2I before
344 the first call to routine CFFT2F or CFFT2B with transform
345 lengths L and M. WSAVE's contents may be re-used for
346 subsequent calls to CFFT2F and CFFT2B with the same
347 transform lengths L and M.
348
349 LENSAV Integer dimension of WSAVE array. LENSAV must be at least
350 2*(L+M) + INT(LOG(REAL(L))/LOG(2.)) + INT(LOG(REAL(M))/LOG(2.)) + 8.
351
352 WORK Real work array.
353
354 LENWRK Integer dimension of WORK array. LENWRK must be at least
355 2*L*M.
356
357 Output Arguments
358
359
360 C Complex output array. For purposes of exposition,
361 assume the index ranges of array C are defined by
362 C(0:L-1,0:M-1).
363
364 For I=0,...,L-1 and J=0,...,M-1, the C(I,J)'s are given
365 in the traditional aliased form by
366
367 L-1 M-1
368 C(I,J) = SUM SUM C(L1,M1)*
369 L1=0 M1=0
370
371 EXP(SQRT(-1)*2*PI*(I*L1/L + J*M1/M))
372
373 And in unaliased form, the C(I,J)'s are given by
374
375 LF MF
376 C(I,J) = SUM SUM C(L1,M1,K1)*
377 L1=LS M1=MS
378
379 EXP(SQRT(-1)*2*PI*(I*L1/L + J*M1/M))
380
381 where
382
383 LS= -L/2 and LF=L/2-1 if L is even;
384 LS=-(L-1)/2 and LF=(L-1)/2 if L is odd;
385 MS= -M/2 and MF=M/2-1 if M is even;
386 MS=-(M-1)/2 and MF=(M-1)/2 if M is odd;
387
388 and
389
390 C(L1,M1) = C(L1+L,M1) if L1 is zero or negative;
391 C(L1,M1) = C(L1,M1+M) if M1 is zero or negative;
392
393 The two forms give different results when used to
394 interpolate between elements of the sequence.
395
396 IER Integer error return
397 = 0 successful exit
398 = 2 input parameter LENSAV not big enough
399 = 3 input parameter LENWRK not big enough
400 = 5 input parameter L > LDIM
401 = 20 input error returned by lower level routine
402 */
403
404 static void cfft2b(const Int& LDIM, const Int& L, const Int& M, Complex*& C, Float*& WSAVE,
405 const Int& LENSAV, Float*& WORK, const Int& LENWRK, Int& IER);
406 // </group>
407
408 // rffti initializes the array wsave which is used in both <src>rfftf</src> and
409 // <src>rfftb</src>. The prime factorization of n together with a tabulation of
410 // the trigonometric functions are computed and stored in wsave.
411 //
412 // Input parameter:
413 // <dl compact>
414 // <dt><b>n</b>
415 // <dd> The length of the sequence to be transformed.
416 // </dl>
417 // Output parameter:
418 // <dl compact>
419 // <dt><b>wsave</b>
420 // <dd> A work array which must be dimensioned at least 2*n+15.
421 // The same work array can be used for both rfftf and rfftb
422 // as long as n remains unchanged. Different wsave arrays
423 // are required for different values of n. The contents of
424 // wsave must not be changed between calls of rfftf or rfftb.
425 // </dl>
426 // <group>
427 static void rffti(Int n, Float* wsave);
428 static void rffti(Int n, Double* wsave);
429 // </group>
430
431 // rfftf computes the Fourier coefficients of a real perodic sequence (Fourier
432 // analysis). The transform is defined below at output parameter r.
433 //
434 // Input parameters:
435 // <dl compact>
436 // <dt><b>n</b>
437 // <dd> The length of the array r to be transformed. The method
438 // is most efficient when n is a product of small primes.
439 // n may change so long as different work arrays are provided
440 // <dt><b>r</b>
441 // <dd> A real array of length n which contains the sequence
442 // to be transformed
443 // <dt><b>wsave</b>
444 // <dd> A work array which must be dimensioned at least 2*n+15
445 // in the program that calls rfftf. The wsave array must be
446 // initialized by calling <src>rffti(n,wsave)</src> and a
447 // different wsave array must be used for each different
448 // value of n. This initialization does not have to be
449 // repeated so long as n remains unchanged thus subsequent
450 // transforms can be obtained faster than the first.
451 // The same wsave array can be used by rfftf and rfftb.
452 // </dl>
453 // output parameters
454 // <dl compact>
455 // <dt><b>r</b>
456 // <dd> r(1) = the sum from i=1 to i=n of r(i)<br>
457 // if n is even set l = n/2 , if n is odd set l = (n+1)/2<br>
458 // then for k = 2,...,l<br>
459 // r(2*k-2) = the sum from i = 1 to i = n of<br>
460 // r(i)*cos((k-1)*(i-1)*2*pi/n)<br>
461 // r(2*k-1) = the sum from i = 1 to i = n of<br>
462 // -r(i)*sin((k-1)*(i-1)*2*pi/n)<br>
463 // if n is even<br>
464 // r(n) = the sum from i = 1 to i = n of<br>
465 // (-1)**(i-1)*r(i)<br>
466 //
467 // note:
468 // this transform is unnormalized since a call of rfftf
469 // followed by a call of rfftb will multiply the input
470 // sequence by n.
471 // <dt><b>wsave</b>
472 // <dd> Contains results which must not be destroyed between
473 // calls of rfftf or rfftb.
474 // </dl>
475 // <group>
476 static void rfftf(Int n, Float* r, Float* wsave);
477 static void rfftf(Int n, Double* r, Double* wsave);
478 // </group>
479
480 // rfftb computes the real perodic sequence from its Fourier coefficients
481 // (Fourier synthesis). The transform is defined below at output parameter r.
482 //
483 // Input parameters:
484 // <dl compact>
485 // <dt><b>n</b>
486 // <dd> The length of the array r to be transformed. The method
487 // is most efficient when n is a product of small primes.
488 // n may change so long as different work arrays are provided
489 // <dt><b>r</b>
490 // <dd> A real array of length n which contains the sequence
491 // to be transformed
492 // <dt><b>wsave</b>
493 // <dd> A work array which must be dimensioned at least 2*n+15
494 // in the program that calls rfftb. The wsave array must be
495 // initialized by calling <src>rffti(n,wsave)</src> and a
496 // different wsave array must be used for each different
497 // value of n. This initialization does not have to be
498 // repeated so long as n remains unchanged thus subsequent
499 // transforms can be obtained faster than the first.
500 // The same wsave array can be used by rfftf and rfftb.
501 // </dl>
502 // Output parameters:
503 // <dl compact>
504 // <dt><b>r</b>
505 // <dd> for n even and for i = 1,...,n<br>
506 // r(i) = r(1)+(-1)**(i-1)*r(n)<br>
507 // plus the sum from k=2 to k=n/2 of<br>
508 // 2.*r(2*k-2)*cos((k-1)*(i-1)*2*pi/n)<br>
509 // -2.*r(2*k-1)*sin((k-1)*(i-1)*2*pi/n)<br>
510 // for n odd and for i = 1,...,n<br>
511 // r(i) = r(1) plus the sum from k=2 to k=(n+1)/2 of<br>
512 // 2.*r(2*k-2)*cos((k-1)*(i-1)*2*pi/n)<br>
513 // -2.*r(2*k-1)*sin((k-1)*(i-1)*2*pi/n)<br>
514 //
515 // note:
516 // this transform is unnormalized since a call of rfftf
517 // followed by a call of rfftb will multiply the input
518 // sequence by n.
519 // <dt><b>wsave</b>
520 // <dd> Contains results which must not be destroyed between
521 // calls of rfftb or rfftf.
522 // </dl>
523 // <group>
524 static void rfftb(Int n, Float* r, Float* wsave);
525 static void rfftb(Int n, Double* r, Double* wsave);
526 // </group>
527
528 // ezffti initializes the array wsave which is used in both <src>ezfftf</src>
529 // and <src>ezfftb</src>. The prime factorization of n together with a
530 // tabulation of the trigonometric functions are computed and stored in wsave.
531 //
532 // Input parameter:
533 // <dl compact>
534 // <dt><b>n</b>
535 // <dd> The length of the sequence to be transformed.
536 // </dl>
537 // Output parameter:
538 // <dl compact>
539 // <dt><b>wsave</b>
540 // <dd> A work array which must be dimensioned at least 3*n+15.
541 // The same work array can be used for both ezfftf and ezfftb
542 // as long as n remains unchanged. Different wsave arrays
543 // are required for different values of n.
544 // </dl>
545 static void ezffti(Int n, Float* wsave);
546
547 // ezfftf computes the Fourier coefficients of a real
548 // perodic sequence (Fourier analysis). The transform is defined
549 // below at output parameters azero, a and b. ezfftf is a simplified
550 // but slower version of rfftf.
551 //
552 // Input parameters:
553 // <dl compact>
554 // <dt><b>n</b>
555 // <dd> The length of the array r to be transformed. The method
556 // is most efficient when n is the product of small primes.
557 // <dt><b>r</b>
558 // <dd> A real array of length n which contains the sequence
559 // to be transformed. r is not destroyed.
560 // <dt><b>wsave</b>
561 // <dd> A work array which must be dimensioned at least 3*n+15
562 // in the program that calls ezfftf. The wsave array must be
563 // initialized by calling <src>ezffti(n,wsave)</src> and a
564 // different wsave array must be used for each different
565 // value of n. This initialization does not have to be
566 // repeated so long as n remains unchanged thus subsequent
567 // transforms can be obtained faster than the first.
568 // The same wsave array can be used by ezfftf and ezfftb.
569 // </dl>
570 // Output parameters:
571 // <dl compact>
572 // <dt><b>azero</b>
573 // <dd> The sum from i=1 to i=n of r(i)/n
574 // <dt><b>a,b</b>
575 // <dd> Real arrays of length n/2 (n even) or (n-1)/2 (n odd)<br>
576 // for n even<br>
577 // b(n/2)=0, and <br>
578 // a(n/2) is the sum from i=1 to i=n of (-1)**(i-1)*r(i)/n<br>
579 //
580 // for n even define kmax=n/2-1<br>
581 // for n odd define kmax=(n-1)/2<br>
582 // then for k=1,...,kmax<br>
583 // a(k) equals the sum from i=1 to i=n of<br>
584 // 2./n*r(i)*cos(k*(i-1)*2*pi/n)<br>
585 // b(k) equals the sum from i=1 to i=n of<br>
586 // 2./n*r(i)*sin(k*(i-1)*2*pi/n)<br>
587 // </dl>
588 static void ezfftf(Int n, Float* r, Float* azero, Float* a, Float* b, Float* wsave);
589
590 // ezfftb computes a real perodic sequence from its
591 // Fourier coefficients (Fourier synthesis). The transform is
592 // defined below at output parameter r. ezfftb is a simplified
593 // but slower version of rfftb.
594 //
595 // Input parameters:
596 // <dl compact>
597 // <dt><b>n</b>
598 // <dd> The length of the output array r. The method is most
599 // efficient when n is the product of small primes.
600 // <dt><b>azero</b>
601 // <dd> The constant Fourier coefficient
602 // <dt><b>a,b</b>
603 // <dd> Arrays which contain the remaining Fourier coefficients
604 // these arrays are not destroyed.
605 // The length of these arrays depends on whether n is even or
606 // odd.
607 // If n is even n/2 locations are required,
608 // if n is odd (n-1)/2 locations are required.
609 // <dt><b>wsave</b>
610 // <dd> A work array which must be dimensioned at least 3*n+15.
611 // in the program that calls ezfftb. The wsave array must be
612 // initialized by calling <src>ezffti(n,wsave)</src> and a
613 // different wsave array must be used for each different
614 // value of n. This initialization does not have to be
615 // repeated so long as n remains unchanged thus subsequent
616 // transforms can be obtained faster than the first.
617 // The same wsave array can be used by ezfftf and ezfftb.
618 // </dl>
619 // Output parameters:
620 // <dl compact>
621 // <dt><b>r</b>
622 // <dd> if n is even define kmax=n/2<br>
623 // if n is odd define kmax=(n-1)/2<br>
624 // then for i=1,...,n<br>
625 // r(i)=azero plus the sum from k=1 to k=kmax of<br>
626 // a(k)*cos(k*(i-1)*2*pi/n)+b(k)*sin(k*(i-1)*2*pi/n)<br>
627 // where<br>
628 // c(k) = .5*cmplx(a(k),-b(k)) for k=1,...,kmax<br>
629 // c(-k) = conjg(c(k))<br>
630 // c(0) = azero<br>
631 // and i=sqrt(-1)<br>
632 // </dl>
633 static void ezfftb(Int n, Float* r, Float* azero, Float* a, Float* b, Float* wsave);
634
635 // sinti initializes the array wsave which is used in
636 // <src>sint</src>. The prime factorization of n together with a tabulation of
637 // the trigonometric functions are computed and stored in wsave.
638 //
639 // Input parameter:
640 // <dl compact>
641 // <dt><b>n</b>
642 // <dd> The length of the sequence to be transformed. the method
643 // is most efficient when n+1 is a product of small primes.
644 // </dl>
645 // Output parameter:
646 // <dl compact>
647 // <dt><b>wsave</b>
648 // <dd> A work array with at least int(2.5*n+15) locations.
649 // Different wsave arrays are required for different values
650 // of n. The contents of wsave must not be changed between
651 // calls of sint.
652 // </dl>
653 // <group>
654 static void sinti(Int n, Float* wsave);
655 static void sinti(Int n, Double* wsave);
656 // </group>
657
658 // sint computes the discrete Fourier sine transform
659 // of an odd sequence x(i). The transform is defined below at
660 // output parameter x.
661 // sint is the unnormalized inverse of itself since a call of sint
662 // followed by another call of sint will multiply the input sequence
663 // x by 2*(n+1).
664 // The array wsave which is used by sint must be
665 // initialized by calling <src>sinti(n,wsave)</src>.
666 //
667 // Input parameters:
668 // <dl compact>
669 // <dt><b>n</b>
670 // <dd> The length of the sequence to be transformed. The method
671 // is most efficient when n+1 is the product of small primes.
672 // <dt><b>x</b>
673 // <dd> An array which contains the sequence to be transformed
674 // <dt><b>wsave</b>
675 // <dd> A work array with dimension at least int(2.5*n+15)
676 // in the program that calls sint. The wsave array must be
677 // initialized by calling <src>sinti(n,wsave)</src> and a
678 // different wsave array must be used for each different
679 // value of n. This initialization does not have to be
680 // repeated so long as n remains unchanged thus subsequent
681 // transforms can be obtained faster than the first.
682 // </dl>
683 // Output parameters:
684 // <dl compact>
685 // <dt><b>x</b>
686 // <dd> for i=1,...,n<br>
687 // x(i) = the sum from k=1 to k=n<br>
688 // 2*x(k)*sin(k*i*pi/(n+1))<br>
689 //
690 // a call of sint followed by another call of
691 // sint will multiply the sequence x by 2*(n+1).
692 // Hence sint is the unnormalized inverse
693 // of itself.
694 //
695 // <dt><b>wsave</b>
696 // <dd> Contains initialization calculations which must not be
697 // destroyed between calls of sint.
698 // </dl>
699 // <group>
700 static void sint(Int n, Float* x, Float* wsave);
701 static void sint(Int n, Double* x, Double* wsave);
702 // </group>
703
704 // costi initializes the array wsave which is used in
705 // <src>cost</src>. The prime factorization of n together with a tabulation of
706 // the trigonometric functions are computed and stored in wsave.
707 //
708 // Input parameter:
709 // <dl compact>
710 // <dt><b>n</b>
711 // <dd> The length of the sequence to be transformed. The method
712 // is most efficient when n-1 is a product of small primes.
713 // </dl>
714 // Output parameter:
715 // <dl compact>
716 // <dt><b>wsave</b>
717 // <dd> A work array which must be dimensioned at least 3*n+15.
718 // Different wsave arrays are required for different values
719 // of n. The contents of wsave must not be changed between
720 // calls of cost.
721 // </dl>
722 // <group>
723 static void costi(Int n, Float* wsave);
724 static void costi(Int n, Double* wsave);
725 // </group>
726
727 // cost computes the discrete Fourier cosine transform
728 // of an even sequence x(i). The transform is defined below at output
729 // parameter x.
730 // cost is the unnormalized inverse of itself since a call of cost
731 // followed by another call of cost will multiply the input sequence
732 // x by 2*(n-1). The transform is defined below at output parameter x.
733 // The array wsave which is used by <src>cost</src> must be
734 // initialized by calling <src>costi(n,wsave)</src>.
735 //
736 // Input parameters:
737 // <dl compact>
738 // <dt><b>n</b>
739 // <dd> The length of the sequence x. n must be greater than 1.
740 // The method is most efficient when n-1 is a product of
741 // small primes.
742 // <dt><b>x</b>
743 // <dd> An array which contains the sequence to be transformed
744 // <dt><b>wsave</b>
745 // <dd> A work array which must be dimensioned at least 3*n+15
746 // in the program that calls cost. The wsave array must be
747 // initialized by calling <src>costi(n,wsave)</src> and a
748 // different wsave array must be used for each different
749 // value of n. This initialization does not have to be
750 // repeated so long as n remains unchanged thus subsequent
751 // transforms can be obtained faster than the first.
752 // </dl>
753 // Output parameters:
754 // <dl compact>
755 // <dt><b>x</b>
756 // <dd> for i=1,...,n<br>
757 // x(i) = x(1)+(-1)**(i-1)*x(n)<br>
758 // + the sum from k=2 to k=n-1<br>
759 // 2*x(k)*cos((k-1)*(i-1)*pi/(n-1))<br>
760 //
761 // a call of cost followed by another call of
762 // cost will multiply the sequence x by 2*(n-1)
763 // hence cost is the unnormalized inverse
764 // of itself.
765 // <dt><b>wsave</b>
766 // <dd> Contains initialization calculations which must not be
767 // destroyed between calls of cost.
768 // </dl>
769 // <group>
770 static void cost(Int n, Float* x, Float* wsave);
771 static void cost(Int n, Double* x, Double* wsave);
772 // </group>
773
774 // sinqi initializes the array wsave which is used in both <src>sinqf</src> and
775 // <src>sinqb</src>. The prime factorization of n together with a tabulation of
776 // the trigonometric functions are computed and stored in wsave.
777 //
778 // Input parameter:
779 // <dl compact>
780 // <dt><b>n</b>
781 // <dd> The length of the sequence to be transformed. The method
782 // is most efficient when n is a product of small primes.
783 // </dl>
784 // Output parameter:
785 // <dl compact>
786 // <dt><b>wsave</b>
787 // <dd> A work array which must be dimensioned at least 3*n+15.
788 // The same work array can be used for both sinqf and sinqb
789 // as long as n remains unchanged. Different wsave arrays
790 // are required for different values of n. The contents of
791 // wsave must not be changed between calls of sinqf or sinqb.
792 // </dl>
793 // <group>
794 static void sinqi(Int n, Float* wsave);
795 static void sinqi(Int n, Double* wsave);
796 // </group>
797
798 // sinqf computes the fast Fourier transform of quarter wave data. That is,
799 // sinqf computes the coefficients in a sine series representation with only
800 // odd wave numbers. The transform is defined below at output parameter x.
801 //
802 // sinqb is the unnormalized inverse of sinqf since a call of sinqf followed by
803 // a call of sinqb will multiply the input sequence x by 4*n.
804 //
805 // The array wsave which is used by sinqf must be initialized by calling
806 // <src>sinqi(n,wsave)</src>.
807 //
808 // Input parameters:
809 // <dl compact>
810 // <dt><b>n</b>
811 // <dd> The length of the array x to be transformed. The method
812 // is most efficient when n is a product of small primes.
813 // <dt><b>x</b>
814 // <dd> An array which contains the sequence to be transformed
815 // <dt><b>wsave</b>
816 // A work array which must be dimensioned at least 3*n+15.
817 // in the program that calls sinqf. The wsave array must be
818 // initialized by calling <src>sinqi(n,wsave)</src> and a
819 // different wsave array must be used for each different
820 // value of n. This initialization does not have to be
821 // repeated so long as n remains unchanged thus subsequent
822 // transforms can be obtained faster than the first.
823 // </dl>
824 // Output parameters:
825 // <dl compact>
826 // <dt><b>x</b>
827 // <dd> for i=1,...,n<br>
828 // x(i) = (-1)**(i-1)*x(n)<br>
829 // + the sum from k=1 to k=n-1 of<br>
830 // 2*x(k)*sin((2*i-1)*k*pi/(2*n))<br>
831 //
832 // a call of sinqf followed by a call of
833 // sinqb will multiply the sequence x by 4*n.
834 // therefore sinqb is the unnormalized inverse
835 // of sinqf.
836 // <dt><b>wsave </b>
837 // <dd> Contains initialization calculations which must not
838 // be destroyed between calls of sinqf or sinqb.
839 // </dl>
840 // <group>
841 static void sinqf(Int n, Float* x, Float* wsave);
842 static void sinqf(Int n, Double* x, Double* wsave);
843 // </group>
844
845 // sinqb computes the fast Fourier transform of quarter
846 // wave data. that is, sinqb computes a sequence from its
847 // representation in terms of a sine series with odd wave numbers.
848 // the transform is defined below at output parameter x.
849 //
850 // sinqf is the unnormalized inverse of sinqb since a call of sinqb
851 // followed by a call of sinqf will multiply the input sequence x
852 // by 4*n.
853 //
854 // The array wsave which is used by <src>sinqb</src> must be
855 // initialized by calling <src>sinqi(n,wsave)</src>.
856 //
857 // Input parameters:
858 // <dl compact>
859 // <dt><b>n</b>
860 // <dd> The length of the array x to be transformed. The method
861 // is most efficient when n is a product of small primes.
862 // <dt><b>x</b>
863 // <dd> An array which contains the sequence to be transformed
864 // <dt><b>wsave</b>
865 // A work array which must be dimensioned at least 3*n+15.
866 // in the program that calls sinqb. The wsave array must be
867 // initialized by calling <src>sinqi(n,wsave)</src> and a
868 // different wsave array must be used for each different
869 // value of n. This initialization does not have to be
870 // repeated so long as n remains unchanged thus subsequent
871 // transforms can be obtained faster than the first.
872 // </dl>
873 // Output parameters:
874 // <dl compact>
875 // <dt><b>x</b>
876 // <dd> for i=1,...,n<br>
877 // x(i)= the sum from k=1 to k=n of<br>
878 // 4*x(k)*sin((2k-1)*i*pi/(2*n))<br>
879 //
880 // a call of sinqb followed by a call of
881 // sinqf will multiply the sequence x by 4*n.
882 // Therefore sinqf is the unnormalized inverse
883 // of sinqb.
884 // <dt><b>wsave</b>
885 // <dd> Contains initialization calculations which must not
886 // be destroyed between calls of sinqb or sinqf.
887 // </dl>
888 // <group>
889 static void sinqb(Int n, Float* x, Float* wsave);
890 static void sinqb(Int n, Double* x, Double* wsave);
891 // </group>
892
893 // <group>
894 static void cosqi(Int n, Float* wsave);
895 static void cosqi(Int n, Double* wsave);
896 // </group>
897 // <group>
898 static void cosqf(Int n, Float* x, Float* wsave);
899 static void cosqf(Int n, Double* x, Double* wsave);
900 // </group>
901 // <group>
902 static void cosqb(Int n, Float* x, Float* wsave);
903 static void cosqb(Int n, Double* x, Double* wsave);
904 // </group>
905};
906
907} // namespace casacore
908
909#endif
static void cosqf(Int n, Double *x, Double *wsave)
static void rfftb(Int n, Double *r, Double *wsave)
static void sinqi(Int n, Double *wsave)
static void ezfftb(Int n, Float *r, Float *azero, Float *a, Float *b, Float *wsave)
ezfftb computes a real perodic sequence from its Fourier coefficients (Fourier synthesis).
static void cost(Int n, Double *x, Double *wsave)
static void ezfftf(Int n, Float *r, Float *azero, Float *a, Float *b, Float *wsave)
ezfftf computes the Fourier coefficients of a real perodic sequence (Fourier analysis).
static void sinqi(Int n, Float *wsave)
sinqi initializes the array wsave which is used in both sinqf and sinqb.
static void sint(Int n, Float *x, Float *wsave)
sint computes the discrete Fourier sine transform of an odd sequence x(i).
static void cfftf(Int n, Complex *c, Float *wsave)
cfftf computes the forward complex discrete Fourier transform (the Fourier analysis).
static void rfftb(Int n, Float *r, Float *wsave)
rfftb computes the real perodic sequence from its Fourier coefficients (Fourier synthesis).
static void cfft2b(const Int &LDIM, const Int &L, const Int &M, Complex *&C, Float *&WSAVE, const Int &LENSAV, Float *&WORK, const Int &LENWRK, Int &IER)
Documentation from FFTPack 5.1.
static void cfftf(Int n, DComplex *c, Double *wsave)
static void cosqb(Int n, Double *x, Double *wsave)
static void rffti(Int n, Double *wsave)
static void sinqb(Int n, Double *x, Double *wsave)
static void sinqf(Int n, Double *x, Double *wsave)
static void cfft2f(const Int &ldim, const Int &L, const Int &M, Complex *&C, Float *&WSAVE, const Int &LENSAV, Float *&WORK, const Int &LENWRK, Int &IER)
Description from FFTPack 5.1.
static void sinti(Int n, Double *wsave)
static void cffti(Int n, Float *wsave)
cffti initializes the array wsave which is used in both cfftf and cfftb.
static void costi(Int n, Float *wsave)
costi initializes the array wsave which is used in cost.
static void cost(Int n, Float *x, Float *wsave)
cost computes the discrete Fourier cosine transform of an even sequence x(i).
static void rfftf(Int n, Float *r, Float *wsave)
rfftf computes the Fourier coefficients of a real perodic sequence (Fourier analysis).
static void cfftb(Int n, Complex *c, Float *wsave)
cfftb computes the backward complex discrete Fourier transform (the Fourier synthesis).
static void cfft2i(const Int &n, const Int &m, Float *&wsave, const Int &lensav, Int &ier)
Here is the doc from FFTPack 5.1 You can convert the linguo from fortran to C/C++.
static void cosqi(Int n, Float *wsave)
static void sinqf(Int n, Float *x, Float *wsave)
sinqf computes the fast Fourier transform of quarter wave data.
static void cffti(Int n, Double *wsave)
static void cosqi(Int n, Double *wsave)
static void sint(Int n, Double *x, Double *wsave)
static void sinti(Int n, Float *wsave)
sinti initializes the array wsave which is used in sint.
static void sinqb(Int n, Float *x, Float *wsave)
sinqb computes the fast Fourier transform of quarter wave data.
static void cosqf(Int n, Float *x, Float *wsave)
static void rffti(Int n, Float *wsave)
rffti initializes the array wsave which is used in both rfftf and rfftb.
static void cosqb(Int n, Float *x, Float *wsave)
static void rfftf(Int n, Double *r, Double *wsave)
static void ezffti(Int n, Float *wsave)
ezffti initializes the array wsave which is used in both ezfftf and ezfftb.
static void cfftb(Int n, DComplex *c, Double *wsave)
static void costi(Int n, Double *wsave)
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
double Double
Definition aipstype.h:53