nifty8.operators.diagonal_operator module#
- class DiagonalOperator(diagonal, domain=None, spaces=None, sampling_dtype=None)[source]#
Bases:
EndomorphicOperator
Represents a
LinearOperator
which is diagonal.The NIFTy DiagonalOperator class is a subclass derived from the
EndomorphicOperator
. It multiplies an input field pixel-wise with its diagonal.- Parameters:
diagonal (
nifty8.field.Field
) – The diagonal entries of the operator.domain (Domain, tuple of Domain or DomainTuple, optional) – The domain on which the Operator’s input Field is defined. If None, use the domain of “diagonal”.
spaces (int or tuple of int, optional) – The elements of “domain” on which the operator acts. If None, it acts on all elements.
sampling_dtype – If this operator represents the covariance of a Gaussian probabilty distribution, sampling_dtype specifies if it is real or complex Gaussian. If sampling_dtype is None, the operator cannot be used as a covariance, i.e. no samples can be drawn. Default: None.
Notes
Formally, this operator always supports all operation modes (times, adjoint_times, inverse_times and inverse_adjoint_times), even if there are diagonal elements with value 0 or infinity. It is the user’s responsibility to apply the operator only in appropriate ways (e.g. call inverse_times only if there are no zeros on the diagonal).
This shortcoming will hopefully be fixed in the future.
- apply(x, mode)[source]#
Applies the Operator to a given x, in a specified mode.
- Parameters:
x (
nifty8.field.Field
) – The input Field, defined on the Operator’s domain or target, depending on mode.mode (int) –
TIMES
: normal applicationADJOINT_TIMES
: adjoint applicationINVERSE_TIMES
: inverse applicationADJOINT_INVERSE_TIMES
orINVERSE_ADJOINT_TIMES
: adjoint inverse application
- Returns:
The processed Field defined on the Operator’s target or domain, depending on mode.
- Return type:
- draw_sample(from_inverse=False)[source]#
Generates a sample from a Gaussian distribution with zero mean and covariance given by the operator.
May or may not be implemented. Only optional.
- Parameters:
from_inverse (bool (default : False)) – if True, the sample is drawn from the inverse of the operator
- Returns:
A sample from the Gaussian of given covariance.
- Return type: