title: Halide: Filter elements out of vector (Halide::Runtime::Buffer)
body: <p>I have a <code>Halide::Runtime::Buffer</code> and would like to remove elements that match a criteria, ideally such that the operation occurs in-place and that the function can be defined in a <code>Halide::Generator</code>.</p>
  
  <p>I have looked into using reductions, but it seems to me that I cannot output a vector of a different length -- I can only set certain elements to a value of my choice.</p>
  
  <p>So far, the only way I got it to work was by using a <code>extern "C"</code> call and passing the Buffer I wanted to filter, along with a boolean Buffer (1's and 0's as ints). I read the Buffers into vectors of another library (Armadillo), conducted my desired filter, then read the filtered vector back into Halide.</p>
  
  <p>This seems quite messy and also, with this code, I'm passing a <code>Halide::Buffer</code> object, and not a <code>Halide::Runtime::Buffer</code> object, so I don't know how to implement this within a <code>Halide::Generator</code>.</p>
  
  <p>So my question is twofold:</p>
  
  <ol>
  <li>Can this kind of filtering be achieved in pure Halide, preferably in-place?</li>
  <li>Is there an example of using <code>extern "C"</code> functions within Generators?</li>
  </ol>