You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to create an NDArray from pointer and NPTypeCode? #390
My code calls into lower level C++ code and I wish to represent the returned array as an NDArray in C#. I have a pointer to the data, the length of the data in bytes, as well as type code. How would I go about creating an NDArray for this case? Something like:
NDArray CreateNDArray(void* data,int dataLengthBytes,NPTypeCode typeCode)
{
var storage = new UnmanagedStorage( "something here" );
var nda = new NDArray(storage);
return nda;
}
changed the title [-]How to create and NDArray from pointer and NPTypeCode[/-][+]How to create an NDArray from pointer and NPTypeCode?[/+]on Jan 24, 2020
Activity
[-]How to create and NDArray from pointer and NPTypeCode[/-][+]How to create an NDArray from pointer and NPTypeCode?[/+]Oceania2018 commentedon Jan 24, 2020
@LarryThermo This snippet of code will help you.
LarryThermo commentedon Jan 27, 2020
Nucs commentedon Sep 7, 2026
Use
np.frombuffer(0.70.0, #628) to wrap a byte buffer as an NDArray of a given dtype:For a raw
T*pointer, wrap it in anUnmanagedMemoryBlock<T>and build the NDArray from that storage. Closing.