Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An easy to use type impulse #23

Closed
arturgower opened this issue Jun 16, 2018 · 1 comment
Closed

An easy to use type impulse #23

arturgower opened this issue Jun 16, 2018 · 1 comment
Milestone

Comments

@arturgower
Copy link
Member

arturgower commented Jun 16, 2018

Currently the struct impulse is very elegant: it has two fields, which are functions representing the impulse in time and frequency (one being the analytic Fourier Transform of the other). However, I think the struct should be easy to use and understand for the most common cases of use. These are:

  1. simple analytic functions like a discrete delta and Gaussian
  2. providing a discrete impulse in either time (most common) or frequency. This is always the case when comparing with experiments.

In both cases, it should be easy to plot both the impulse in time and frequency, even if the user only provided the impulse in, say, time. Currently I think it is not easy to provide 2, and even the inability to plot the discrete delta function in 1 will confuse most. For example, after sampling the discrete delta in frequency, it can be useful to look at the resulting impulse in time, and vice-versa (a common exercise in signal processing). It helps decide how to sample the frequency.

I think it will make our lives easier to use instead

struct Impulse{T<:AbstractFloat}
    in_time::Vector{T}
    in_freq:::Vector{Complex{T}}
    t::Vector{T}
    ω::Vector{T}
end

One draw back is that it seems that both the vectors ω and t need to be supplied. But this is not really an issue in practice, and, for example, the impulse in time can be easily re-sampled from the impulse in frequency for a different t vector.

Although the struct impulse is elegant, and is more flexible than above, there is no clear example where this flexibility is needed. And I think it is not worth the added complications of trying to convert impulse vectors to functions.

@arturgower arturgower added this to the Version 0.2 milestone Jun 16, 2018
@jondea
Copy link
Member

jondea commented Jun 16, 2018

I suppose there's no reason not to have both, one called DiscreteImpulse and the other ContinuousImpulse. Users wouldn't even have to see them, they'd just use the most relevant constructor and multiple dispatch will decide how to compute with them.

arturgower added a commit that referenced this issue Jun 17, 2018
changes made:
- the default now is to use the DiscreteImpulse rather than the continuous impulse
- Dirac delta in frequency has a constant different from Dirac in time
- time_to_frequency now also multiplies the impulse in frequency. To use the impulse in time it should be a convolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants