Using parametric types for Complex{T}

You can do something like:

function foo(x::Union{Vector{T}, Vector{Complex{T}}}, t::T) where T <: Union{Float32, Float64}
    tmp = T(0)
    ...
end

Or make it more readable with a definition:

const Signal{T} = Union{Vector{T}, Vector{Complex{T}}}

function foo(x::Signal{T}, t::T}) where T <: Union{Float32, Float64}
    tmp = T(0)
    ...
end
1 Like