SciSharp / NumSharp

High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
https://github.com/SciSharp
Apache License 2.0
1.37k stars 192 forks source link

Complex number support? #435

Open cgranade opened 3 years ago

cgranade commented 3 years ago

When attempting to create a new NDArray of complex numbers, I get an exception in the Allocate method at https://github.com/SciSharp/NumSharp/blob/00d8700b00e815f321238536e0d6b4dbc9af8d6a/src/NumSharp.Core/Backends/Unmanaged/ArraySlice.cs#L387:

image

Are complex numbers supported as the dtype of NDArray objects, and if so, how do I allocate them? Thanks for the help, and for the awesome project!

dcuccia commented 3 years ago

+1. Just got to the end of a port, and realized Complex is not supported. Are there plans for this?

LetGo commented 2 years ago

+1. Just got to the end of a port, and realized Complex is not supported. Are there plans for this?

gsgou commented 1 year ago

Any way to workaround this one? UnmanagedStorage also doesnt support Complex.

System.NotSupportedException: Specified method is not supported.
  at NumSharp.NPTypeCodeExtensions.AsType (NumSharp.NPTypeCode typeCode) [0x00097] in D:\SciSharp\NumSharp\src\NumSharp.Core\Backends\NPTypeCode.cs:144 
  at NumSharp.Backends.UnmanagedStorage..ctor (NumSharp.NPTypeCode typeCode) [0x00014] in D:\SciSharp\NumSharp\src\NumSharp.Core\Backends\Unmanaged\UnmanagedStorage.cs:181 
  at NumSharp.Backends.DefaultEngine.GetStorage (NumSharp.NPTypeCode typeCode) [0x00000] in D:\SciSharp\NumSharp\src\NumSharp.Core\Backends\Default\Allocation\Default.Allocation.cs:14 
  at NumSharp.NDArray..ctor (NumSharp.NPTypeCode typeCode, NumSharp.TensorEngine engine) [0x0000d] in D:\SciSharp\NumSharp\src\NumSharp.Core\Backends\NDArray.cs:102 
  at NumSharp.NDArray..ctor (NumSharp.NPTypeCode typeCode) [0x00000] in D:\SciSharp\NumSharp\src\NumSharp.Core\Backends\NDArray.cs:119 
  at NumSharp.NDArray..ctor (NumSharp.NPTypeCode dtype, NumSharp.Shape shape, System.Boolean fillZeros) [0x00000] in D:\SciSharp\NumSharp\src\NumSharp.Core\Backends\NDArray.cs:234 
  at NumSharp.np.zeros (NumSharp.Shape shape, NumSharp.NPTypeCode typeCode) [0x0000e] in D:\SciSharp\NumSharp\src\NumSharp.Core\Creation\np.zeros.cs:54