-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Discrete Fourier Transform example #150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing, thanks a lot.
I did a first round, but I need more time to wrap my head around it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice example. I left a few comments but overall, its really nice. And I learned some things about the Discrete Fourier Transform (DFT).
One general comment, we now try to follow a common commenting style in MASM, see https://github.com/0xPolygonMiden/miden-base/blob/main/miden-lib/asm/faucets/basic.masm#L39C1-L39C1 where we always
- explain a function or line of instructions above it, i.e.
# get max supply of this faucet. We assume it is stored at pos 3 of slot 1
- indicate the new stack below it, i.e.,
# => [max_supply, amount, tag, RECIPIENT, ...]
examples/dft.masm
Outdated
# Input: [n, v0, ..., v{n-1}, ...] | ||
# Output: [...] | ||
proc.store_array | ||
# Store n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to store n
again here? Looks like you did that already in procedure main
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This store_array
procedure was written to be self-contained (modulo the fact that it uses the global INPUT_ARR_LOC
instead of receiving that address on the stack, but I got lazy); i.e. it can be used to store array of any length. So you could do (pseudocode)
# Storing arrays of different lengths
exec.store_array([4,1,2,3,4])
exec.store_array([3,1,2,3])
Basically, an array is [length, ele_0, ..., ele_{length-1}]
, and this mem_store
stores the length
(which could be different from call to call).
Kudos, SonarCloud Quality Gate passed! |
@Dominik1999 Changed the code to follow the comment convention |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
Implements the Discrete Fourier Transform over the input list. Basically, this is the non-efficient version of the Number Theoretic Transform (NTT).
You can verify the correctness of the program by comparing with the Python implementation:
Conceptually though, this Miden implementation is closer to