def update(self, gradient, step):
do_sd = self.gradient_old is None<EOL>self.gradient_old = self.gradient<EOL>self.gradient = gradient<EOL>if do_sd:<EOL><INDENT>self._update_sd()<EOL><DEDENT>else:<EOL><INDENT>self._update_cg()<EOL><DEDENT>
Update the search direction given the latest gradient and step