Skip to content

Support Unitful data? #225

@JeffFessler

Description

@JeffFessler

Currently fft fails for Unitful data. It is pretty easy to write a work-around that does not even add any dependency on the Unitful package, by using oneunit in Base:

using Unitful: mm
using FFTW: fft
import FFTW: fft

x = ones(8)*mm
#fft(x) # fails ERROR: LoadError: MethodError: no method matching plan_fft...

function fft(x::AbstractArray{<:Number})
    u = oneunit(eltype(x))
    return fft(x / u) * u
end

fft(x) # works as desired

Edit: perhaps the support should be added at the plan_fft level or such.
Would there be openness for a PR to add such support to FFTW?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions