Numpy xt::where用于xtensor C++;

Numpy xt::where用于xtensor C++;,numpy,c++14,xtensor,Numpy,C++14,Xtensor,我是Xtenor的新手。我想知道如何使用xt::where的输出。例如,在python中,假设imap是nd数组, 其中(imap>=4)返回两个带索引的数组,可以使用=运算符直接赋值。请让我知道如何在xTraseC++环境中使用它。任何一个小例子都会大有帮助 谢谢。返回输入类型的xt::xarray xt::xarray<int> res = xt::where(b, a1, a2); 您所描述的实际上是np.nonzero(imap>=4),这是np.where(one_arg

我是Xtenor的新手。我想知道如何使用xt::where的输出。例如,在python中,假设imap是nd数组, 其中(imap>=4)返回两个带索引的数组,可以使用=运算符直接赋值。请让我知道如何在xTraseC++环境中使用它。任何一个小例子都会大有帮助


谢谢。

返回输入类型的xt::xarray

xt::xarray<int> res = xt::where(b, a1, a2);

您所描述的实际上是
np.nonzero(imap>=4)
,这是
np.where(one_arg)
是一个不幸的缩写。
xt::xarray<bool> b = { false, true, true, false };
xt::xarray<int> a1 = { 1,   2,  3,  4 };
xt::xarray<int> a2 = { 11, 12, 13, 14 };

xt::xarray<int> res = xt::where(b, a1, a2);
// => res = { 11, 2, 3, 14 }