code: def gradient(self):
          
          if self.operator is None:
              return ConstantOperator(self.vector, self.domain)
          else:
              if not self.operator.is_linear:
                  # TODO: Acutally works otherwise, but needs more work
                  raise NotImplementedError('`operator` must be linear')
  
              # Figure out if operator is symmetric
              opadjoint = self.operator.adjoint
              if opadjoint == self.operator:
                  gradient = 2 * self.operator
              else:
                  gradient = self.operator + opadjoint
  
              # Return gradient
              if self.vector is None:
                  return gradient
              else:
                  return gradient + self.vector
docs: Gradient operator of the functional.