简体   繁体   中英

Is there a equivalent of the numpy.tile() function in C#?

I'm trying to use a alternative for numpy.tile() in C# to copy an array n times to create a matrix of this array. Maybe it can be found in the MathNet.Numerics.LinearAlgebra library, but I can't find anything.

If you have an array AB C:

var a = new []{"a","b","c"};

And you want a 10 element array that is ABCABCABCA:

var ten = Enumerable.Range(0, 10).Select(n => a[n%a.Length]).ToArray();

Or you want a 3x4 array:

var tbf = Enumerable.Range(0, 4).Select(n => (string[])a.Clone()).ToArray();

Note that this isn't a C# version of tile, it's using LINQ to arrange something similar to the aspects of tile, as far as I can understand, that you might want..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM