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 a \(r \times r(r+1)(r+2)/6\) matrix 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 entries \(\Ghat\).

Examples

>>> import numpy as np
>>> G = opinf.operators.CubicOperator()
>>> entries = np.random.random((10, 1000))  # Operator entries.
>>> 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

Discrete representation of the operator, the matrix \(\Ohat\).

shape

Shape of the operator entries array.

state_dimension

Dimension 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, \(\widehat{\mathbf{G}} = \Wr\trp\mathbf{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 operator entries.

save

Save the operator to an HDF5 file.

set_entries

Set the entries attribute.