Skip to content
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

std::complex< T > as attributes #1908

Closed
ax3l opened this issue Dec 19, 2019 · 2 comments
Closed

std::complex< T > as attributes #1908

ax3l opened this issue Dec 19, 2019 · 2 comments

Comments

@ax3l
Copy link
Contributor

ax3l commented Dec 19, 2019

Hi,

is there a specific reason why we do not allow std::complex< T > types as attributes in ADIOS2?
Those are primitive types and according to my tests in openPMD-api, using complex types as attributes was possible in ADIOS1.

Can we potentially just update the macros that specialize the overloads to allow complex types for attributes as well?

@ax3l
Copy link
Contributor Author

ax3l commented Dec 19, 2019

The specialization you need for nlohmann::json reads:

#include <complex>

namespace std
{
    // std::complex handling
    template< class T > void to_json(nlohmann::json &j, const std::complex< T > &p) {
        j = nlohmann::json {p.real(), p.imag()};
    }

    template< class T > void from_json(const nlohmann::json &j, std::complex< T > &p) {
        p.real(j.at(0));
        p.imag(j.at(1));
    }
}

@ax3l
Copy link
Contributor Author

ax3l commented Jan 8, 2020

Implemented via #1909 and #1922

@ax3l ax3l closed this as completed Jan 8, 2020
ax3l added a commit to openPMD/openPMD-api that referenced this issue Sep 3, 2020
Add support for complex numbers as fundamental data type.

Close #203 

- [x] Tests
- [x] internals: new types, comparisons, allowed casts, record components, patches and attributes, etc.
- [x] JSON (writes to pairs, read re-identification as complex is todo)
- [x] HDF5
- [x] ADIOS1 (no long double complex; no attributes of arrays of complex: ornladios/ADIOS#212)
- [x] ADIOS2: (complex attributes: ornladios/ADIOS2#1908);  (no long double complex ornladios/ADIOS2#1907)
- [x] Python bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant