TensorSpace._dist

TensorSpace._dist(x1, x2)[source]

Return the distance between x1 and x2.

This function is part of the subclassing API. Do not call it directly.

Parameters

x1, x2NumpyTensor

Elements whose mutual distance is calculated.

Returns

distfloat

Distance between the elements.

Examples

Different exponents result in difference metrics:

>>> space_2 = odl.rn(3, exponent=2)
>>> x = space_2.element([-1, -1, 2])
>>> y = space_2.one()
>>> space_2.dist(x, y)
3.0
>>> space_1 = odl.rn(3, exponent=1)
>>> x = space_1.element([-1, -1, 2])
>>> y = space_1.one()
>>> space_1.dist(x, y)
5.0

Weighting is supported, too:

>>> space_1_w = odl.rn(3, exponent=1, weighting=[2, 1, 1])
>>> x = space_1_w.element([-1, -1, 2])
>>> y = space_1_w.one()
>>> space_1_w.dist(x, y)
7.0