Esempio n. 1
0
def test_combine_proximal():
    """Function to combine proximal factory functions.

    The combine function makes use of the separable sum property of proximal
    operators.
    """

    # Image space
    space = odl.uniform_discr(0, 1, 10)

    # Factory function returning the proximal operator
    prox_factory = proximal_const_func(space)

    # Combine factory function of proximal operators
    combined_prox_factory = combine_proximals(prox_factory, prox_factory)

    # Initialize combine proximal operator
    prox = combined_prox_factory(1)

    assert isinstance(prox, odl.Operator)

    # Explicit construction of the combine proximal operator
    prox_verify = odl.ProductSpaceOperator(
        [[odl.IdentityOperator(space), None],
         [None, odl.IdentityOperator(space)]])

    # Create an element in the domain of the operator
    x = prox_verify.domain.element([np.arange(-5, 5), np.arange(-5, 5)])

    # Allocate output element
    out = prox_verify.range.element()

    # Apply explicitly constructed and factory-function-combined proximal
    # operators
    assert prox(x) == prox_verify(x)

    # Test output argument
    assert prox(x, out) == prox_verify(x)

    # Identity mapping
    assert out == x
Esempio n. 2
0
def test_proximal_const_func():
    """Proximal factory for the constnat mapping G(x) = c."""

    # Image space
    space = odl.uniform_discr(0, 1, 10)

    # Element in the image space where the proximal operator is evaluated
    x = space.element(np.arange(-5, 5))

    # Factory function returning the proximal operator
    prox_factory = proximal_const_func(space)

    # Initialize proximal operator of G (with an unused parameter)
    prox = prox_factory(None)

    # prox_tau[G](x) = x = identity operator
    assert isinstance(prox, odl.IdentityOperator)

    # Optimal point of the auxiliary minimization problem prox_tau[G]
    x_opt = prox(x)

    # Identity map
    assert x == x_opt