title: Eigen: mask an array
body: <p>Is it possible to mask an array in Eigen as in Matlab? </p>
  
  <p>Something like </p>
  
  <pre><code>ArrayXd arrayA = ArrayXd::Random(10, 5);
  ArrayXi mask = ArrayXi::Zero(arrayA.rows(), arrayA.cols());
  mask = arrayA &gt; 5;
  ArrayXd arrayB = arrayA(mask)
  </code></pre>
  
  <p>where arrayB is a row vector containing all and only the elements of arrayA>5 </p>
  
  <p>I could find similar requests but not any updated answer after 2011 ( <a href="https://forum.kde.org/viewtopic.php?f=74&amp;t=98382" rel="noreferrer">https://forum.kde.org/viewtopic.php?f=74&amp;t=98382</a> , <a href="https://forum.kde.org/viewtopic.php?f=74&amp;t=98093" rel="noreferrer">https://forum.kde.org/viewtopic.php?f=74&amp;t=98093</a> , <a href="https://forum.kde.org/viewtopic.php?f=74&amp;t=97652" rel="noreferrer">https://forum.kde.org/viewtopic.php?f=74&amp;t=97652</a>)</p>