</span><span class="op">)</span>, dim <span class="op">=</span> <span class="va">p</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co">#Calculate HOSVD.</span></span></span>
<span class="r-in"><span><span class="va">hosvd_x</span> <span class="op">&lt;-</span> <span class="fu">hosvd</span><span class="op">(</span><span class="va">X</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">S</span> <span