nifty7.multi_field module

class MultiField(domain, val)[source]

Bases: nifty7.operators.operator.Operator

Transforms values defined on one domain into values defined on another domain, and can also provide the Jacobian.

clip(a_min=None, a_max=None)[source]
conjugate()[source]
property domain

The domain on which the Operator’s input Field is defined.

Returns

domain

Return type

DomainTuple or MultiDomain

property dtype
extract(subset)[source]
extract_by_keys(keys)[source]
extract_part(subset)[source]
flexible_addsub(other, neg)[source]

Merges two MultiFields on potentially different MultiDomains.

Parameters
  • other (MultiField) – the partner Field

  • neg (bool) – if True, the partner field is subtracted, otherwise added

Returns

This MultiField’s domain is the union of the input fields’ domains. The values are the sum (or difference, if neg==True) of the fields in self and other. If a field is not present, it is assumed to have an uniform value of zero.

Return type

MultiField

static from_dict(dct, domain=None)[source]
static from_random(domain, random_type='normal', dtype=<class 'numpy.float64'>, **kwargs)[source]

Draws a random multi-field with the given parameters.

Parameters
  • random_type ('pm1', 'normal', or 'uniform') – The random distribution to use.

  • domain (DomainTuple) – The domain of the output random Field.

  • dtype (type) – The datatype of the output random Field. If the datatype is complex, each real an imaginary part have variance 1.

Returns

The newly created MultiField.

Return type

MultiField

Notes

The individual fields within this multi-field will be drawn in alphabetical order of the multi-field’s domain keys. As a consequence, renaming these keys may cause the multi-field to be filled with different random numbers, even for the same initial RNG state.

static from_raw(domain, arr)[source]
static full(domain, val)[source]
property imag

The imaginary part of the multi field

Type

MultiField

items()[source]
keys()[source]
norm(ord=2)[source]

Computes the norm of the field values.

Parameters

ord (int, default=2) – accepted values: 1, 2, …, np.inf

Returns

norm – The norm of the field values.

Return type

float

ptw(op, *args, **kwargs)[source]
ptw_with_deriv(op, *args, **kwargs)[source]
property real

The real part of the multi field

Type

MultiField

s_all()[source]
s_any()[source]
s_sum()[source]

Computes the sum all field values.

Returns

norm – The sum of the field values.

Return type

float

s_vdot(x)[source]
property size

Computes the overall degrees of freedom.

Returns

size – The sum of the size of the individual fields

Return type

int

to_dict()[source]
static union(fields, domain=None)[source]

Returns the union of its input fields.

Parameters
  • fields (iterable of MultiFields) – The set of input fields. Their domains need not be identical.

  • domain (MultiDomain or None) – If supplied, this will be the domain of the resulting field. Providing this domain will accelerate the function.

Returns

The union of the input fields

Return type

MultiField

Notes

If the same key occurs more than once in the input fields, the value associated with the last occurrence will be put into the output. No summation is performed!

unite(other)[source]

Merges two MultiFields on potentially different MultiDomains.

Parameters

other (MultiField) – the partner Field

Returns

This MultiField’s domain is the union of the input fields’ domains. The values are the sum of the fields in self and other. If a field is not present, it is assumed to have an uniform value of zero.

Return type

MultiField

property val

The numerical value associated with this object For “pure” operators this is None. For Field-like objects this is a numpy.ndarray or a dictionary of numpy.ndarray`s mathcing the object’s `target.

Returns

None or numpy.ndarray or dictionary of np.ndarrays

Return type

the numerical value

val_rw()[source]
values()[source]
vdot(x)[source]
func(op)[source]