nifty7.operators.einsum module

class LinearEinsum(domain, mf, subscripts, key_order=None, optimize='optimal', _target=None, _calling_as_lin=False)[source]

Bases: nifty7.operators.linear_operator.LinearOperator

Linear Einsum operator with exactly one freely varying field

Parameters
  • domain (Domain, DomainTuple or tuple of Domain) – The operator’s input domain.

  • mf (MultiField) – The first part of the left-hand side of the einsum.

  • subscripts (str) – The subscripts which is passed to einsum. Everything before the very last scripts before the ‘->’ is treated as part of the fixed mulfi- field while the last scripts are taken to correspond to the freely varying field.

  • key_order (tuple of str, optional) – The order of the keys in the multi-field. If not specified, defaults to the order of the keys in the multi-field.

  • optimize (bool, String or List, optional) – Parameter passed on to einsum_path.

Notes

The indices of the tensors run along spaces, not the axes of the spaces. For example, a matrix requires a product of two spaces, not one space with the combined shapes.

By convention LinearEinsum only performs operations with lower indices. Therefore no complex conjugation is performed on complex inputs or mf. To achieve operations with upper/lower indices use PartialConjugate before applying this operator.

apply(x, mode)[source]

Applies the Operator to a given x, in a specified mode.

Parameters
  • x (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

Field

class MultiLinearEinsum(domain, subscripts, key_order=None, static_mf=None, optimize='optimal')[source]

Bases: nifty7.operators.operator.Operator

Multi-linear Einsum operator with corresponding derivates

Parameters
  • domain (MultiDomain or dict{name: DomainTuple}) – The operator’s input domain.

  • subscripts (str) – The subscripts which is passed to einsum.

  • key_order (tuple of str, optional) – The order of the keys in the multi-field. If not specified, defaults to the order of the keys in the multi-field.

  • static_mf (MultiField or dict{name: Field}, optional) – A dictionary like type from which Fields are to be taken if the key from key_order is not part of the domain. Fields in this object are supposed to be static as they will not appear as FieldAdapter in the Linearization.

  • optimize (bool, String or List, optional) – Parameter passed on to einsum_path.

Notes

The indices of the tensors run along spaces, not the axes of the spaces. For example, a matrix requires a product of two spaces, not one space with the combined shapes.

By convention MultiLinearEinsum only performs operations with lower indices. Therefore no complex conjugation is performed on complex inputs. To achieve operations with upper/lower indices use PartialConjugate before applying this operator.

apply(x)[source]

Applies the operator to a Field or MultiField.

Parameters

x (Field or MultiField) – Input on which the operator shall act. Needs to be defined on domain.