Skip to contents

Extends stats::fft() to work with mlx objects while delegating to the standard R implementation for other inputs.

Usage

fft(z, inverse = FALSE, ...)

Arguments

z

Input to transform. May be a numeric, complex, or mlx object.

inverse

Logical flag; if TRUE compute the inverse transform.

...

Passed through to the default method.

Value

For mlx inputs, an mlx object containing complex frequency coefficients; otherwise the base R result.

Examples

z <- as_mlx(c(1, 2, 3, 4))
fft(z)
#> mlx array [4]
#>   dtype: complex64
#>   device: gpu
#>   values:
#> [1] 10+0i -2+2i -2+0i -2-2i
fft(z, inverse = TRUE)
#> mlx array [4]
#>   dtype: complex64
#>   device: gpu
#>   values:
#> [1] 10+0i -2-2i -2+0i -2+2i