PartialDerivative¶
- class odl.discr.diff_ops.PartialDerivative(*args, **kwargs)[source]¶
Bases:
PointwiseTensorFieldOperator
Calculate the discrete partial derivative along a given axis.
Calls helper function
finite_diff
to calculate finite difference. Preserves the shape of the underlying grid.- Attributes:
adjoint
Return the adjoint operator.
base_space
Base space
X
of this operator's domain and range.domain
Set of objects on which this operator can be evaluated.
inverse
Return the operator inverse.
is_functional
True
if this operator's range is aField
.is_linear
True
if this operator is linear.range
Set in which the result of an evaluation of this operator lies.
Methods
__call__
(x[, out])Return
self(x[, out, **kwargs])
.derivative
([point])Return the derivative operator.
norm
([estimate])Return the operator norm of this operator.
- __init__(domain, axis, range=None, method='forward', pad_mode='constant', pad_const=0)[source]¶
Initialize a new instance.
- Parameters:
- domain
DiscretizedSpace
Space of elements on which the operator can act.
- axisint
Axis along which the partial derivative is evaluated.
- range
DiscretizedSpace
, optional Space of elements to which the operator maps, must have the same shape as
domain
. For the defaultNone
, the range is the same asdomain
.- method{'forward', 'backward', 'central'}, optional
Finite difference method which is used in the interior of the domain of
f
.- pad_modestring, optional
The padding mode to use outside the domain.
'constant'
: Fill withpad_const
.'symmetric'
: Reflect at the boundaries, not doubling the outmost values.'periodic'
: Fill in values from the other side, keeping the order.'order0'
: Extend constantly with the outmost values (ensures continuity).'order1'
: Extend with constant slope (ensures continuity of the first derivative). This requires at least 2 values along each axis where padding is applied.'order2'
: Extend with second order accuracy (ensures continuity of the second derivative). This requires at least 3 values along theaxis
where padding is applied.- pad_constfloat, optional
For
pad_mode == 'constant'
,f
assumespad_const
for indices outside the domain off
- domain
Examples
>>> f = np.array([[ 0., 1., 2., 3., 4.], ... [ 0., 2., 4., 6., 8.]]) >>> discr = odl.uniform_discr([0, 0], [2, 1], f.shape) >>> par_deriv = PartialDerivative(discr, axis=0, pad_mode='order1') >>> par_deriv(f) uniform_discr([ 0., 0.], [ 2., 1.], (2, 5)).element( [[ 0., 1., 2., 3., 4.], [ 0., 1., 2., 3., 4.]] )