是否有ac#库提供像numpy这样的数组操作
我开始使用Numpy并且非常喜欢它的数组处理function。 是否有一些我可以在C#中使用的库,它提供与数组类似的function。 我最想要的function是:
- 从另一个创建一个数组
- n维数组的简易/三次迭代
- 切片arrays
我认为你不需要图书馆。 我认为LINQ你所提到的都很好。
从另一个创建一个数组
int[,] parts = new int[2,3]; int[] flatArray = parts.ToArray(); // Copying the array with the same dimensions can easily be put into an extension // method if you need it, nothing to grab a library for ...
轻松迭代
int[,] parts = new int[2,3]; foreach(var item in parts) Console.WriteLine(item);
切片arrays
int[] arr = new int[] { 2,3,4,5,6 }; int[] slice = arr.Skip(2).Take(2).ToArray(); // Multidimensional slice int[,] parts = new int[2,3]; int[] slice = arr.Cast().Skip(2).Take(2).ToArray();
最后一个例子中的尴尬.Cast
是由于C#中的多维数组只是IEnumerable
而不是IEnumerable
的怪癖 。
NumPY已通过IronPython移植到.NET。 在这里查看主页。