Skip to content

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

Merged
merged 7 commits into from
Jul 17, 2019
Merged

FFT Javascript Implementation #599

merged 7 commits into from
Jul 17, 2019

Conversation

benchislett
Copy link
Contributor

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.

@june128 june128 added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Apr 10, 2019
Copy link
Contributor

@Trashtalk217 Trashtalk217 left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@leios
Copy link
Member

leios commented Jun 13, 2019

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.

@leios
Copy link
Member

leios commented Jul 17, 2019

@Trashtalk217 If you have no further comments, I think we are ready to merge this one.

Copy link
Member

@leios leios left a 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!

@leios leios merged commit 0c969cb into algorithm-archivists:master Jul 17, 2019
@leios leios mentioned this pull request Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants