Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想以与返回表达式相同的方式获得重复数组numpy。xt::repeat当我尝试将此表达式转换为数组时,出现编译错误。
numpy
xt::repeat
xt::array<int> a = {{1, 2}, {3, 4}}; auto r = xt::repeat(a, 3, 1); // r is expression xt::array<int> b = r; // compile error here
如何重复数组并将结果作为另一个数组而不是表达式?也许我错过了文档中的某些内容,但找不到工作示例。
这是xtensor. 我正在开发补丁,现在您可以使用以下解决方法:
xtensor
xt::xarray<int> b(r.shape()); std::copy(r.cbegin(), r.cend(), b.begin());