fft2d: 2D fast-Fourier wrapper around 'fftwtools' or 'stats' package

View source: R/fft.R

fft2dR Documentation

2D fast-Fourier wrapper around 'fftwtools' or 'stats' package

Description

Utilises the Fastest Fourier Transform in the West (FFTW) via the 'fftwtools' package if available, else reverts to built-in functionality

Usage

fft2d(x, inverse = FALSE, fftw = fftw_available())

Arguments

x

A numeric matrix to be transformed.

inverse

Whether it should compute the inverse transform (defaults to FALSE).

fftw

Whether the fftwtools R package is available.

Details

This function is called wherever sparr seeks to perform a 2D fast-Fourier transform. Where available, computational expense is noticeably reduced by appealing to routines in the independent ‘FFTW’ toolbox. The user is encouraged to install the corresponding R package fftwtools from CRAN; this function will automatically detect and use the faster option, otherwise will defer to the built-in fft.

Value

The fast-Fourier (inverse) transform. A complex-valued matrix of the same size as x.

Author(s)

J.C. Marshall

Examples



# System check
sparr:::fftw_available()

system.time(fft(matrix(1:2000^2,2000)))
system.time(fft2d(matrix(1:2000^2,2000)))



tilmandavies/sparr documentation built on July 8, 2024, 2:57 p.m.