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 the operator to the given state / input: \(\Ophat_{\ell}(\qhat,\u) = \Ghat[\qhat\otimes\qhat\otimes\qhat]\).
Calculate the compressed cubic Kronecker product of a vector with itself.
Construct a mask for efficiently computing the compressed Kronecker triple product.
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()
).Return a copy of the operator.
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
.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()
).Return the Galerkin projection of the operator, \(\Ghat = (\Wr\trp\Vr)^{-1}\Wr\trp\G[\Vr\otimes\Vr\otimes\Vr]\).
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 an operator from an HDF5 file.
Column dimension \(r(r+1)(r+2)/6\) of the internal representation \(\tilde{\G}\) of the operator matrix \(\Ghat\).
Save the operator to an HDF5 file.
Set the internal representation \(\tilde{\G}\) of the operator matrix \(\Ghat\).
Verify consistency between dimension properties and required methods.