MatrixWeighting

class odl.space.weighting.MatrixWeighting(matrix, impl, exponent=2.0, **kwargs)[source]

Bases: odl.space.weighting.Weighting

Weighting of a space by a matrix.

The exact definition of the weighted inner product, norm and distance functions depend on the concrete space.

The matrix must be Hermitian and posivive definite, otherwise it does not define an inner product or norm, respectively. This is not checked during initialization.

Attributes
exponent

Exponent of this weighting.

impl

Implementation backend of this weighting.

matrix

Weighting matrix of this inner product.

repr_part

Return a string usable in a space’s __repr__ method.

Methods

dist(self, x1, x2)

Calculate the distance between two elements.

equiv(self, other)

Test if other is an equivalent weighting.

inner(self, x1, x2)

Return the inner product of two elements.

is_valid(self)

Test if the matrix is positive definite Hermitian.

matrix_decomp(self[, cache])

Compute a Hermitian eigenbasis decomposition of the matrix.

norm(self, x)

Calculate the norm of an element.

__init__(self, matrix, impl, exponent=2.0, \*\*kwargs)[source]

Initialize a new instance.

Parameters
matrixscipy.sparse.spmatrix or 2-dim. array-like

Square weighting matrix of the inner product

implstring

Specifier for the implementation backend

exponentpositive float, optional

Exponent of the norm. For values other than 2.0, the inner product is not defined. If matrix is a sparse matrix, only 1.0, 2.0 and inf are allowed.

precomp_mat_powbool, optional

If True, precompute the matrix power W ** (1/p) during initialization. This has no effect if exponent is 1.0, 2.0 or inf.

Default: False

cache_mat_powbool, optional

If True, cache the matrix power W ** (1/p). This can happen either during initialization or in the first call to norm or dist, resp. This has no effect if exponent is 1.0, 2.0 or inf.

Default: True

cache_mat_decompbool, optional

If True, cache the eigenbasis decomposition of the matrix. This can happen either during initialization or in the first call to norm or dist, resp. This has no effect if exponent is 1.0, 2.0 or inf.

Default: False

Notes

The matrix power W ** (1/p) is computed by eigenbasis decomposition:

eigval, eigvec = scipy.linalg.eigh(matrix)
mat_pow = (eigval ** p * eigvec).dot(eigvec.conj().T)

Depending on the matrix size, this can be rather expensive.