Fast Fourier transform: Difference between revisions

→‎{{header|Raku}}: mark as in need for improvement
(→‎{{header|Raku}}: mark as in need for improvement)
Line 3,645:
=={{header|Raku}}==
(formerly Perl 6)
{{Works with|rakudo 20152022-1207}}
{{improve|raku|Not numerically accurate}}
<syntaxhighlight lang="raku" line>sub fft {
return @_ if @_ == 1;
Line 3,653 ⟶ 3,654:
return flat @evn »+« @odd, @evn »-« @odd;
}
 
.say for fft <1 1 1 1 0 0 0 0>;</syntaxhighlight>
{{out}}
<pre>4+0i
1-02.414213562373095i
1-2.41421356237309i
0+0i
1-0.4142135623730949i
1-0.414213562373095i
0+0i
0.9999999999999999+0.4142135623730949i
1+0.414213562373095i
0+0i
1+0.9999999999999997+2.414213562373095i
1+2.41421356237309i</pre>
</pre>
 
For the fun of it, here is a purely functional version:
Line 3,673 ⟶ 3,675:
}</syntaxhighlight>
 
<!-- Not really helping now
This particular version is numerically inaccurate though, because of the pi approximation. It is possible to fix it with the 'cisPi' function available in the TrigPi module:
 
Line 3,681 ⟶ 3,684:
fft(@_[1,3...*]) «*« map &cisPi, (0,-2/@_...^-2)
}</syntaxhighlight>
-->
 
=={{header|REXX}}==
1,934

edits