Skip to main content

core.Operator

core.Operator()

A precision operator on vectors V: products, solves, its diagonal and log-determinant.

A vector’s leading axes are a batch: mv, solve and cov_sqrt_mv take [..., P] (or a mapping of such tensors) and act on each vector. A plugin operator held in a LaplacePosterior must accept this, since batched covariance products pass [n, P].

Methods

Name Description
add_diagonal The operator for \(P + \operatorname{diag}(d)\).
add_isotropic The operator for \(P + \lambda I\).
add_same The operator for \(P + P'\), with \(P'\) an operator of the same type.
cov_sqrt_mv The product \(L v\) with a square root \(L\) of the covariance, \(L L^\top = P^{-1}\).
diagonal The diagonal of the precision, \(\operatorname{diag}(P)\).
inverse_diagonal The diagonal of the covariance, \(\operatorname{diag}(P^{-1})\).
logdet The log-determinant \(\log \det P\).
mv The product \(P v\) with the precision \(P\).
scaled The operator for \(s P\).
solve The solve \(P^{-1} v\).

add_diagonal

core.Operator.add_diagonal(d, /)

The operator for \(P + \operatorname{diag}(d)\).

Parameters

Name Type Description Default
d V The diagonal \(d\), shaped like a vector of the operator. required

Returns

Name Type Description
Self An operator of the same type.

Raises

Name Type Description
StructureError Implementations raise it when their structure can’t hold a diagonal.

add_isotropic

core.Operator.add_isotropic(precision, /)

The operator for \(P + \lambda I\).

Parameters

Name Type Description Default
precision Tensor The precision \(\lambda\), a 0-dim tensor. required

Returns

Name Type Description
Self An operator of the same type.

add_same

core.Operator.add_same(other, /)

The operator for \(P + P'\), with \(P'\) an operator of the same type.

Parameters

Name Type Description Default
other Operator[V] The operator \(P'\). required

Returns

Name Type Description
Self An operator of the same type.

Raises

Name Type Description
StructureError other has another type, or implementations can’t hold the sum.

cov_sqrt_mv

core.Operator.cov_sqrt_mv(v, /)

The product \(L v\) with a square root \(L\) of the covariance, \(L L^\top = P^{-1}\).

Parameters

Name Type Description Default
v V A vector [..., P], or a mapping of such vectors keyed by block name. required

Returns

Name Type Description
V \(L v\), shaped like v.

Raises

Name Type Description
StructureError Implementations may raise it when \(P\) is not positive definite.

diagonal

core.Operator.diagonal()

The diagonal of the precision, \(\operatorname{diag}(P)\).

Returns

Name Type Description
V A vector [P], or a mapping of them keyed by block name.

inverse_diagonal

core.Operator.inverse_diagonal()

The diagonal of the covariance, \(\operatorname{diag}(P^{-1})\).

Operators compute it without forming \(P^{-1}\) where their structure allows; Dense without a cached eigendecomposition forms it.

Returns

Name Type Description
V A vector [P], or a mapping of them keyed by block name.

Raises

Name Type Description
StructureError Implementations may raise it when \(P\) is not positive definite.

logdet

core.Operator.logdet()

The log-determinant \(\log \det P\).

Returns

Name Type Description
Tensor A 0-dim tensor.

Raises

Name Type Description
StructureError Implementations may raise it when \(P\) is not positive definite.

mv

core.Operator.mv(v, /)

The product \(P v\) with the precision \(P\).

Parameters

Name Type Description Default
v V A vector [..., P], or a mapping of such vectors keyed by block name. required

Returns

Name Type Description
V \(P v\), shaped like v.

scaled

core.Operator.scaled(s, /)

The operator for \(s P\).

Parameters

Name Type Description Default
s Tensor A 0-dim factor. required

Returns

Name Type Description
Self An operator of the same type.

solve

core.Operator.solve(v, /)

The solve \(P^{-1} v\).

Parameters

Name Type Description Default
v V A vector [..., P], or a mapping of such vectors keyed by block name. required

Returns

Name Type Description
V \(P^{-1} v\), shaped like v.

Raises

Name Type Description
StructureError Implementations may raise it when \(P\) is not positive definite.