Is there a C # library that provides array manipulation like numpy

I am starting to use Numpy and really love its array processing capabilities. Is there any library I can use in C # that provides similar capabilities with arrays. I would like most of all:

  • Creating one array from another
  • Simple / trivial iteration of n-dimensional arrays
  • Array slicing
+7
source share
2 answers

I do not think you need a library. I think LINQ does everything you say well enough.

Creating one array from another

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 ... 

Simple iteration

 int[,] parts = new int[2,3]; foreach(var item in parts) Console.WriteLine(item); 

Array slicing

 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<int>().Skip(2).Take(2).ToArray(); 

The .Cast<int> in the last example is due to the quirk that multidimensional arrays in C # are only IEnumerable and not IEnumerable<T> .

0
source

NumPY is ported to .NET through IronPython. Look here for the main page.

+6
source

All Articles