MattOates / Math--FourierTransform

Discrete Fourier Transform for Perl 6
Artistic License 2.0
0 stars 3 forks source link

A suggestion #5

Open frithnanth opened 6 years ago

frithnanth commented 6 years ago

Hi, may I suggest to add an "examples" directory with at least one little program to show how to go from samples to spectrum and back? It might look like this:

use Math::FourierTransform;

my Complex @data = (1..6)».Complex;
say @data;
my Complex @spectrum = discrete-fourier-transform @data;
say @spectrum;
my Complex @back = (discrete-fourier-transform(@spectrum».conj)».conj) »/» @data.elems;
say @back;
# Let's cheat!
say @back».round(10⁻¹²);

Additional examples may show how to use the transformed data to implement a high or low-pass filter.

MattOates commented 6 years ago

Hi Fernando, if you want to edit the README with what you'd like to see I'm happy to accept a PR. That way you go on record as knowing whats happening in the example ;P