Closed andyyankai closed 4 years ago
This is the gather operation. But, it probably isn't as fast as you might want it to be.
Indeed, you will need a gather
operator to do this (see this)
In your code this should translate to:
FloatD some = {2.3f, 3.4f, 4.5f, 5.6f, 6.7f, 7.8f};
IntC index = {1,1,3,3,5};
FloatD check = gather<FloatD>(some, index); // or something very similar to this
When I tried:
FloatC some = {2.3f, 3.4f, 4.5f, 5.6f, 6.7f, 7.8f}; IntC index = {1,1,3,3,5}; FloatC check = gather<FloatC>(some, index);
its working, but when I change FloatC into FloatD I have an error:
Could you try with IntD
instead of IntC
when working with FloatD
?
Yes, seems working now.
for example A = [1, 2, 3, 4, 5] I = [0, 1, 1, 2] then A[I] = [A[0], A[1], A[1], A[2]] = [1, 2, 2, 3]
or