41Z Routine of the week: DFT
|
02-22-2017, 01:54 PM
(This post was last modified: 02-22-2017 08:24 PM by Ángel Martin.)
Post: #1
|
|||
|
|||
41Z Routine of the week: DFT
Discrete Fourier Transform with the 41Z Module.
Not much of a groundbreaking algorithm, the program below uses the straightforward definition to obtain the DFT and inverse DFT of a set of N complex data points, stored in complex data registers ZR01 to ZR0n. You can use the sub-function ZINPT from the module to enter all values. Just enter the sample size in X, and execute ZDFT. The results are stored in complex registers ZRn+1 to ZR(2n). You can use the sub-function ZOUPT to see the values. If you want to apply the inverse DFT to the results you can use REGSWAP to reset the locations: 2,00(2+2n)00(2n). i.e. 2,010|008 for n=4. Then run ZIDFT to obtain the original values (except rounding). Example: DFT [ 1+2i ; 3+4i ; 5+6i ; 7+8i ] = [ 16+20.i ; -8 ; -4-4.i ; -8.i ] IDFT [ 16+20.i ; -8 ; -4-4.i ; -8.i ] = [ 1+2i ; 3+4i ; 5+6i ; 7+8i ] Code: 01 LBL "ZDFT" As always, the execution time can be rather long for large size samples. Using the 41-CL or an emulator in Turbo mode is recommended. Feedback is welcome - would be great to get an FFT implementation as well... any volunteers? "To live or die by your own sword one must first learn to wield it aptly." |
|||
03-01-2017, 08:26 AM
Post: #2
|
|||
|
|||
RE: 41Z Routine of the week: DFT
'Angel,
I am having a problem executing this program... specifically steps 27 thru 33. You use the P register for storage at step 27, then enter E at step 31. I think this blows part of the P register, so your recall at step 33 won't work properly, or do I understand your use of E as a step properly? I am thinking you are using E as a faster "1" entry. Greg. |
|||
03-01-2017, 05:05 PM
(This post was last modified: 08-11-2017 05:09 AM by Ángel Martin.)
Post: #3
|
|||
|
|||
RE: 41Z Routine of the week: DFT
Good catch Greg, thanks for the warning. Indeed using "E" is not a good idea if register P is also used for storage, I had completely forgotten about that... since I moved to the all-MCODE version in the updated module attached ;-)
So just change the "E" to a "1" and the program should work fine. Here's an alternative FOCAL version that should always work, just to close this issue. It does the intermediate multiplication in-situ so registers R00 and R01 are free to use now. Code: 01 LBL "ZDFT" Latest revision of the 41Z deluxe is attached. Cheers, Ángel "To live or die by your own sword one must first learn to wield it aptly." |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)