<span class="p">):</span>
        
            <span class="c1"># Calculate residual</span>
            <span class="n">resid</span> <span class="o">=</span> <span class="n">memoized_Ax</span> <span class="o">-</span> <span class="n">b_k_val</span>

            <span class="c1"># Calculate columnwise difference with resid.</span>
            <span class="c1"># resid[:None] promotes shape from (d) to (d,)</span>
            <span class="n">gain_norms</span> <span class="o">=</span> <span class="p">(</span><s