code: def is_restart(self, z_old, x_new, x_old):
          r
          if self.restart_strategy is None:
              return False
  
          criterion = np.vdot(z_old - x_new, x_new - x_old) >= 0
  
          if criterion:
              if 'adaptive' in self.restart_strategy:
                  self.r_lazy *= self.xi_restart
              if self.restart_strategy in ['adaptive-ii', 'adaptive-2']:
                  self._t_now = 1
  
          if self.restart_strategy == 'greedy':
              cur_delta = np.linalg.norm(x_new - x_old)
              if self._delta_0 is None:
                  self._delta_0 = self.s_greedy * cur_delta
              else:
                  self._safeguard = cur_delta >= self._delta_0
  
          return criterion
docs: r""" Check whether the algorithm needs to restart
  
          This method implements the checks necessary to tell whether the
          algorithm needs to restart depending on the restarting strategy.
          It also updates the FISTA parameters according to the restarting
          strategy (namely beta and r).
  
          Parameters
          ----------
          z_old: ndarray
              Corresponds to y_n in [L2018].
          x_new: ndarray
              Corresponds to x_{n+1} in [L2018].
          x_old: ndarray
              Corresponds to x_n in [L2018].
  
          Returns
          -------
          bool: whether the algorithm should restart
  
          Notes
          -----
          Implements restarting and safeguarding steps in alg 4-5 o [L2018]