IndicatorSumConstraint

class odl.functionals.default_functionals.IndicatorSumConstraint(*args, **kwargs)[source]

Bases: Functional

Indicator functional of a unit sum constraint.

Notes

The functional F is given by:

F(x)
=
\begin{cases}
    0 & \text{if } \sum_i x_i = 1
 \\ +\infty & \text{else.}
\end{cases}

__init__(space, sum_value=1, sum_rtol=None)[source]

Initialize a new instance.

Parameters

spaceDiscretizedSpace or TensorSpace

Domain of the functional.

sum_valuefloat

Desired value of the sum constraint.

sum_rtolfloat, optional

Relative tolerance for sum comparison. If set to None, the default is space.size times 1e-10 when space.dtype is float64 and 1e-6 otherwise.

Examples

Example where a point does not have unit sum …

>>> space = odl.rn(3)
>>> ind_sum = IndicatorSumConstraint(space)
>>> x = space.one()
>>> ind_sum(x)
inf

… and one where it does.

>>> x /= odl.sum(x)
>>> ind_sum(x)
0