nifty8.operators.simple_linear_operators module#

class ConjugationOperator(domain)[source]#

Bases: EndomorphicOperator

Operator computing the complex conjugate of its input.

Parameters:

domain (Domain, tuple of domains or DomainTuple) – domain of the input field

__init__(domain)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class DomainChangerAndReshaper(domain, target)[source]#

Bases: LinearOperator

Convert nifty domains into each other and reshape field.

This is only possible if domain and target have the same number of pixels.

Parameters:
__init__(domain, target)[source]#
__repr__()[source]#

Return repr(self).

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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class ExtractAtIndices(domain, indices, space=0)[source]#

Bases: LinearOperator

Extract Field values at given indices along a subspace of a DomainTuple, and puts them in a field with an unstructured domain for the given subspace. Note: This operator supports having the same index several times. If this is not the case also the numerically faster GeometryRemover and MaskOperator might be useful.

Parameters:
  • domain (DomainTuple) – Domain of the operator

  • indices (tuple) – Tuple of indices to extract from the field along a given space. The length of the tuple needs to equal the number of axes of the space. Each entry of the tuple should be a tuple of indices to take along the respective axis of the space. Example for a 2d space: indices=((0,1,1,0), (3,4,1,5)) will extract the pixels (0,3), (1,4), (1,1) and (0,5).

  • space (int) – The index of the space in the domain along which to extract values

__init__(domain, indices, space=0)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class FieldAdapter(target, name)[source]#

Bases: LinearOperator

Operator for conversion between Fields and MultiFields.

Parameters:
  • tgt (Domain, tuple of domains, DomainTuple, dict or MultiDomain:) – If this is a Domain, tuple of Domain or DomainTuple, this will be the operator’s target, and its domain will be a MultiDomain consisting of its domain with the supplied name If this is a dict or MultiDomain, everything except for name will be stripped out of it, and the result will be the operator’s target. Its domain will then be the DomainTuple corresponding to the single entry in the operator’s domain.

  • name (String) – The relevant key of the MultiDomain.

__init__(target, name)[source]#
__repr__()[source]#

Return repr(self).

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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class GeometryRemover(domain, space=None)[source]#

Bases: LinearOperator

Operator which transforms between a structured and an unstructured domain.

Parameters:
  • domain (Domain, tuple of Domain, or DomainTuple:) – the full input domain of the operator.

  • space (int, optional) – The index of the subdomain on which the operator should act. If None, it acts on all spaces.

Notes

The operator will convert every sub-domain of its input domain to an UnstructuredDomain with the same shape. No weighting by volume factors is carried out.

__init__(domain, space=None)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class Imaginizer(domain)[source]#

Bases: EndomorphicOperator

Operator returning the imaginary component of its input.

Parameters:

domain (Domain, tuple of domains, DomainTuple or MultiDomain) – domain of the input field

__init__(domain)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class NullOperator(domain, target)[source]#

Bases: LinearOperator

Operator corresponding to a matrix of all zeros.

Parameters:
__init__(domain, target)[source]#
__repr__()[source]#

Return repr(self).

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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class PartialExtractor(domain, target)[source]#

Bases: LinearOperator

NIFTY base class for linear operators.

The base NIFTY operator class is an abstract class from which other specific operator subclasses are derived.

Variables:
  • TIMES (int) – Symbolic constant representing normal operator application

  • ADJOINT_TIMES (int) – Symbolic constant representing adjoint operator application

  • INVERSE_TIMES (int) – Symbolic constant representing inverse operator application

  • ADJOINT_INVERSE_TIMES (int) – Symbolic constant representing adjoint inverse operator application

  • INVERSE_ADJOINT_TIMES (int) – same as ADJOINT_INVERSE_TIMES

Notes

The symbolic constants for the operation modes can be combined by the “bitwise-or” operator “|”, for expressing the capability of the operator by means of a single integer number.

__init__(domain, target)[source]#
__repr__()[source]#

Return repr(self).

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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class PrependKey(domain, pre)[source]#

Bases: LinearOperator

Prepend a string to all keys of a MultiDomain.

Parameters:
__init__(domain, pre)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class Realizer(domain)[source]#

Bases: EndomorphicOperator

Operator returning the real component of its input.

Parameters:

domain (Domain, tuple of domains, DomainTuple or MultiDomain) – domain of the input field

__init__(domain)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class VdotOperator(field)[source]#

Bases: LinearOperator

Operator computing the scalar product of its input with a given Field.

Parameters:

field (nifty8.field.Field or nifty8.multi_field.MultiField) – The field used to build the scalar product with the operator input

__init__(field)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

class WeightApplier(domain, spaces, power)[source]#

Bases: EndomorphicOperator

Operator multiplying its input by a given power of dvol.

Parameters:
  • domain (Domain, tuple of domains or DomainTuple) – domain of the input field

  • spaces (list or tuple of int) – indices of subdomains for which the weights shall be applied

  • power (int) – the power of to be used for the volume factors

__init__(domain, spaces, power)[source]#
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 application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty8.field.Field

ducktape(left, right, name)[source]#

Convenience function creating an operator that converts between a DomainTuple and a MultiDomain.

Parameters:
  • left (None, Operator, or Domainoid) – Something describing the new operator’s target domain. If left is an Operator, its domain is used as left.

  • right (None, Operator, or Domainoid) – Something describing the new operator’s input domain. If right is an Operator, its target is used as right.

  • name (string) – The component of the MultiDomain that will be extracted/inserted

Notes

  • one of the involved domains must be a DomainTuple, the other a MultiDomain.

  • left and right must not be both None, but one of them can (and probably should) be None. In this case, the missing information is inferred.

Returns:

an adapter operator converting between the two (possibly partially inferred) domains.

Return type:

FieldAdapter or _SlowFieldAdapter