Skip to content

Stream Compaction #124

Answered by 9prady9
ethanabrooks asked this question in Q&A
Discussion options

You must be logged in to vote

I believe stream compaction is equivalent to the following 3 steps in that order.

  1. Generate boolean map indicating which elements are important if one doesn't exist already.
  2. Perform scan operation on the boolean map.
  3. Index the original input array using the scanned boolean map avoiding zero values.

Given below is the C++ equivalent of above steps.

array a = randu(10);    // input data
array b = a > 0.4;        // boolean map of relevant values
array c = scan(b);       // scan the boolean map
array i = c(where(b));  // gather scanned map values where the map wasn't zero originally
array dense = a(i);      // index original input array with gathered map values

The rust version would follow…

Replies: 18 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by 9prady9
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #124 on December 09, 2020 05:11.