Skip to content

[Refactor] Improve type safety with std::complex #6346

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 1 commit into from
Jul 2, 2025

Conversation

kluophysics
Copy link

Motivation

Recent trial of including f2c.h leads to conflicts with the complex type defined there typedef struct { real r, i; } complex;.

What's changed?

  • All complex<double> and complex<float> occurrances including tests have been replaced by std::complex<double> and std::complex<float>
  • Arguments with complex<T> without a space separation has been modified to have it. Example: double,complex<double> is changed to double, std::complex<double>.

Discussions

I had thought about using trick like

template <typename T>
using complex=std::complex<T>;

to do it, but it still has the same problem. So I stick to this more cumbersome.

@mohanchen mohanchen added Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 labels Jul 2, 2025
@mohanchen mohanchen merged commit ca96d8e into deepmodeling:develop Jul 2, 2025
14 checks passed
@mohanchen
Copy link
Collaborator

Excellent work! Thank you so much for these contributions !! @kluophysics

@kluophysics kluophysics deleted the complex_refactor branch July 4, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants