nifty7.linearization module

class Linearization(val, jac, metric=None, want_metric=False)[source]

Bases: nifty7.operators.operator.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 (Field or 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.

add_metric(metric)[source]
conjugate()[source]
property domain

the Jacobian’s domain

Type

DomainTuple or MultiDomain

property gradient

the gradient

Notes

Only available if target is a scalar

Type

Field or MultiField

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

Linearization

property jac

the Jacobian

Type

LinearOperator

static make_const(field, want_metric=False)[source]

Converts a Field to a Linearization, with a zero Jacobian

Parameters
  • field (Field or Multifield) – the field to be converted

  • 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

Linearization

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 (Field or Multifield) – the field to be converted

  • 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

Linearization

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 (Multifield) – the field to be converted

  • constants (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

Linearization

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 (Field or Multifield) – the field to be converted

  • 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

Linearization

property metric

the metric

Notes

Only available if target is a scalar

Type

LinearOperator

new(val, jac, metric=None)[source]
Create a new Linearization, taking the want_metric property from

this one.

Parameters
outer(other)[source]

Computes the outer product of this Linearization with a Field or another Linearization

Parameters

other (Field or MultiField or Linearization) –

Returns

the outer product of self and other

Return type

Linearization

prepend_jac(jac)[source]
ptw(op, *args, **kwargs)[source]
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

Linearization

property target

the Jacobian’s target (i.e. the value’s domain)

Type

DomainTuple or MultiDomain

trivial_jac()[source]
property val

the value

Type

Field or MultiField

vdot(other)[source]

Computes the inner product of this Linearization with a Field or another Linearization

Parameters

other (Field or MultiField or Linearization) –

Returns

the inner product of self and other

Return type

Linearization

property want_metric

True iff the metric was requested in the constructor

Type

bool

with_want_metric()[source]