title: Is there a way to store thresholding operation output in Eigen (C++)?
body: <p>In MATLAB, you can create a binary matrix B by thresholding a matrix A as follows:</p>
  
  <pre><code>B = A &gt; threshold
  </code></pre>
  
  <p>Where <code>threshold</code> is some value. In Eigen for C++, I have been able see similar results, but have faced an inability to assign the output. That is, given</p>
  
  <pre><code>MatrixXd M =
  0 1 2
  0 1 2
  0 1 2
  </code></pre>
  
  <p>(I know that's not proper initialization but for the sake of the question, go with it)</p>
  
  <pre><code>cout &lt;&lt; (M &lt; 1)
  </code></pre>
  
  <p>produces</p>
  
  <pre><code>1 0 0
  1 0 0
  1 0 0
  </code></pre>
  
  <p>but </p>
  
  <pre><code>MatrixXd N = M &lt; 1;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>M = M &lt; 1;
  </code></pre>
  
  <p>both give build errors.</p>
  
  <p>Can someone please explain the correct way to save the binary output of this threshold to a variable?</p>