LinearSpace class represent abstract mathematical concepts
of vector spaces. It cannot be used directly but are rather intended
to be subclassed by concrete space implementations. The space
provides default implementations of the most important vector space
operations. See the documentation of the respective classes for more
The concept of linear vector spaces in ODL is largely inspired by the Rice Vector Library (RVL).
LinearSpace class is intended for quick prototyping.
It has a number of abstract methods which must be overridden by a
subclass. On the other hand, it provides automatic error checking
and numerous attributes and methods for convenience.
In the following, the abstract methods are explained in detail.
This public method is the factory for the inner
LinearSpaceElement class. It creates a new element of the space,
either from scratch or from an existing data container. In the
simplest possible case, it just delegates the construction to the
If no data is provided, the new element is merely allocated, not initialized, thus it can contain any value.
_lincomb(a, x1, b, x2, out)
This private method is the raw implementation (i.e. without error
checking) of the linear combination
out = a * x1 + b * x2.
LinearSpace._lincomb and its public counterpart
LinearSpace.lincomb are used to cover a range of convenience
functions, see below.
outmust be allowed.
The input elements
x2must not be modified.
The initial state of the output element
outmust not influence the result.
Underlying scalar field¶
Should be implemented as a
@property to make it immutable.
A raw (not type-checking) private method measuring the distance
between two elements
A space with a distance is called a metric space.
Elements whose mutual distance to calculate.
The distance between
x2, measured in the space’s metric
_dist(x, y) == _dist(y, x)
_dist(x, y) <= _dist(x, z) + _dist(z, y)
_dist(x, y) >= 0
_dist(x, y) == 0(approx.) if and only if
x == y(approx.)
A raw (not type-checking) private method measuring the length of a
A space with a norm is called a normed space.
Inner product (optional)¶
A raw (not type-checking) private method calculating the inner
product of two space elements
Elements whose inner product to calculate.
_inner(x, y) == _inner(y, x)^*with ‘*’ = complex conjugation
_inner(s * x, y) == s * _inner(x, y)for
_inner(x + z, y) == _inner(x, y) + _inner(z, y)
_inner(x, x) == 0(approx.) if and only if
x == 0(approx.)
Pointwise multiplication (optional)¶
_multiply(x1, x2, out)
A raw (not type-checking) private method multiplying two elements
x2 point-wise and storing the result in
_multiply(x, y, out) <==> _multiply(y, x, out)
_multiply(s * x, y, out) <==> _multiply(x, y, out); out *= s <==>
_multiply(x, s * y, out)for any scalar
There is a space element
_multiply(one, x, out)or
_multiply(x, one, out)equals
A normed space is automatically a metric space with the distance function
_dist(x, y) = _norm(x - y).
A Hilbert space (inner product space) is automatically a normed space with the norm function
_norm(x) = sqrt(_inner(x, x)).
The conditions on the pointwise multiplication constitute a unital commutative algebra in the mathematical sense.