The DiagonalOperator class – …¶

class nifty.DiagonalOperator[source]

Bases: nifty.operators.endomorphic_operator.endomorphic_operator.EndomorphicOperator

NIFTY class for diagonal operators.

The NIFTY DiagonalOperator class is a subclass derived from the EndomorphicOperator. It multiplies an input field pixel-wise with its diagonal.

Parameters: domain : tuple of DomainObjects, i.e. Spaces and FieldTypes The domain on which the Operator’s input Field lives. diagonal : {scalar, list, array, Field, d2o-object} The diagonal entries of the operator. bare : boolean Indicates whether the input for the diagonal is bare or not (default: False). copy : boolean Internal copy of the diagonal (default: True) distribution_strategy : string setting the prober distribution_strategy of the diagonal (default : None). In case diagonal is d2o-object or Field, their distribution_strategy is used as a fallback. default_spaces : tuple of ints optional Defines on which space(s) of a given field the Operator acts by default (default: None)

EndomorphicOperator

Notes

The ambiguity of bare or non-bare diagonal entries is based on the choice of a matrix representation of the operator in question. The naive choice of absorbing the volume weights into the matrix leads to a matrix-vector calculus with the non-bare entries which seems intuitive, though. The choice of keeping matrix entries and volume weights separate deals with the bare entries that allow for correct interpretation of the matrix entries; e.g., as variance in case of an covariance operator.

Examples

>>> x_space = RGSpace(5)
>>> D = DiagonalOperator(x_space, diagonal=[1., 3., 2., 4., 6.])
>>> f = Field(x_space, val=2.)
>>> res = D.times(f)
>>> res.val
<distributed_data_object>
array([ 2.,  6.,  4.,  8.,  12.])

Attributes

 domain domain – tuple of DomainObjects, i.e. Spaces and FieldTypes target target – tuple of DomainObjects, i.e. Spaces and FieldTypes unitary unitary – boolean self_adjoint States whether the Operator is self_adjoint or not. distribution_strategy distribution_strategy –

Methods

 determinant() Returns the determinant of the operator. diagonal([bare, copy]) Returns the diagonal of the Operator. inverse_determinant() Returns the inverse-determinant of the operator. inverse_diagonal([bare]) Returns the inverse-diagonal of the operator. inverse_trace([bare]) Returns the inverse-trace of the operator. log_determinant() Returns the log-eterminant of the operator. set_diagonal(diagonal[, bare, copy]) Sets the diagonal of the Operator. trace([bare]) Returns the trace the operator. trace_log() Returns the trave-log of the operator.
determinant()[source]

Returns the determinant of the operator.

Returns: out : scalar out : scalar the determinant of the Operator
diagonal(bare=False, copy=True)[source]

Returns the diagonal of the Operator.

Parameters: bare : boolean Whether the returned Field values should be bare or not. copy : boolean Whether the returned Field should be copied or not. out : Field The diagonal of the Operator.
inverse_determinant()[source]

Returns the inverse-determinant of the operator.

Returns: out : scalar the inverse-determinant of the Operator
inverse_diagonal(bare=False)[source]

Returns the inverse-diagonal of the operator.

Parameters: bare : boolean Whether the returned Field values should be bare or not. out : Field The inverse of the diagonal of the Operator.
inverse_trace(bare=False)[source]

Returns the inverse-trace of the operator.

Parameters: bare : boolean Whether the returned Field values should be bare or not. out : scalar The inverse of the trace of the Operator.
log_determinant()[source]

Returns the log-eterminant of the operator.

Returns: out : scalar the log-determinant of the Operator
set_diagonal(diagonal, bare=False, copy=True)[source]

Sets the diagonal of the Operator.

Parameters: diagonal : {scalar, list, array, Field, d2o-object} The diagonal entries of the operator. bare : boolean Indicates whether the input for the diagonal is bare or not (default: False). copy : boolean Specifies if a copy of the input shall be made (default: True).
trace(bare=False)[source]

Returns the trace the operator.

Parameters: bare : boolean Whether the returned Field values should be bare or not. out : scalar The trace of the Operator.
trace_log()[source]

Returns the trave-log of the operator.

Returns: out : scalar the trace of the logarithm of the Operator.
distribution_strategy

distribution_strategy

string
Defines the way how the diagonal operator is distributed among the nodes. Available distribution_strategies are: ‘fftw’, ‘equal’ and ‘not’.
Notes :
https://arxiv.org/abs/1606.05385
domain

domain – tuple of DomainObjects, i.e. Spaces and FieldTypes The domain on which the Operator’s input Field lives. Every Operator which inherits from the abstract LinearOperator base class must have this attribute.