def update(self, counter, f, x_orig, gradient_orig):
do_update = Preconditioner.update(self, counter, f, x_orig, gradient_orig)<EOL>if do_update:<EOL><INDENT>N = len(x_orig)<EOL>if self.scales is None:<EOL><INDENT>self.scales = np.ones(N, float)<EOL><DEDENT>for i in range(N):<EOL><INDENT>epsilon = self.epsilon/self.scales[i]<EOL>xh = x_orig.copy()<EOL>xh[i] += <NUM_LIT:0.5>*epsilon<EOL>fh = self.fun(xh)<EOL>xl = x_orig.copy()<EOL>xl[i] -= <NUM_LIT:0.5>*epsilon<EOL>fl = self.fun(xl)<EOL>curv = (fh+fl-<NUM_LIT:2>*f)/epsilon**<NUM_LIT:2><EOL>self.scales[i] = np.sqrt(abs(curv))<EOL><DEDENT>if self.scales.max() <= <NUM_LIT:0>:<EOL><INDENT>self.scales = np.ones(N, float)<EOL><DEDENT>else:<EOL><INDENT>self.scales /= self.scales.max()<EOL>self.scales[self.scales<self.scale_limit] = self.scale_limit<EOL><DEDENT><DEDENT>return do_update<EOL>
Perform an update of the linear transformation

           Arguments:
            | ``counter``  --  the iteration counter of the minimizer
            | ``f``  --  the function value at ``x_orig``
            | ``x_orig``  --  the unknowns in original coordinates
            | ``gradient_orig``  --  the gradient in original coordinates

           Return value:
            | ``done_update``  --  True when an update has been done

           The minimizer must reset the search direction method when an updated
           has been done.