ReductionOperator
- class odl.ReductionOperator(*args, **kwargs)
Bases:
OperatorReduce argument over set of operators.
An argument is reduced by evaluating several operators and summing the result:
ReductionOperator(op1, op2)(x) = op1(x[0]) + op2(x[1])
See Also
ProductSpaceOperator : More general case, used as backend. BroadcastOperator : Calls several operators with same argument. DiagonalOperator : Case where each operator should have its own argument. SeparableSum : Corresponding construction for functionals.
- __init__(*operators)[source]
Initialize a new instance.
Parameters
Examples
>>> I = odl.IdentityOperator(odl.rn(3)) >>> op = ReductionOperator(I, 2 * I) >>> op.domain ProductSpace(rn(3), 2) >>> op.range rn(3)
Evaluating in a point gives the sum of the evaluation results of the individual operators:
>>> op([[1, 2, 3], ... [4, 6, 8]]) rn(3).element([ 9., 14., 19.])
An
outargument can be given for in-place evaluation:>>> out = op.range.element() >>> result = op([[1, 2, 3], ... [4, 6, 8]], out=out) >>> out rn(3).element([ 9., 14., 19.]) >>> result is out True
There is a simplified syntax for the case that all operators are the same:
>>> op = ReductionOperator(I, 2) >>> op.operators (IdentityOperator(rn(3)), IdentityOperator(rn(3)))