Title says it - what is the xtensor equivalent of numpy's
# set all elements > 3 to 1
sometensor[sometensor > 3] = 1
?
It looks like xt::filter
works:
xt::filter(sometensor, sometensor > 3) = 1
But it also looks like the numpy version is much faster. I've build xtensor with xsimd, but it doesn't seem to help in this case. Is there a better, more simd-ish way to do it?
EDIT
I found filtration
, which indeed is faster (by about 3x), but still slower than numpy (by about 10x)...
SOLUTION (thx Tom!)
a = xt::where(a > 0.5, 1.0, a);
Is the fastest of all - about 10x faster than filtration
, so it looks like it's simd-d!