has wrong dimensions.'</span>)
    <span class="keyword">return</span>
<span class="keyword">end</span>
X = x;
<span class="keyword">if</span> ~isempty(opts.gpu_id)
    gpuDevice(opts.gpu_id);
    x = gpuArray(x);
    h = gpuArray(h);
    G= gpuArray(G);
<span class="keyword">end</span>
rds=1:size(Y,2);
</pre><h2 id="6">Compute the second term (the Gramian matrix) that does not change throughout the function</h2><pre class="codeinput"><span class="keyword">if</span> opts.use_std
    G = @(x) G*x - (G*sum(x,