Fast Fourier transform: Difference between revisions

m
 
(5 intermediate revisions by 5 users not shown)
Line 229:
FOR I% = 0 TO 7
READ in{(I%)}.r#
out{(I%)}.r# = in{(I%)}.r#
PRINT in{(I%)}.r# "," in{(I%)}.i#
NEXT
Line 2,708 ⟶ 2,709:
ucomplex;
 
{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined}
(*) Use for variants and ucomplex (*)
 
 
Line 3,645 ⟶ 3,648:
=={{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,657:
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,678:
}</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,687:
fft(@_[1,3...*]) «*« map &cisPi, (0,-2/@_...^-2)
}</syntaxhighlight>
-->
 
=={{header|REXX}}==
Line 4,608 ⟶ 4,615:
=={{header|VBA}}==
{{works with|VBA}}
{{trans|BBCBASICBBC_BASIC}}
Written and tested in Microsoft Visual Basic for Applications 7.1 under Office 365 Excel; but is probably useable under any recent version of VBA.
<syntaxhighlight lang="vba">Option Base 0
Line 4,689 ⟶ 4,696:
1 2.414213562</pre>
 
=={{header|V (Vlang)}}==
{{trans|Go}}
<syntaxhighlight lang="v (vlang)">import math.complex
import math
fn ditfft2(x []f64, mut y []Complex, n int, s int) {
Line 4,736 ⟶ 4,743:
{{libheader|Wren-complex}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="ecmascriptwren">import "./complex" for Complex
import "./fmt" for Fmt
 
var ditfft2 // recursive
122

edits