Skip to contents

Provides functions to compute the Fast Fourier Transform (FFT) and its inverse (IFFT) while maintaining results in a tabular format. Supports vectors, time series (ts), and arrays as inputs.

Usage

fftab(x, norm = FALSE)

# Default S3 method
fftab(x, norm = FALSE)

# S3 method for class 'ts'
fftab(x, norm = FALSE)

# S3 method for class 'array'
fftab(x, norm = FALSE)

ifftab(x)

Arguments

x

Input object for which to compute the FFT or IFFT. This can be:

  • A numeric vector (default method for fftab).

  • A time series object (ts) for fftab.ts.

  • A multidimensional numeric array for fftab.array.

  • A fftab object for ifftab.

norm

Logical. If TRUE, computes normalized coefficients for FFT.

Value

  • fftab: A tibble containing:

    • Fourier frequencies (.dim_1, .dim_2, etc.).

    • FFT values stored in the fx column as complex values.

  • ifftab: A vector, array, or time series object representing the reconstructed signal.

Details

  • fftab organizes FFT results into a tibble for downstream analysis.

  • ifftab ensures that reconstructed signals match the input structure (e.g., arrays, ts).

FFT

The fftab function computes the FFT for different input types:

  • Default Input (fftab.default): Computes FFT for numeric vectors.

  • Time Series Input (fftab.ts): Handles FFT for ts objects, scaling frequencies appropriately.

  • Array Input (fftab.array): Processes multidimensional arrays.

Results are returned as a tibble containing Fourier frequencies and FFT values.

IFFT

The ifftab function reconstructs the original signal from a fftab object. It supports vectors, arrays, and time series inputs. The inverse transform preserves the original structure (e.g., array dimensions or time series attributes).

See also

Examples

fftab(c(1, 0, -1, 0))
#> # A tibble: 4 × 2
#>   .dim_1 fx   
#> *  <dbl> <cpl>
#> 1   0    0+0i 
#> 2   0.25 2+0i 
#> 3   0.5  0+0i 
#> 4  -0.25 2+0i 

fftab(c(1, 0, -1, 0)) |> ifftab()
#> [1]  1  0 -1  0

ts(sin(1:10), frequency = 12) |> fftab()
#> # A tibble: 10 × 2
#>    .dim_1 fx                   
#>  *  <dbl> <cpl>                
#>  1    0    1.4111884+0.0000000i
#>  2    1.2  1.7597704+2.0140018i
#>  3    2.4 -0.0540927-3.7860893i
#>  4    3.6  0.6552682-1.0310219i
#>  5    4.8  0.7536372-0.4010851i
#>  6    6    0.7743552+0.0000000i
#>  7   -4.8  0.7536372+0.4010851i
#>  8   -3.6  0.6552682+1.0310219i
#>  9   -2.4 -0.0540927+3.7860893i
#> 10   -1.2  1.7597704-2.0140018i

array(1:8, dim = c(2, 2, 2)) |> fftab()
#> # A tibble: 8 × 4
#>   .dim_1 .dim_2 .dim_3 fx    
#> *  <dbl>  <dbl>  <dbl> <cpl> 
#> 1    0      0      0    36+0i
#> 2    0.5    0      0    -4+0i
#> 3    0      0.5    0    -8+0i
#> 4    0.5    0.5    0     0+0i
#> 5    0      0      0.5 -16+0i
#> 6    0.5    0      0.5   0+0i
#> 7    0      0.5    0.5   0+0i
#> 8    0.5    0.5    0.5   0+0i