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

Support System.Numerics.Complex #237

Open
brechtvb opened this issue Oct 24, 2022 · 3 comments
Open

Support System.Numerics.Complex #237

brechtvb opened this issue Oct 24, 2022 · 3 comments

Comments

@brechtvb
Copy link

Is it possible to support System.Numerics.Complex

Today that has to be done through a [float float] compound, correct?

@LiorBanai
Copy link
Owner

@brechtvb , Yeah I don't think H5 data type has native complex type. It will have to be split into 2 fields.

@LiorBanai
Copy link
Owner

@brechtvb
Copy link
Author

Indeed, there is no other way.

An ugly hack could be provided through issue #236:

unsafe public void Write(Guid guid, ReadOnlySpan<double> valuePath, ReadOnlySpan<Complex> cdata, string groupName)
    {
        var groupId = h5.Hdf5.CreateGroupRecursively(hfile, loc(guid, valuePath));

        fixed (Complex* cptr = cdata)
        {
            double* dptr = (double*)cptr;

            var ddata = new ReadOnlySpan<double>(dptr, cdata.Length * 2);
            
            var ds = h5.Hdf5.WriteDatasetFromArray<double>(groupId, groupName, ddata.ToArray());
        }
        
    }

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

2 participants