def __init__(self, functional, point, subgrad):
        """Initialize a new instance.

        Parameters
        ----------
        functional : `Functional`
            Functional on which to base the Bregman distance.
        point : element of ``functional.domain``
            Point from which to define the Bregman distance.
        subgrad : element of ``functional.domain``
            A subgradient of ``functional`` in ``point``. If it exists,  a
            valid option is ``functional.gradient(point)``.

        Examples
        --------
        Example of initializing the Bregman distance functional:

        >>> space = odl.uniform_discr(0, 1, 10)
        >>> l2_squared = odl.solvers.L2NormSquared(space)
        >>> point = space.one()
        >>> subgrad = l2_squared.gradient(point)
        >>> bregman_dist = odl.solvers.BregmanDistance(
        ...     l2_squared, point, subgrad)

        This is gives squared L2 distance to the given point, ||x - 1||^2:

        >>> expected_functional = l2_squared.translated(point)
        >>> bregman_dist(space.zero()) == expected_functional(space.zero())
        True
        """
        if not isinstance(functional, Functional):
            raise TypeError('`functional` {} not an instance of ``Functional``'
                            ''.format(functional))
        self.__functional = functional

        if point not in functional.domain:
            raise ValueError('`point` {} is not in `functional.domain` {}'
                             ''.format(point, functional.domain))
        self.__point = point

        if subgrad not in functional.domain:
            raise TypeError(
                '`subgrad` must be an element in `functional.domain`, got '
                '{}'.format(subgrad))
        self.__subgrad = subgrad

        self.__constant = -functional(point) + subgrad.inner(point)

        self.__bregman_dist = FunctionalQuadraticPerturb(
            functional, linear_term=-subgrad, constant=self.__constant)

        grad_lipschitz = functional.grad_lipschitz + subgrad.norm()

        super(BregmanDistance, self).__init__(
            space=functional.domain, linear=False,
            grad_lipschitz=grad_lipschitz)
def __init__ ( self , functional , point , subgrad ) : if not isinstance ( functional , Functional ) : raise TypeError ( '`functional` {} not an instance of ``Functional``' '' . format ( functional ) ) self . __functional = functional if point not in functional . domain : raise ValueError ( '`point` {} is not in `functional.domain` {}' '' . format ( point , functional . domain ) ) self . __point = point if subgrad not in functional . domain : raise TypeError ( '`subgrad` must be an element in `functional.domain`, got ' '{}' . format ( subgrad ) ) self . __subgrad = subgrad self . __constant = - functional ( point ) + subgrad . inner ( point ) self . __bregman_dist = FunctionalQuadraticPerturb ( functional , linear_term = - subgrad , constant = self . __constant ) grad_lipschitz = functional . grad_lipschitz + subgrad . norm ( ) super ( BregmanDistance , self ) . __init__ ( space = functional . domain , linear = False , grad_lipschitz = grad_lipschitz )
Initialize a new instance.

        Parameters
        ----------
        functional : `Functional`
            Functional on which to base the Bregman distance.
        point : element of ``functional.domain``
            Point from which to define the Bregman distance.
        subgrad : element of ``functional.domain``
            A subgradient of ``functional`` in ``point``. If it exists,  a
            valid option is ``functional.gradient(point)``.

        Examples
        --------
        Example of initializing the Bregman distance functional:

        >>> space = odl.uniform_discr(0, 1, 10)
        >>> l2_squared = odl.solvers.L2NormSquared(space)
        >>> point = space.one()
        >>> subgrad = l2_squared.gradient(point)
        >>> bregman_dist = odl.solvers.BregmanDistance(
        ...     l2_squared, point, subgrad)

        This is gives squared L2 distance to the given point, ||x - 1||^2:

        >>> expected_functional = l2_squared.translated(point)
        >>> bregman_dist(space.zero()) == expected_functional(space.zero())
        True