PointwiseSum
- class odl.PointwiseSum(*args, **kwargs)
Bases:
PointwiseInnerTake the point-wise sum of a vector field.
This operator takes the (weighted) sum
sum(F(x)) = [ sum_j( w_j * F_j(x) ) ]
where
Fis a vector field. This implies that theOperator.domainis a power space of a discretized function space. For example, ifXis aDiscretizedSpacespace, thenProductSpace(X, d)is a valid domain for any positive integerd.- __init__(vfspace, weighting=None)[source]
Initialize a new instance.
Parameters
- vfspace
ProductSpace Space of vector fields on which the operator acts. It has to be a product space of identical spaces, i.e. a power space.
- weighting
array-likeor float, optional Weighting array or constant for the sum. If an array is given, its length must be equal to
len(domain). By default, the weights are is taken fromdomain.weighting. Note that this excludes unusual weightings with custom inner product, norm or dist.
Examples
We make a tiny vector field space in 2D and create the standard point-wise sum operator on that space. The operator maps a vector field to a scalar function:
>>> spc = odl.uniform_discr([-1, -1], [1, 1], (1, 2)) >>> vfspace = odl.ProductSpace(spc, 2) >>> pw_sum = PointwiseSum(vfspace) >>> pw_sum.range == spc True
Now we can calculate the sum in each point:
>>> x = vfspace.element([[[1, -4]], ... [[0, 3]]]) >>> print(pw_sum(x)) [[ 1., -1.]]
- vfspace