CubicOperator#

class CubicOperator(entries=None)[source]#

Cubic state operator \(\Ophat_{\ell}(\qhat,\u) = \Ghat[\qhat\otimes\qhat\otimes\qhat]\) where \(\Ghat\in\RR^{r \times r^{3}}\).

Internally, the action of the operator is computed as the product of an \(r \times r(r+1)(r+2)/6\) matrix \(\tilde{\G}\) and a compressed version of the triple Kronecker product \(\qhat \otimes \qhat \otimes \qhat\).

Parameters:
entries(r, r^3) or (r, r(r+1)(r+2)/6) or (r, r, r, r) ndarray or None

Operator matrix \(\Ghat\), its compressed representation \(\tilde{\G}\), or the equivalent symmetric 4-tensor.

Examples

>>> import numpy as np
>>> G = opinf.operators.CubicOperator()
>>> entries = np.random.random((10, 1000))  # Operator matrix.
>>> G.set_entries(entries)
>>> G.shape                                 # Compressed shape.
(10, 220)
>>> q = np.random.random(10)                # State vector.
>>> out = G.apply(q)                        # Apply the operator to q.
>>> np.allclose(out, entries @ np.kron(q, np.kron(q, q)))
True
Properties:
entries#

Internal representation \(\tilde{\G}\) of the operator matrix \(\Ghat\).

shape#

Shape \((r, r(r+1)(r+2)/6)\) of the internal representation \(\tilde{\G}\) of the operator matrix \(\Ghat\).

state_dimension#

Dimension \(r\) of the state \(\qhat\) that the operator acts on.

Methods:

apply

Apply the operator to the given state / input: \(\Ophat_{\ell}(\qhat,\u) = \Ghat[\qhat\otimes\qhat\otimes\qhat]\).

ckron

Calculate the compressed cubic Kronecker product of a vector with itself.

ckron_indices

Construct a mask for efficiently computing the compressed Kronecker triple product.

compress_entries

Given \(\Ghat\in\RR^{a\times r^2}\), construct the matrix \(\tilde{\G}\in\RR^{a \times r(r+1)(r+2)/6}\) such that \(\Ghat[\qhat\otimes\qhat\otimes\qhat] = \tilde{\G}[\qhat\,\hat{\otimes}\,\qhat\,\hat{\otimes}\,\qhat]\) for all \(\qhat\in\RR^{r}\) where \(\cdot\hat{\otimes}\cdot\hat{\otimes}\cdot\) is the compressed cubic Kronecker product (see ckron()).

copy

Return a copy of the operator.

datablock

Return the data matrix block corresponding to the operator, the Khatri--Rao product of the state with itself three times: \(\Qhat\odot\Qhat\odot\Qhat\) where \(\Qhat\) is states.

expand_entries

Given \(\tilde{\G}\in\RR^{a \times r(r+1)(r+2)/6}\), construct the matrix \(\Ghat\in\RR^{a\times r^3}\) such that \(\Ghat[\qhat\otimes\qhat\otimes\qhat] = \tilde{\G}[\qhat\,\hat{\otimes}\,\qhat\,\hat{\otimes}\,\qhat]\) for all \(\qhat\in\RR^{r}\) where \(\cdot\hat{\otimes}\cdot\hat{\otimes}\cdot\) is the compressed cubic Kronecker product (see ckron()).

galerkin

Return the Galerkin projection of the operator, \(\Ghat = (\Wr\trp\Vr)^{-1}\Wr\trp\G[\Vr\otimes\Vr\otimes\Vr]\).

jacobian

Construct the state Jacobian of the operator: \(\ddqhat\Ophat_{\ell}(\qhat,\u) = \Ghat[(\I_r\otimes\qhat\otimes\qhat) + (\qhat\otimes\I_r\otimes\qhat) + (\qhat\otimes\qhat\otimes\I_r)]\).

load

Load an operator from an HDF5 file.

operator_dimension

Column dimension \(r(r+1)(r+2)/6\) of the internal representation \(\tilde{\G}\) of the operator matrix \(\Ghat\).

save

Save the operator to an HDF5 file.

set_entries

Set the internal representation \(\tilde{\G}\) of the operator matrix \(\Ghat\).

verify

Verify consistency between dimension properties and required methods.