title: What is the correct way to extract a vector from a matrix in Eigen?
body: <p>I'm a beginner in Eigen, and what I'm doing is to extract different rows from a matrix and do some calculation.</p>
  
  <p>The code looks like this</p>
  
  <pre><code>MatrixXd mat(5, 10);
  VectorXd vec1 = mat.row(1);
  VectorXd vec2 = mat.row(2);
  // do some calculation with vec1 and vec2
  </code></pre>
  
  <p>So the question is, by doing like <code>VectorXd vec = mat.row(1)</code>, there's memory allocation / memory copying which may be bad for performance. As I'm only using it for calculation and definitely won't do any changes to the matrix underneath, Is there a better way to do this?</p>
  
  <p>I tried using <code>Eigen::Block</code> but it appeared that <code>Block</code> doesn't support some matrix operations (I'm not sure).</p>