So an example really helped me out here. If you have your input be [1.2, 0.2, 4.1, 3.5], and your indices be [1,3,0,2], then I believe gather would result with an output of [0.2, 3.5, 1.2, 4.1], and scatter would result with [4.1, 1.2, 3.5, 0.2].
So in my mind gather takes the set of indices and says, okay at index i I want the input element from indices[i], whereas scatter would say take the input from index i and put it in the output at index indices[i]. (now that I write this, I realize it's probably not much better than the code... but the example might help!)
This comment was marked helpful 3 times.
kayvonf
Question: Another way to understand gather and scatter is for someone to want to write sequential C-code for:
So an example really helped me out here. If you have your input be [1.2, 0.2, 4.1, 3.5], and your indices be [1,3,0,2], then I believe gather would result with an output of [0.2, 3.5, 1.2, 4.1], and scatter would result with [4.1, 1.2, 3.5, 0.2].
So in my mind gather takes the set of indices and says, okay at index
i
I want the input element fromindices[i]
, whereas scatter would say take the input from indexi
and put it in the output at indexindices[i]
. (now that I write this, I realize it's probably not much better than the code... but the example might help!)This comment was marked helpful 3 times.
Question: Another way to understand gather and scatter is for someone to want to write sequential C-code for:
This comment was marked helpful 0 times.
I'll give it a go! Assuming they all have equal length N
This comment was marked helpful 1 times.
Each of these programs seems to use only one of either gather or scatter. Is there an example that would use both operations?
This comment was marked helpful 0 times.