</h2><pre class="codeinput">    x_ = gather(x);
    df = -h + G(x);
    passive=max(x&gt;0,df&lt;0);
    df_=df.*passive;
    alpha=sum(df_.^2,1)./sum(df_.*(G(df_)),1);
    alpha(isnan(alpha))=0;
    x = x - df_.*alpha;
    x(x&lt;0) = 0;
</pre><h2 id="10">If max. iterations has not been reached, log consecutive error history (see function help)</h2><p>wait for two times opts.sample and then use the error estimator</p><pre class="codeinput">    <span class="keyword">if</span> iter&gt;opts.max_iter
        i