Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Feature request: native complex number datatype #3322

Closed
ZedThree opened this issue Aug 2, 2023 · 0 comments
Closed

Feature request: native complex number datatype #3322

ZedThree opened this issue Aug 2, 2023 · 0 comments

Comments

@ZedThree
Copy link

ZedThree commented Aug 2, 2023

Is your feature request related to a problem? Please describe.

Complex numbers are widely used in the physical sciences, and in some domains are very commonplace. C, C++, Fortran, Python, and Julia all have native complex numbers, all with the same representation in memory, that of an array of two numbers in the rectangular/Cartesian form. Currently, because there is no built-in datatype for HDF5 then library and application authors must create their own. A nice summary of the approaches different authors have taken is in this discussion on the CF-Conventions. Note that there are broadly speaking three approaches, but the one labelled 2a appears to be the most common.

Complex numbers have been discussed here previously, though still without real consensus:

Describe the solution you'd like

The minimal implementation that is most useful to the most number of people would be a set of complex types for float and double base types equivalent to the compound type:

DATATYPE "H5T_COMPLEX_<base float>" H5T_COMPOUND {
   H5T_<base float> "r";
   H5T_<base float> "i";
}

This would coincide with the choices made by h5py and HDF5.jl, for example.

The <base float> above would either be NATIVE_FLOAT/NATIVE_DOUBLE and/or the IEEE_F* types.

Describe alternatives you've considered

The existing solution is for each library and application to invent their own datatype. This has led to incompatible definitions for the type, reducing interoperability between tools and datasets. It also adds friction for developers and users in having to create the type or re-structure their data in comparison to other native types.

Additional context

Some commentators have called for this type to be flexible enough to work for higher order complex numbers such as quarternions. I'm not proposing that here as these types are generally not built-in types in the programming languages, at least not those used in the physical sciences. I believe that there may also be much more variety in the representations of quarternions so that it perhaps makes less sense to bless one particular form.

@HDFGroup HDFGroup locked and limited conversation to collaborators Aug 3, 2023
@derobins derobins converted this issue into discussion #3339 Aug 3, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant