SciSharp / NumSharp

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

How to convert NDArray to list #401

Open Sullivanecidi opened 4 years ago

Sullivanecidi commented 4 years ago

It is really a big surprise for me to find the Numsharp. Here is little question with using the NumSharp: How to convert the NDArray data to list ? since in VB.net, list is the frequently used. For example: dim x_data, y_data as NDArray dim y() as double x_data = np.linspace(0,100,500) y_data = x_data * 2 + np.random.randn(500)

how to convert y_data to y() ?

Thanks!

Oceania2018 commented 4 years ago

x_data.ToArray<double>()

Sullivanecidi commented 4 years ago

x_data.ToArray<double>()

Do you mean y = y_data.ToArray(of double)() it doesn't work at all......

Jiuyong commented 4 years ago

VB.Net don't support Of unmanaged 目前看到的情况是,VB.Net 不支持 C# 7.3 新的 unmanaged 泛型约束。 如果想要使用,可能需要变通一下了。

pepure commented 4 years ago

x_data.ToArray<double>()

Do you mean y = y_data.ToArray(of double)() it doesn't work at all......

I offer a lower level solution:)

Dim x_data, y_data As NDArray x_data = np.linspace(0, 100, 500) y_data = x_data * 2 + np.random.randn(500)

Dim y(y_data.size - 1) As Double For i = 0 To y_data.size - 1 y(i) = y_data(i) Next i

Debugging results: image Please confirm if it can solve your problem。

Sullivanecidi commented 4 years ago

VB.Net don't support Of unmanaged 目前看到的情况是,VB.Net 不支持 C# 7.3 新的 unmanaged 泛型约束。 如果想要使用,可能需要变通一下了。

那就可能是按照楼上这位了,一个一个取出来。谢谢你了~

Sullivanecidi commented 4 years ago

Thanks very much! this is the alternative way, since VB.net don't support the unmanaged constraint.

Sullivanecidi commented 4 years ago

VB.Net don't support Of unmanaged 目前看到的情况是,VB.Net 不支持 C# 7.3 新的 unmanaged 泛型约束。 如果想要使用,可能需要变通一下了。

我刚试了下c#,是可以用toArray()实现的。

Jiuyong commented 4 years ago

是的,C#肯定没问题啊。 还有个稍微好一点的解决方案。 就是用C#弄一个缝合项目,然后VB项目引用。