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