title: How to speed up reshape in higher rank tensor contraction by BLAS in Fortran?
body: <p>Related question <a href="https://stackoverflow.com/questions/31169856/fortran-which-method-is-faster-to-change-the-rank-of-arrays-reshape-vs-point">Fortran: Which method is faster to change the rank of arrays? (Reshape vs. Pointer)</a></p>
  <p>If I have a tensor contraction
  <code>A[a,b] * B[b,c,d] = C[a,c,d]</code>
  If I use BLAS, I think I need DGEMM (assume real values), then I can</p>
  <ol>
  <li>first reshape tensor <code>B[b,c,d]</code> as <code>D[b,e]</code> where <code>e = c*d</code>,</li>
  <li>DGEMM, <code>A[a,b] * D[b,e] = E[a,e] </code></li>
  <li>reshape <code>E[a,e]</code> into <code>C[a,c,d]</code></li>
  </ol>
  <p>The problem is, reshape is not that fast :( I saw discussions in <a href="https://stackoverflow.com/questions/31169856/fortran-which-method-is-faster-to-change-the-rank-of-arrays-reshape-vs-point">Fortran: Which method is faster to change the rank of arrays? (Reshape vs. Pointer)</a>
  , in the above link, the author met some error messages, except reshape itself.</p>
  <p>Thus, I am asking if there is a convenient solution.</p>