something wrong with dfns FFT

For users of dfns, both novice and expert

something wrong with dfns FFT

Postby Stu on Mon Aug 07, 2017 12:57 am

I'd like to use the FFT and iFFT functions shown on the dfns page. When I try to run the FFT example there, I get the following:

x←9 3 5 8 1 0 5
y←6 2 2 7 4
x
9 3 5 8 1 0 5
y
6 2 3 7 4
FFT 16↑x
RANK ERROR: Invalid axis
floop[0] floop←{(⊣/⍺)∇⍣(×m)⊢(+⌿⍵),[m-0.5]⍺×[⍳m←≢⍴⍺]-⌿⍵}

FFT 16↑y
RANK ERROR: Invalid axis
floop[0] floop←{(⊣/⍺)∇⍣(×m)⊢(+⌿⍵),[m-0.5]⍺×[⍳m←≢⍴⍺]-⌿⍵}
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: something wrong with dfns FFT

Postby Adam|Dyalog on Mon Aug 07, 2017 9:13 am

For performance, may want to look into our Math namespace, which you can find at https://github.com/Dyalog/Math/releases.
User avatar
Adam|Dyalog
 
Posts: 134
Joined: Thu Jun 25, 2015 1:13 pm

Re: something wrong with dfns FFT

Postby Stu on Mon Aug 07, 2017 10:51 pm

Thanks! The Math namespace is great; however, I really wanted to see FFT/iFFT implemented in Dyalog (and also to understand why the code in dfns.dws doesn't work). Performance considerations are secondary for me at this point.
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: something wrong with dfns FFT

Postby Stu on Tue Aug 08, 2017 12:11 am

This is weird: FFT and iFFT work inside xtimes, but give an error when used alone, e.g.
x
1 2 3 4 5
y
2 3 4 5 6
x xtimes y ⍝ xtimes gives a numeric result, not an error:
2 8 9 5 6 4 3 2 0
12345 × 23456 ⍝ Ordinary multiplication gives the corresponding result:
289564320
FFT¨x extend y ⍝ This subexpression from xtimes generates an error:
RANK ERROR: Invalid axis
floop[0] floop←{(⊣/⍺)∇⍣(×m)⊢(+⌿⍵),[m-0.5]⍺×[⍳m←≢⍴⍺]-⌿⍵}

roots←{×\1,1↓(⍵÷2)⍴¯1*2÷⍵}
cube←{⍵⍴⍨2⍴⍨2⍟⍴⍵}
extend←{(2*⌈2⍟¯1+(⍴⍺)+⍴⍵)↑¨⍺ ⍵}
floop←{(⊣/⍺)∇⍣(×m)⊢(+⌿⍵),[m-0.5]⍺×[⍳m←≢⍴⍺]-⌿⍵}
FFT←{,(cube roots⍴⍵)floop cube ⍵}
iFFT←{(⍴⍵)÷⍨,(cube+roots⍴⍵)floop cube ⍵}
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: something wrong with dfns FFT

Postby Stu on Tue Aug 08, 2017 2:42 am

Duh! Never mind. ⎕IO needs to be 0 in the execution environment. Note to self: when in doubt, study the code.
Stu
 
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am


Return to Functional Programming

Who is online

Users browsing this forum: No registered users and 1 guest