Computes a real 1- or 2-D FFT.


y = rfftn(x)
Parameters:x (NxK real matrix) – data
Returns:y (LxM matrix) – where \(L\) and \(M\) are the smallest prime factor products greater than or equal to \(N\) and \(K\), respectively.


rfftn() uses the Temperton prime factor FFT algorithm. This algorithm can compute the FFT of any vector or matrix whose dimensions can be expressed as the product of selected prime number factors. GAUSS implements the Temperton algorithm for any power of 2, 3, and 5, and one factor of 7. Thus, rfftn can handle any matrix whose dimensions can be expressed as:

\[2^p \times 3^q \times 5^r \times 7^s\]

For rows of the matrix :

\[p, q, r \geq 0\]

For columns of the matrix or length of a vector:

\[\begin{split}p > 0\\ q, r \geq 0\end{split}\]

For all dimensions:

\[s = 0 \text{ or } 1\]

If a dimension of x does not meet these requirements, it will be padded with zeros to the next allowable size before the FFT is computed.

rfftn() pads matrices to the next allowable size; however, it generally runs faster for matrices whose dimensions are highly composite numbers, i.e., products of several factors (to various powers), rather than powers of a single factor. For example, even though it is bigger, a 33600x1 vector can compute as much as 20 percent faster than a 32768x1 vector, because 33600 is a highly composite number, \(2\ :sup:\)x3x52x7`, whereas 32768 is a simple power of 2, \(2\ :sup:\). For this reason, you may want to hand-pad matrices to optimum dimensions before passing them to rfftn(). The Run-Time Library includes two routines, optn() and optnevn(), for determining optimum dimensions. Use optn() to determine optimum rows for matrices, and optnevn() to determine optimum columns for matrices and optimum lengths for vectors.

The Run-Time Library also includes the nextn() and nextnevn() routines, for determining allowable dimensions for matrices and vectors. (You can use these to see the dimensions to which rfftn() would pad a matrix or vector.)

rfftn() scales the computed FFT by \(\frac{1}{(L*M)}\).