Skip to content

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

Merged
merged 3 commits into from
Aug 27, 2018

Conversation

mika314
Copy link
Contributor

@mika314 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

@Gathros Gathros added the Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.) label Jul 19, 2018
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) {
Copy link
Contributor

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

Copy link
Contributor Author

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.

@mika314 mika314 force-pushed the cooley_tukey_cpp branch from 7318afc to bf5b13b Compare July 20, 2018 05:22
@Gathros
Copy link
Contributor

Gathros commented Aug 4, 2018

Since your changing the code, can you add the dft function. Look at the C code to understand how it works.

- rename c64 to complex
- make pi a constant instead of function
- fix complilation warnings about comparing signed int with unsigned int
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);
Copy link
Contributor

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));.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@Gathros Gathros dismissed zsparal’s stale review August 27, 2018 09:49

The review is out of date.

@Gathros Gathros merged commit 41bb45a into algorithm-archivists:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants