nifty8.linearization module#
- class Linearization(val, jac, metric=None, want_metric=False)[source]#
Bases:
Operator
Let A be an operator and x a field. Linearization stores the value of the operator application (i.e. A(x)), the local Jacobian (i.e. dA(x)/dx) and, optionally, the local metric.
- Parameters:
val (
nifty8.field.Field
ornifty8.multi_field.MultiField
) – The value of the operator application.jac (LinearOperator) – The Jacobian.
metric (LinearOperator or None) – The metric. Default: None.
want_metric (bool) – If True, the metric will be computed for other Linearizations derived from this one. Default: False.
- property domain#
the Jacobian’s domain
- Type:
- property gradient#
the gradient
Notes
Only available if target is a scalar
- property imag#
- integrate(spaces=None)[source]#
Computes the (partial) integral over self
- Parameters:
spaces (None, int or list of int) –
if None, integrate over the entire domain
else integrate over the specified subspaces
- Returns:
the (partial) integral
- Return type:
- property jac#
the Jacobian
- Type:
- static make_const(field, want_metric=False)[source]#
Converts a Field to a Linearization, with a zero Jacobian
- Parameters:
field (
nifty8.field.Field
ornifty8.multi_field.MultiField
) – the field to be convertedwant_metric (bool) – If True, the metric will be computed for other Linearizations derived from this one. Default: False.
- Returns:
the requested Linearization
- Return type:
Notes
The Jacobian is square and contains only zeroes.
- static make_const_empty_input(field, want_metric=False)[source]#
Converts a Field to a Linearization, with a zero Jacobian
- Parameters:
field (
nifty8.field.Field
ornifty8.multi_field.MultiField
) – the field to be convertedwant_metric (bool) – If True, the metric will be computed for other Linearizations derived from this one. Default: False.
- Returns:
the requested Linearization
- Return type:
Notes
The Jacobian has an empty input domain, i.e. its matrix representation has 0 columns.
- static make_partial_var(field, constants, want_metric=False)[source]#
Converts a MultiField to a Linearization, with a Jacobian that is unity for some MultiField components and a zero matrix for others.
- Parameters:
field (
nifty8.multi_field.MultiField
) – the field to be convertedconstants (list of string) – the MultiField components for which the Jacobian should be a zero matrix.
want_metric (bool) – If True, the metric will be computed for other Linearizations derived from this one. Default: False.
- Returns:
the requested Linearization
- Return type:
Notes
The Jacobian is square.
- static make_var(field, want_metric=False)[source]#
Converts a Field to a Linearization, with a unity Jacobian
- Parameters:
field (
nifty8.field.Field
ornifty8.multi_field.MultiField
) – the field to be convertedwant_metric (bool) – If True, the metric will be computed for other Linearizations derived from this one. Default: False.
- Returns:
the requested Linearization
- Return type:
- property metric#
the metric
Notes
Only available if target is a scalar
- Type:
- new(val, jac, metric=None)[source]#
- Create a new Linearization, taking the want_metric property from
this one.
- Parameters:
val (
nifty8.field.Field
ornifty8.multi_field.MultiField
) – the value of the operator applicationjac (LinearOperator) – the Jacobian
metric (LinearOperator or None) – The metric. Default: None.
- outer(other)[source]#
Computes the outer product of this Linearization with a Field or another Linearization
- Parameters:
other (
nifty8.field.Field
ornifty8.multi_field.MultiField
or Linearization)- Returns:
the outer product of self and other
- Return type:
- property real#
- sum(spaces=None)[source]#
Computes the (partial) sum over self
- Parameters:
spaces (None, int or list of int) –
if None, sum over the entire domain
else sum over the specified subspaces
- Returns:
the (partial) sum
- Return type:
- property target#
the Jacobian’s target (i.e. the value’s domain)
- Type:
- property val#
the value
- vdot(other)[source]#
Computes the inner product of this Linearization with a Field or another Linearization
- Parameters:
other (
nifty8.field.Field
ornifty8.multi_field.MultiField
or Linearization)- Returns:
the inner product of self and other
- Return type:
- property want_metric#
True iff the metric was requested in the constructor
- Type:
bool