title: Wrap Eigen's tensor class to create dynamic rank tensors?
body: <p>Eigen's tensor module supports static rank tensors through the use of template arguments, with something like <code>Eigen::Tensor&lt;typename T,int dims&gt;</code>. I'm only going to be using <code>Eigen::Tensor&lt;double, n&gt;</code>, where n isn't necessarily known at compile time. Is there anyway to make a class like:</p>
  
  <pre><code>class TensorWrapper{
      Eigen::Tensor&lt;double,??????&gt; t; //not sure what could go here
      TensorWrapper(int dimensions){
          t = Eigen::Tensor&lt;double,dimensions&gt;(); //wouldn't work either way
      }
  };
  </code></pre>
  
  <p>I know that <code>Eigen::Tensor&lt;double,2&gt;</code> and <code>Eigen::Tensor&lt;double,3&gt;</code> have absolutely nothing to do with each other because they are templated, and that I can't have template arguments determined at run-time, so the above would fail in every possible way. I also know that tensors in Tensorflow support this, but they don't have tensor contraction in c++ (which is why I need tensors in the first place). Is there any way to do what I wanted to above, even for a limited number of dimensions (I won't need more than 5 or 6)? If not, are there any tensor libraries for c++ that support dynamic rank and tensor contraction?</p>