-
-
Notifications
You must be signed in to change notification settings - Fork 360
Minor clean up for cooley tukey in C++ #276
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
Minor clean up for cooley tukey in C++ #276
Conversation
mika314
commented
Jul 19, 2018
- rename c64 to complex
- make pi a constant instead of function
- fix complilation warnings about comparing signed int with unsigned int
auto temp = std::vector<c64>(size / 2); | ||
for (size_t i = 0; i < size / 2; ++i) { | ||
auto temp = std::vector<complex>(size / 2); | ||
for (int i = 0; i < size / 2; ++i) { |
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.
Similarly to the other PR, this should actually be ptrdiff_t
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.
Copy from the other PR:
@Gustorn I decided to use int instead of ptrdiff_t to improve the readability of the code, not to many people know about ptrdiff_t. And to overflow int on modern computers for vector of complex values we would need to have 2 billions elements in the array which will consume 8 (for double) * 2 (for real and imaginary) * 2 (billions elements) = 32 GB of memory. Kind of unlikely.
7318afc
to
bf5b13b
Compare
Since your changing the code, can you add the |
- rename c64 to complex - make pi a constant instead of function - fix complilation warnings about comparing signed int with unsigned int
bf5b13b
to
84f7b3d
Compare
84f7b3d
to
3227558
Compare
for (auto i = 0; i < N; ++i) { | ||
for (auto j = 0; j < N; ++j) { | ||
using namespace std::literals::complex_literals; | ||
tmp[i] += X[j] * exp(-2.0 * M_PI * i * j / N * 1i); |
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 not do this, tmp[i] += X[j] * exp(complex(0, -2.0 * M_PI * i * j / 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.
ok