How do I do outer product of tensors in Eigen?
<p>In eigen, one can do quite easily tensor contractions using:</p>

<pre><code>Tensor&lt;double, 1&gt; tensor1;
Tensor&lt;double, 2&gt; tensor2;

// fill with data so that
// tensor1 is of dimensions [10] and tensor2 of dimensions [5,10]

std::array&lt;Eigen::IndexPair&lt;int&gt;, 1&gt; product_dims1 = { IndexPair&lt;int&gt;(1, 0) };

auto tensor = tensor2.contract(tensor1, product_dims1);

// now tensor is of dimensions [5]
</code></pre>

<p>I am looking for a method that does the opposite of contraction, meaning it takes two tensors A and B, say of dimensions 5 x 10 and 3 x 2 and defines a new tensor C of dimensions 5 x 10 x 3 x 2 such that</p>

<pre><code>  C_ijkl = A_ij * B_kl
</code></pre>

<p>I could easily write such a method if necessary, but I get the sense it would be more optimized if I used a native eigen method. I also want to be able to use GPU support which is quite easy with eigen if you use the native methods.</p>

<p>Thanks.</p>