简体   繁体   English

C# 中是否有等效的 numpy.tile() function?

[英]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.我正在尝试在 C# 中使用numpy.tile()的替代方法来复制数组n次以创建该数组的矩阵。 Maybe it can be found in the MathNet.Numerics.LinearAlgebra library, but I can't find anything.也许它可以在 MathNet.Numerics.LinearAlgebra 库中找到,但我什么也找不到。

If you have an array AB C:如果您有一个数组 AB C:

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

And you want a 10 element array that is ABCABCABCA:你想要一个 10 元素数组,它是 ABCABCABCA:

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

Or you want a 3x4 array:或者你想要一个 3x4 数组:

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..请注意,这不是瓷砖的 C# 版本,它使用 LINQ 来安排类似于瓷砖方面的东西,据我所知,你可能想要..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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