Operators

Operators perform some operation on a given field. In practice an operator can take the form of an explicit matrix (e.g. stored in a Numpy array) or it may be implicitly defined as a function (e.g. an FFT operation would not be encoded in a matrix, but performed using an FFT routine). NIFTY includes a framework for handling arbitrary operators, and basic methods for manipulating these operators. Common functions like taking traces and extracting diagonals are provided.

In order to have a blueprint for operators capable of handling fields, any application of operators is split into a general and a concrete part. The general part comprises the correct involvement of normalizations and transformations, necessary for any operator type, while the concrete part is unique for each operator subclass. In analogy to the field class, any operator instance has a set of properties that specify its domain and target as well as some additional flags.

For example, the application of an operator A to a field s is coded as A(s), or equivalently A.times(s). The instance method times() then invokes _briefing(), _multiply() and _debriefing() consecutively. The briefing and debriefing are generic methods in which in- and output are checked; e.g., the input field might be transformed automatically during the briefing to match the operator’s domain. The _multiply() method, being the concrete part, is the only contribution coded by the user. This can be done either explicitly by multiplication with a complete matrix or implicitly by a computer routine.

Operator classes

NIFTY provides a base class for defining operators, as well as several pre-implemented operator types that are very often needed for signal inference algorithms.

The simplest operator is the identity operator. An identity operator instance is generated with a call to identity()

nifty.identity(domain)

Returns an identity operator.

The identity operator is represented by a diagonal_operator instance, which is applicable to a field-like object; i.e., a scalar, list, array or field. (The identity operator is unrelated to PYTHON’s built-in function id().)

Parameters :

domain : space

The space wherein valid arguments live.

Returns :

id : diagonal_operator

The identity operator as a diagonal_operator instance.

Examples

>>> I = identity(rg_space(8,dist=0.2))
>>> I.diag()
array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.])
>>> I.diag(bare=True)
array([ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.])
>>> I.tr()
8.0
>>> I(3)
<nifty.field>
>>> I(3).val
array([ 3.,  3.,  3.,  3.,  3.,  3.,  3.,  3.])
>>> I(np.arange(8))[:]
array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.])
>>> f = I.get_random_field()
>>> print(I(f) - f)
nifty.field instance
- domain      = <nifty.rg_space>
- val         = [...]
  - min.,max. = [0.0, 0.0]
  - med.,mean = [0.0, 0.0]
- target      = <nifty.rg_space>
>>> I.times(f) ## equal to I(f)
<nifty.field>
>>> I.inverse_times(f)
<nifty.field>

Table Of Contents

Previous topic

Cos(x)

Next topic

The operator class – The base operator object

This Page