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