nifty7.operators.inversion_enabler module#

class InversionEnabler(op, iteration_controller, approximation=None)[source]#

Bases: EndomorphicOperator

Class which augments the capability of another operator object via numerical inversion.

Parameters:
  • op (EndomorphicOperator) – The operator to be enhanced. The InversionEnabler object will support the same operation modes as op, and additionally the inverse set. The newly-added modes will be computed by iterative inversion.

  • iteration_controller (IterationController) – The iteration controller to use for the iterative numerical inversion done by a ConjugateGradient object.

  • approximation (LinearOperator, optional) – if not None, this operator should be an approximation to op, which supports the operation modes that op doesn’t have. It is used as a preconditioner during the iterative inversion, to accelerate convergence.

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

draw_sample(from_inverse=False)[source]#

Generates a sample from a Gaussian distribution with zero mean and covariance given by the operator.

May or may not be implemented. Only optional.

Parameters:

from_inverse (bool (default : False)) – if True, the sample is drawn from the inverse of the operator

Returns:

A sample from the Gaussian of given covariance.

Return type:

Field or MultiField

draw_sample_with_dtype(dtype, from_inverse=False)[source]#

Generates a sample from a Gaussian distribution with zero mean, covariance given by the operator and specified data type.

This method is implemented only for operators which actually draw samples (e.g. DiagonalOperator). Operators which process the sample (like SandwichOperator) implement only draw_sample().

May or may not be implemented. Only optional.

Parameters:
  • dtype (numpy.dtype or dict of numpy.dtype) – Dtype used for sampling from this operator. If the domain of op is a MultiDomain, the dtype can either be specified as one value for all components of the MultiDomain or in form of a dictionary whose keys need to conincide the with keys of the MultiDomain.

  • from_inverse (bool (default : False)) – if True, the sample is drawn from the inverse of the operator

Returns:

A sample from the Gaussian of given covariance.

Return type:

Field or MultiField