nifty8.multi_field module#
- class MultiField(domain, val)[source]#
Bases:
Operator
Transforms values defined on one domain into values defined on another domain, and can also provide the Jacobian.
- __init__(domain, val)[source]#
The discrete representation of a continuous field over a sum space.
- Parameters:
domain (MultiDomain)
val (tuple containing Field entries)
- property domain#
The domain on which the Operator’s input Field is defined.
- Returns:
domain
- Return type:
- property dtype#
- flexible_addsub(other, neg)[source]#
Merges two MultiFields on potentially different MultiDomains.
- Parameters:
other (
nifty8.multi_field.MultiField
) – the partner Fieldneg (bool or dict) – 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:
- 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:
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.
- property imag#
The imaginary part of the multi field
- Type:
- 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
- property real#
The real part of the multi field
- Type:
- s_sum()[source]#
Computes the sum all field values.
- Returns:
norm – The sum of the field values.
- Return type:
float
- property size#
Computes the overall degrees of freedom.
- Returns:
size – The sum of the size of the individual fields
- Return type:
int
- static union(fields, domain=None)[source]#
Returns the union of its input fields.
- Parameters:
fields (iterable of
nifty8.multi_field.MultiField
) – 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:
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 (
nifty8.multi_field.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:
- 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