title: Fixed size Eigen matrix as parameters in template function
body: <p>I am trying to write a function that takes fixed size matrix using template on the matrix size. I have read <a href="http://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html" rel="nofollow">http://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html</a> but I am not able to make it works perfectly. I could not use fixed size matrix block operations on the fixed size matrix inside my function. (TutorialBlockOperations.html">http://eigen.tuxfamily.org/dox/group_TutorialBlockOperations.html)</p>
  
  <p>I tried to do it in two ways but both of them did not work.</p>
  
  <p>Here is the function definition A:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template &lt;int N&gt;
  Matrix&lt;double, 3, N&gt; foo(const Matrix&lt;double, 3, N&gt;&amp; v)
  {
    Matrix&lt;double, 3, N&gt; ret;
  
    Vector3d a = v.leftCols&lt;1&gt;();  // error: expected primary-expression before ')' token
  
    return ret;
  }
  </code></pre>
  
  <p>Here is the function definition B:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template&lt;typename Derived&gt;
  Eigen::MatrixBase&lt;Derived&gt; bar(const Eigen::MatrixBase&lt;Derived&gt;&amp; v)
  {
    EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
    EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 3,
                    THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
  
    Eigen::Matrix&lt;double,
        Derived::RowsAtCompileTime,
        Derived::ColsAtCompileTime&gt; ret;
  
    Vector3d a = v.leftCols&lt;1&gt;();  // error: expected primary-expression before ')' token
  
    return ret;
  }
  </code></pre>
  
  <p>Any ideas?</p>