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 pixelwise 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, d2oobject}
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 d2oobject 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)
See also
EndomorphicOperator
Notes
The ambiguity of bare or nonbare 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 matrixvector calculus with the nonbare 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 inversedeterminant of the operator. inverse_diagonal
([bare])Returns the inversediagonal of the operator. inverse_trace
([bare])Returns the inversetrace of the operator. log_determinant
()Returns the logeterminant 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 travelog 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.
Returns: out : Field
The diagonal of the Operator.

inverse_determinant
()[source]¶ Returns the inversedeterminant of the operator.
Returns: out : scalar
the inversedeterminant of the Operator

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

inverse_trace
(bare=False)[source]¶ Returns the inversetrace of the operator.
Parameters: bare : boolean
Whether the returned Field values should be bare or not.
Returns: out : scalar
The inverse of the trace of the Operator.

log_determinant
()[source]¶ Returns the logeterminant of the operator.
Returns: out : scalar
the logdeterminant of the Operator

set_diagonal
(diagonal, bare=False, copy=True)[source]¶ Sets the diagonal of the Operator.
Parameters: diagonal : {scalar, list, array, Field, d2oobject}
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.
Returns: out : scalar
The trace of the Operator.

trace_log
()[source]¶ Returns the travelog 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.

self_adjoint
¶ States whether the Operator is self_adjoint or not.

unitary
¶ unitary – boolean States whether the Operator is unitary or not. Every Operator which inherits from the abstract LinearOperator base class must have this attribute.
