-
-
Notifications
You must be signed in to change notification settings - Fork 359
FFT Javascript Implementation #599
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
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.
While I've not been able to check if the code runs, it looks good from a syntactic standpoint and the comments are helpfull. I still have a couple of questions, but once that is cleared up it should be good to go.
return x.map((_, i) => x[indexes[i]]); | ||
} | ||
|
||
// Assumes log_2(N) is an integer |
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.
Why is this comment floating?
The Julia code also doesn't asume log2(n) to be an integer, does this output the same results?
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 a radix-2 cooley-tukey implementation if I'm not mistaken, and requires that N be a power of two. The bit reversal algorithm also operates with radix-2 so it requires that N be a power of two, and thus that log2(N) be integral.
Here in particular, the displacement array is generated, and will always be of power-of-two length. The recursive nature of the bit_reverse_idxs
function requires that the input be a positive integer or it will infinitely recurse as n goes into the negative non-integers.
let zdiff = 0; | ||
for (let i = 0; i < X.length; i++) { | ||
ydiff += (Y[i].sub(T[i])).abs(); | ||
zdiff += (Z[i].sub(T[i])).abs(); |
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.
In the Julia code the approximation-check has been made a seperate function, it might be a good idea to do that here as well.
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.
For consistency or syntactically? I personally think that it's fine where it is and that another function would be too much for this simple piece of code, but I'm not set in that opinion.
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.
I think it is a bit more clear in a function. At the very least, a comment would be appreciated.
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.
Done!
I'm happy with the implementation and the line numbers seem correct. If @Trashtalk217 is happy with the javascript as well, I believe this can be merged. |
@Trashtalk217 If you have no further comments, I think we are ready to merge this one. |
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.
If @Trashtalk217 and @benchislett are happy, I am happy to approve!
Made use of Complex.js for dealing with complex numbers.
Implementation is fairly similar to the Python one, a key difference being the bit reversal step.
Instead of dealing with bits, the double-concat algorithm is implemented, described here.