PointwiseNorm¶
-
class
odl.operator.tensor_ops.
PointwiseNorm
(*args, **kwargs)[source]¶ Bases:
odl.operator.tensor_ops.PointwiseTensorFieldOperator
Take the point-wise norm of a vector field.
This operator computes the (weighted) p-norm in each point of a vector field, thus producing a scalar-valued function. It implements the formulas
||F(x)|| = [ sum_j( w_j * |F_j(x)|^p ) ]^(1/p)
for
p
finite and||F(x)|| = max_j( w_j * |F_j(x)| )
for
p = inf
, whereF
is a vector field. This implies that theOperator.domain
is a power space of a discretized function space. For example, ifX
is aDiscretizedSpace
space, thenProductSpace(X, d)
is a valid domain for any positive integerd
.- Attributes
adjoint
Adjoint of this operator (abstract).
base_space
Base space
X
of this operator’s domain and range.domain
Set of objects on which this operator can be evaluated.
exponent
Exponent
p
of this norm.inverse
Return the operator inverse.
is_functional
True
if this operator’s range is aField
.is_linear
True
if this operator is linear.is_weighted
True
if weighting is not 1 or all ones.range
Set in which the result of an evaluation of this operator lies.
weights
Weighting array of this operator.
Methods
_call
(self, f, out)Implement
self(f, out)
.derivative
(self, vf)Derivative of the point-wise norm operator at
vf
.norm
(self[, estimate])Return the operator norm of this operator.
-
__init__
(self, vfspace, exponent=None, 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.
- exponentnon-zero float, optional
Exponent of the norm in each point. Values between 0 and 1 are currently not supported due to numerical instability. Default:
vfspace.exponent
- weighting
array-like
or positive float, optional Weighting array or constant for the norm. If an array is given, its length must be equal to
len(domain)
, and all entries must be positive. By default, the weights are is taken fromdomain.weighting
. Note that this excludes unusual weightings with custom inner product, norm or dist.
- vfspace
Examples
We make a tiny vector field space in 2D and create the standard point-wise norm 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_norm = odl.PointwiseNorm(vfspace) >>> pw_norm.range == spc True
Now we can calculate the 2-norm in each point:
>>> x = vfspace.element([[[1, -4]], ... [[0, 3]]]) >>> print(pw_norm(x)) [[ 1., 5.]]
We can change the exponent either in the vector field space or in the operator directly:
>>> vfspace = odl.ProductSpace(spc, 2, exponent=1) >>> pw_norm = PointwiseNorm(vfspace) >>> print(pw_norm(x)) [[ 1., 7.]] >>> vfspace = odl.ProductSpace(spc, 2) >>> pw_norm = PointwiseNorm(vfspace, exponent=1) >>> print(pw_norm(x)) [[ 1., 7.]]