FFT Servers
Overview
Three fast Fourier transform (FFT) servers are included in the Essential Math Module class library:
*Class DComplexFFTServer transforms an RWMathVec<DComplex> vector into an RWMathVec<DComplex> and back;
*Class DoubleFFTServer transforms a real RWMathVec<double> into a complex conjugate-even vector and back;
*Class DComplexFFT2DServer transforms an RWGenMat<DComplex> matrix into an RWGenMat<DComplex> and back.
In addition, a fast sine/cosine transform server is included:
*Class DoubleCosineServer can take the sine or cosine transform of a real RWMathVec<double> into a real RWMathVec<double> and back.
The only restriction on the length of a vector that can be transformed is that a real RWMathVec<double> must have an even number of points. In particular, vector lengths need not be a power of 2, although the transform is more efficient if they are. More generally, vectors with lengths that have small prime factors transform the most efficiently. By definition, a power of 2 has prime factors of 2—the smallest of all.
At any given moment, a server is configured to transform a vector of a specified length. The appropriate weights, which are actually the roots of one of the prime factors, are stored internally. This length can be set:
*At construction time
*By using the member function setOrder()
*Dynamically from a vector length, as shown in the following code:
 
// Will transform vectors 10 points long:
DComplexFFTServer aserv(10);
 
aserv.setOrder(20); // Now set for 20 points
 
RWMathVec<DComplex> b(30, rwUninitialized);
.
.
.
// Forward FFT of b:
RWMathVec<DComplex> btrans = aserv.fourier(b);
 
//aserv would now be set for vectors 30 pts long.
 
Because reconfiguring for a new vector length is a relatively expensive process, if more than one vector length must be transformed within a program, it is better to build several servers rather than to keep reconfiguring one. This means it is possible to transform efficiently and conveniently more than one vector length within a stretch of code, something that is difficult to do with conventional Fortran-based FFT functions.
See the SourcePro API Reference Guide for a description of the exact transforms that are calculated.