title: Big matrix with compile-time known size in Eigen: MatrixXd or Matrix<double, n, m>?
body: <p>I'm using Eigen to write some C++ linear algebra code. I've got to manipulate some not-so-small matrices (greater than 4x4, but smaller than 50x50, if that matters), whose sizes are all entirely known at compile time.</p>
  
  <p>I would love to benefit from the compile-time size checks that Eigen library can perform around matrix operations, which trigger an error whenever, say, a sum between different-size matrices happens in the code, however I'm also scared about the possible abuse of the stack that I could make if I don't dinamically allocate those relatively big objects. Performance concerns doesn't bother me.</p>
  
  <p>The <a href="https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html" rel="nofollow noreferrer">Eigen documentation</a> has a brief paragraph about fixed and dynamic size matrices, where my previous concerns are discussed, but unfortunately there is no emphasys on the compile time checks which I would love to maintain. The documentation suggests:</p>
  
  <blockquote>
    <p>Use fixed sizes for very small sizes where you can, and use dynamic sizes for larger sizes or where you have to.</p>
  </blockquote>
  
  <p>In the end, my question: is there a way in Eigen to have a dynamically allocated Matrix with compile-time known size, in a way to retain the usual compile-time checks that we have for standard fixed-size matrices?</p>
  
  <p>Something like this:</p>
  
  <pre><code>using MyMatrix = MatrixXd&lt;12, 15&gt;; // Currently I can only do Matrix&lt;double, 12, 15&gt;
  using MyVector = MatrixXd&lt;14, 1&gt;;
  MyMatrix M;
  MyVector v;
  auto w = M * v; // This should trigger an INVALID_MATRIX_PRODUCT error
  </code></pre>
  
  <p>where <code>MatrixXd&lt;n, m&gt;</code> is the hypothetical dynamically allocated, compile-time known size matrix I would like to use!</p>