Help language development. Donate to The Perl Foundation

Math::FFT::Libfftw3 cpan:FRITH last updated on 2019-11-30

examples/1Dtransform.p6
#!/usr/bin/env perl6

use Math::FFT::Libfftw3::C2C;
use Math::FFT::Libfftw3::Constants;

my @in = (0, π/100 … 2*π)».sin;
put @in».Complex».round(10⁻¹²); # print the original array as complex values rounded to 10⁻¹²
my Math::FFT::Libfftw3::C2C $fft .= new: data => @in;
my @out = $fft.execute;
put @out; # print the direct transform output
my Math::FFT::Libfftw3::C2C $fftr .= new: data => @out, direction => FFTW_BACKWARD;
my @outr = $fftr.execute;
put @outr».round(10⁻¹²); # print the backward transform output rounded to 10⁻¹²